添加1字节对齐,避免结构体大小错误
This commit is contained in:
parent
bb7ade7025
commit
f1ae618627
@ -1347,7 +1347,7 @@ static void packMsgToHost(uint16_t funcCode, uint8_t isOK) {
|
|||||||
if(funcCode == HOST_CMD_STATUS_QUERY) {
|
if(funcCode == HOST_CMD_STATUS_QUERY) {
|
||||||
dlen = sizeof(DeviceStatus_t);
|
dlen = sizeof(DeviceStatus_t);
|
||||||
index = sizeof(FRAME_TAIL)+2;
|
index = sizeof(FRAME_TAIL)+2;
|
||||||
msgBuf[index] = 17;
|
msgBuf[index] = dlen;//#pragma pack(1)后大小正确
|
||||||
index += 1;
|
index += 1;
|
||||||
//系统是小端序,将deviceStatus转换为大端序
|
//系统是小端序,将deviceStatus转换为大端序
|
||||||
memcpy(msgBuf+index, &deviceStatus.sensorStatus, 1);
|
memcpy(msgBuf+index, &deviceStatus.sensorStatus, 1);
|
||||||
|
@ -375,6 +375,8 @@ typedef enum {
|
|||||||
INIT_FAILED = 2
|
INIT_FAILED = 2
|
||||||
} InitStatus_t;
|
} InitStatus_t;
|
||||||
|
|
||||||
|
// 大小对齐至1字节
|
||||||
|
#pragma pack(1)
|
||||||
// 三通阀结构体
|
// 三通阀结构体
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t angle[2]; // 阀门实时角度
|
uint16_t angle[2]; // 阀门实时角度
|
||||||
|
Loading…
Reference in New Issue
Block a user