Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
Become a Premium Member and unlock a new, free course in leading technologies each month.
#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;
}
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
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
Join the community of 500,000 technology professionals and ask your questions.