Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#define ERROR_CALIB_DATA_SIZE -5
#define MAX_DATA_SIZE 450
#define MAX_MATRIX_BUFFER 450
//################################################################################################
//
// IN : int data_size: size of the calibration data buffer
// IN/OUT : char * calib_data: the formatted calibration data buffer (max size = 450 bytes)
//################################################################################################
int compose_data(int p_A_0_xi, int p_A_0_yi, int p_A_Z_xi, int p_A_Z_yi, int p_B_0_xi,
int p_B_0_yi, int p_B_Z_xi, int p_B_Z_yi, int height_cm, double xy,int res_x, int res_y, int data_size, char * calib_data)
{
int ret = 0;
int nchars = 0;
int real_size = 0;
char temp_buf[MAX_DATA_SIZE]={0};
sprintf( temp_buf,"PA_0_X:%d;PA_0_Y:%d;PA_Z_X:%d;PA_Z_Y:%d;PB_0_X:%d;PB_0_Y:%d;PB_Z_X:%d;PB_Z_Y:%d\nHEIGHT_CM:%d;PIXEL_XY:%f;RES_X:%d;RES_Y:%d\n",
p_A_0_xi, p_A_0_yi, p_A_Z_xi, p_A_Z_yi,
p_B_0_xi, p_B_0_yi, p_B_Z_xi, p_B_Z_yi,
height_cm, xy, res_x, res_y);
real_size =strlen(temp_buf);
if (real_size>data_size)
return ERROR_CALIB_DATA_SIZE;
strcpy (calib_data,temp_buf);
return ret;
}
int main(int argc, char* argv[])
{
int res_x = 5;
int res_y = 15;
char calib_data[MAX_DATA_SIZE]={0};
char result_buffer[MAX_MATRIX_BUFFER]={0};
int size_length = MAX_DATA_SIZE;
printf("\nCalling vgt_compose_calib_data...\n");
compose_data(70,170,110,210,50,90,150,120,170,1.0,res_x,res_y,size_length, calib_data);
printf("STRING DATA BUFFER:\n%s\n",calib_data);
int size_in = strlen(calib_data);//or sizeof(buffer)
printf("size of calib_data: %d\n",size_in);
getchar();
return 0;
}
int compose_data(int p_A_0_xi, int p_A_0_yi, int p_A_Z_xi, int p_A_Z_yi, int p_B_0_xi,
int p_B_0_yi, int p_B_Z_xi, int p_B_Z_yi, int height_cm, double xy,int res_x, int res_y, int data_size, char * calib_data)
{
int ret = 0;
int real_size = 0;
sprintf( calib_data,"PA_0_X:%d;PA_0_Y:%d;PA_Z_X:%d;PA_Z_Y:%d;PB_0_X:%d;PB_0_Y:%d;PB_Z_X:%d;PB_Z_Y:%d\nHEIGHT_CM:%d;PIXEL_XY:%f;RES_X:%d;RES_Y:%d\n",
p_A_0_xi, p_A_0_yi, p_A_Z_xi, p_A_Z_yi,
p_B_0_xi, p_B_0_yi, p_B_Z_xi, p_B_Z_yi,
height_cm, xy, res_x, res_y);
real_size =strlen(calib_data);
if (real_size>data_size)
return ERROR_CALIB_DATA_SIZE;
return ret;
}
int compose_data(int p_A_0_xi, int p_A_0_yi, int p_A_Z_xi, int p_A_Z_yi, int p_B_0_xi,
int p_B_0_yi, int p_B_Z_xi, int p_B_Z_yi, int height_cm,
double xy,int res_x, int res_y, int data_size, char * calib_data)
{
int ret = ERROR_CALIB_DATA_SIZE;
int real_size = 0;
char temp_buf[MAX_DATA_SIZE] = { 0 };
if (calib_data == 0 || data_size == 0)
return ret;
real_size = sprintf( temp_buf,"PA_0_X:%d;PA_0_Y:%d;PA_Z_X:%d;PA_Z_Y:%d;PB_0_X:%d;PB_0_Y:%d;PB_Z_X:%d;PB_Z_Y:%d\nHEIGHT_CM:%d;PIXEL_XY:%f;RES_X:%d;RES_Y:%d\n",
p_A_0_xi, p_A_0_yi, p_A_Z_xi, p_A_Z_yi,
p_B_0_xi, p_B_0_yi, p_B_Z_xi, p_B_Z_yi,
height_cm, xy, res_x, res_y);
if (real_size < data_size)
{
strcpy (calib_data, temp_buf);
ret = 0;
}
return ret;
}
int compose_data(int p_A_0_xi, int p_A_0_yi, int p_A_Z_xi, int p_A_Z_yi, int p_B_0_xi,
int p_B_0_yi, int p_B_Z_xi, int p_B_Z_yi, int height_cm,
double xy,int res_x, int res_y, int data_size, char * calib_data)
{
int real_size = 0;
char temp_buf[MAX_DATA_SIZE] = { 0 };
real_size = sprintf( temp_buf,"PA_0_X:%d;PA_0_Y:%d;PA_Z_X:%d;PA_Z_Y:%d;PB_0_X:%d;PB_0_Y:%d;PB_Z_X:%d;PB_Z_Y:%d\nHEIGHT_CM:%d;PIXEL_XY:%f;RES_X:%d;RES_Y:%d\n",
p_A_0_xi, p_A_0_yi, p_A_Z_xi, p_A_Z_yi,
p_B_0_xi, p_B_0_yi, p_B_Z_xi, p_B_Z_yi,
height_cm, xy, res_x, res_y);
if (calib_data != 0 && real_size < data_size)
strcpy (calib_data, temp_buf);
return real_size;
}
int compose_data(int p_A_0_xi, int p_A_0_yi, int p_A_Z_xi, int p_A_Z_yi, int p_B_0_xi,
int p_B_0_yi, int p_B_Z_xi, int p_B_Z_yi, int height_cm, double pixel_xy,int res_x, int res_y, int data_size, char * calib_data)
{
int ret = 0;
int nchars = 0;
int real_size = 0;
char temp_buf[MAX_CALIBRATION_DATA]={0};
memset(calib_data,0,data_size);
real_size=sprintf( temp_buf,"PA_0_X:%d;PA_0_Y:%d;PA_Z_X:%d;PA_Z_Y:%d;PB_0_X:%d;PB_0_Y:%d;PB_Z_X:%d;PB_Z_Y:%d\nHEIGHT_CM:%d;PIXEL_XY:%f;RES_X:%d;RES_Y:%d\n",
p_A_0_xi, p_A_0_yi, p_A_Z_xi, p_A_Z_yi,
p_B_0_xi, p_B_0_yi, p_B_Z_xi, p_B_Z_yi,
height_cm, pixel_xy, res_x, res_y);
if (calib_data != 0 && real_size < data_size)
strcpy (calib_data,temp_buf);
else
return ERROR_CALIB_DATA_SIZE;
return ret;
}
{
int ret = 0;
int nchars = 0;
int real_size = 0;
char temp_buf[MAX_CALIBRATION_DATA]={0};
if(calib_data!=NULL) //NEW CHECK
return ERROR_BAD_INITIALIZED_BUFFER;
memset(calib_data,0,data_size);
real_size=sprintf( temp_buf,"PA_0_X:%d;PA_0_Y:%d;PA_Z_X:%d;PA_Z_Y:%d;PB_0_X:%d;PB_0_Y:%d;PB_Z_X:%d;PB_Z_Y:%d\nHEIGHT_CM:%d;PIXEL_XY:%f;RES_X:%d;RES_Y:%d\n",
p_A_0_xi, p_A_0_yi, p_A_Z_xi, p_A_Z_yi,
p_B_0_xi, p_B_0_yi, p_B_Z_xi, p_B_Z_yi,
height_cm, pixel_xy, res_x, res_y);
if (calib_data != 0 && real_size < data_size)
strcpy (calib_data,temp_buf);
else
return ERROR_CALIB_DATA_SIZE;
return ret;
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
splitOdd10 challenge | 5 | 104 | |
MacOS and programming in React | 7 | 34 | |
nested if statement in excel help | 4 | 26 | |
If a cell in a range equals "YES" return specific Test. | 4 | 27 |
Join the community of 500,000 technology professionals and ask your questions.