diff --git a/protocol.c b/protocol.c index 5ccde65..8fc38eb 100644 --- a/protocol.c +++ b/protocol.c @@ -1347,7 +1347,7 @@ static void packMsgToHost(uint16_t funcCode, uint8_t isOK) { if(funcCode == HOST_CMD_STATUS_QUERY) { dlen = sizeof(DeviceStatus_t); index = sizeof(FRAME_TAIL)+2; - msgBuf[index] = 17; + msgBuf[index] = dlen;//#pragma pack(1)后大小正确 index += 1; //系统是小端序,将deviceStatus转换为大端序 memcpy(msgBuf+index, &deviceStatus.sensorStatus, 1); diff --git a/protocol.h b/protocol.h index 2f929b9..d7ee3d4 100644 --- a/protocol.h +++ b/protocol.h @@ -375,6 +375,8 @@ typedef enum { INIT_FAILED = 2 } InitStatus_t; +// 大小对齐至1字节 +#pragma pack(1) // 三通阀结构体 typedef struct { uint16_t angle[2]; // 阀门实时角度