So I have the following parsing code that sends of a string in msgbuf comprised of binary information:
Code:
parse_binaryxyz(msgbuf,&xyz);
new_nav_posecef = TRUE;
(#1) printf("%x %x %x %x %x %d %d %d %d %x %d %d\n",xyz.header[0],xyz.header[1],xyz.msg_class,xyz.msg_id, xyz.len, xyz.ITOW, xyz.ECEF_X, xyz.ECEF_Y, xyz.ECEF_Z, xyz.Pacc, xyz.cs[0], xyz.cs[1]);
//Reset variables
gettingbinarymsg = FALSE;
msgbufindex = 0;
The msgbuf is sent here where the information is split up into its meanings by a predifined struct that is listed below the following code:
Code:
int parse_binaryxyz(unsigned char *msg, struct nav_posecef *xyz)
{
if ((msg[2] == 0x01) && (msg[3] == 0x01))
{//Parse the NAV_POSECEF message
//Cast the message into the nav_posecef structure
xyz = (struct nav_posecef*) msg;
(#2)printf("%x %x %x %x %x %d %d %d %d %x %d %d\n",xyz->header[0],xyz->header[1],xyz->msg_class,xyz->msg_id, xyz->len, xyz->ITOW, xyz->ECEF_X, xyz->ECEF_Y, xyz->ECEF_Z, xyz->Pacc, xyz->cs[0], xyz->cs[1]);
return 0;
}
}
So I have a struct that is of the form:
Code:
struct nav_posecef{
unsigned char header[2];
unsigned char msg_class;
unsigned char msg_id;
unsigned short len;
unsigned long ITOW;
long ECEF_X ;
long ECEF_Y ;
long ECEF_Z ;
unsigned long Pacc;
unsigned char cs[2];
}__attribute__((packed));
Alright here is my problem: You can see the two printf commands: The one labeled (#2) ,inside the actual parsing code, prints out the correct information. However, (#1) , where the information is returned does not. Why is it not passing the information back to the main program correctly.
The following is a what I see printing to the screen: (Note the first line is from the parser and correct and second is what is returned)
b5 62 1 1 14 333670999 42332163 -536164414 341727981 136 170 164
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
b5 62 1 1 14 333671999 42332165 -536164415 341727982 136 152 44
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
b5 62 1 1 14 333672999 42332169 -536164418 341727984 136 135 196
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
b5 62 1 1 14 333673999 42332174 -536164419 341727990 136 125 164
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
b5 62 1 1 14 333674999 42332178 -536164420 341727996 136 113 97
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
b5 62 1 1 14 333675999 42332181 -536164420 341728001 137 103 48
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0
b5 62 1 1 14 333676999 42332183 -536164421 341728005 137 88 208
0 0 0 0 0 -1312895732 234 0 1122304 2 4 0