原子哥,您好!我按照您说的添加了关键字__attribute__ ((__packed__)),现在不会死机了,但是输出的数据只有第一个是对的,其余的都不知道是什么意思,请问这个是什么意思呢?
[C]
纯文本查看 复制代码
struct piledatansr { unsigned char bStaNum; unsigned char bDataType; unsigned char WN; unsigned char SOW; }__attribute__ ((__packed__));struct piledatansr piledatansr_1; struct piledatansr *pilepointer; pilepointer=&piledatansr_1; unsigned char msg[250]; piledatansr_1.bStaNum=0xAA; piledatansr_1.bDataType=0x01; piledatansr_1.WN=0x20; piledatansr_1.SOW=0x30; for(x=0;x<4;x++) { memcpy(msg,pilepointer+x,sizeof(piledatansr_1));//将结构体数据导入输出数组中 nmea_send_outmsg(msg, 1, CPU_USAGE_NMEA_MSG);//输出msg的1个字节 } if(x==4) pilepointer=&piledatansr_1;
这样通过串口调试助手看到的数据是AA 10 A5 55 不知道为什么呢?求原子哥指教!谢谢您!
原子哥,您好!我按照您说的添加了关键字__attribute__ ((__packed__)),现在不会死机了,但是输出的数据只有第一个是对的,其余的都不知道是什么意思,请问这个是什么意思呢?
[C] 纯文本查看 复制代码
struct piledatansr { unsigned char bStaNum; unsigned char bDataType; unsigned char WN; unsigned char SOW; }__attribute__ ((__packed__));struct piledatansr piledatansr_1; struct piledatansr *pilepointer; pilepointer=&piledatansr_1; unsigned char msg[250]; piledatansr_1.bStaNum=0xAA; piledatansr_1.bDataType=0x01; piledatansr_1.WN=0x20; piledatansr_1.SOW=0x30; for(x=0;x<4;x++) { memcpy(msg,pilepointer+x,sizeof(piledatansr_1));//将结构体数据导入输出数组中 nmea_send_outmsg(msg, 1, CPU_USAGE_NMEA_MSG);//输出msg的1个字节 } if(x==4) pilepointer=&piledatansr_1;
这样通过串口调试助手看到的数据是AA 10 A5 55 不知道为什么呢?求原子哥指教!谢谢您!
举报