Click here to show toolbars of the Web Online Help System: show toolbars |
Appendix A. Parse4610Stream Sample Code
void Process4610PrintPacket(char *in_buff, int in_len)
{
char *buffp;
int len_remain;
ulong line_feeds;
char printData[100];
LOG_SETUP("Process4610Packet");
long prt4610Station = 0;
parse4610CommandInfo_t cmdI = {0};
parse4610ContinueInfo_t contI = {0};
uint cmd_len = 0;
int line_count = 0;
len_remain = in_len;
buffp = in_buff;
logprintf(LOG_HEXLBL, (char *)in_buff, in_len, "4610data");
while(len_remain > 0)
{
len_remain = parse4610Stream(//in_buff, in_len, buffp, cmd_len,
// &buffp, &cmd_len, &cmdI, &(tinf->CI));
in_buff, /* Pointer to stream (IN) */
in_len, /* Length of data in stream (IN) */
buffp, /* Pointer returned on last call */
/* (can be NULL if first call) (IN) */
cmd_len, /* Cmd len return on last call */
/* (0 if first call) (IN) */
&buffp, /* Return pointer - points to next */
/* command in the stream (OUT) */
&cmd_len, /* Return command len - len of next */
/* command (OUT) */
&cmdI, /* Pointer to structure containing */
/* additional info about the returned */
/* sub-command (OUT) */
&contI); /* Pointer to structure that keeps */
/* track of information about commands*/
/* that require continuation data. */
/* Structure should be set to all */
/* 0's at initialization */
/* so far (IN/OUT) */
if (len_remain < 0)
{
logprintf(LOG_DBG, "error detected in command, len_remain 0x%08X\n",
len_remain);
printf("error detected in command, len_remain 0x%08X\n",
len_remain);
break;
}
else
{
line_count += cmdI.line_cnt;
}
line_feeds = 0;
if (cmdI.cmd_type == PARS46_CMDTYPE_CMD)
{
if (cmdI.cmd_code == PARS46_CMDCODE_SET_STATION)
{
prt4610Station = buffp[3];
}
}
else if (cmdI.cmd_type == PARS46_CMDTYPE_CONT)
{
if ((buffp[0] == 0x0A) || (buffp[0] == 0x0D))
line_feeds = 1;
}
memset(printData, 0x00, sizeof(printData));
memcpy(printData, buffp, cmd_len);
switch(cmdI.cmd_code)
{
case PARS46_CMDCODE_DATA:
printf("prt4610Station(%d) command=%d x%04X cmd_len=%d PrintData[%s]\n",
prt4610Station,
cmdI.cmd_code,
cmdI.cmd_code,
cmd_len,
printData);
break;
default:
printf("prt4610Station(%d) command=%d x%04X cmd_len=%d (IGNORED)\n",
prt4610Station,
cmdI.cmd_code,
cmdI.cmd_code,
cmd_len);
break;
}
}
printf("app_line_count of 4610 packet %04x\n", line_count);
logprintf(LOG_DBG, "app_line_count of 4610 packet %04x\n", line_count);
LOG_ENDF();
} /* Process4610PrintPacket() */
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |