fixed crc order
This commit is contained in:
parent
18f9ab4581
commit
0113eb9911
5 changed files with 15 additions and 20 deletions
|
|
@ -13,19 +13,18 @@ static inline void hydrolink_msg_ack_encode(uint8_t src_id, uint8_t dst_id, cons
|
|||
uint16_t crc;
|
||||
crc_xmodem_init(&crc);
|
||||
packet->id = HYDROLINK_MSG_ID_ACK;
|
||||
packet->payload_length = HYDROLINK_MSG_1_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
crc_xmodem_accumulate(packet->id, &crc);
|
||||
packet->dst_id = dst_id;
|
||||
crc_xmodem_accumulate(packet->dst_id, &crc);
|
||||
packet->src_id = src_id;
|
||||
crc_xmodem_accumulate(packet->src_id, &crc);
|
||||
packet->payload_length = HYDROLINK_MSG_1_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->ack);
|
||||
|
||||
for(int i = 0; i < packet->payload_length; ++i) {
|
||||
crc_xmodem_accumulate(packet->payload[i], &crc);
|
||||
}
|
||||
crc_xmodem_accumulate(HYDROLINK_MSG_ACK_CRC_EXTRA, &crc);
|
||||
crc_xmodem_acumulate(HYDROLINK_MSG_ACK_CRC_EXTRA, &crc);
|
||||
packet->crc = crc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,20 +14,19 @@ static inline void hydrolink_msg_get_cmd_encode(uint8_t src_id, uint8_t dst_id,
|
|||
uint16_t crc;
|
||||
crc_xmodem_init(&crc);
|
||||
packet->id = HYDROLINK_MSG_ID_GET_CMD;
|
||||
packet->payload_length = HYDROLINK_MSG_4_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
crc_xmodem_accumulate(packet->id, &crc);
|
||||
packet->dst_id = dst_id;
|
||||
crc_xmodem_accumulate(packet->dst_id, &crc);
|
||||
packet->src_id = src_id;
|
||||
crc_xmodem_accumulate(packet->src_id, &crc);
|
||||
packet->payload_length = HYDROLINK_MSG_4_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->index);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 1, msg->cmd_id);
|
||||
|
||||
for(int i = 0; i < packet->payload_length; ++i) {
|
||||
crc_xmodem_accumulate(packet->payload[i], &crc);
|
||||
}
|
||||
crc_xmodem_accumulate(HYDROLINK_MSG_GET_CMD_CRC_EXTRA, &crc);
|
||||
crc_xmodem_acumulate(HYDROLINK_MSG_GET_CMD_CRC_EXTRA, &crc);
|
||||
packet->crc = crc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,21 +15,20 @@ static inline void hydrolink_msg_get_response_encode(uint8_t src_id, uint8_t dst
|
|||
uint16_t crc;
|
||||
crc_xmodem_init(&crc);
|
||||
packet->id = HYDROLINK_MSG_ID_GET_RESPONSE;
|
||||
packet->payload_length = HYDROLINK_MSG_5_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
crc_xmodem_accumulate(packet->id, &crc);
|
||||
packet->dst_id = dst_id;
|
||||
crc_xmodem_accumulate(packet->dst_id, &crc);
|
||||
packet->src_id = src_id;
|
||||
crc_xmodem_accumulate(packet->src_id, &crc);
|
||||
packet->payload_length = HYDROLINK_MSG_5_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
hydrolink_put_int32_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->value);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 4, msg->result);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 5, msg->cmd_id);
|
||||
|
||||
for(int i = 0; i < packet->payload_length; ++i) {
|
||||
crc_xmodem_accumulate(packet->payload[i], &crc);
|
||||
}
|
||||
crc_xmodem_accumulate(HYDROLINK_MSG_GET_RESPONSE_CRC_EXTRA, &crc);
|
||||
crc_xmodem_acumulate(HYDROLINK_MSG_GET_RESPONSE_CRC_EXTRA, &crc);
|
||||
packet->crc = crc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,21 +15,20 @@ static inline void hydrolink_msg_set_cmd_encode(uint8_t src_id, uint8_t dst_id,
|
|||
uint16_t crc;
|
||||
crc_xmodem_init(&crc);
|
||||
packet->id = HYDROLINK_MSG_ID_SET_CMD;
|
||||
packet->payload_length = HYDROLINK_MSG_2_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
crc_xmodem_accumulate(packet->id, &crc);
|
||||
packet->dst_id = dst_id;
|
||||
crc_xmodem_accumulate(packet->dst_id, &crc);
|
||||
packet->src_id = src_id;
|
||||
crc_xmodem_accumulate(packet->src_id, &crc);
|
||||
packet->payload_length = HYDROLINK_MSG_2_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
hydrolink_put_int32_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->value);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 4, msg->index);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 5, msg->cmd_id);
|
||||
|
||||
for(int i = 0; i < packet->payload_length; ++i) {
|
||||
crc_xmodem_accumulate(packet->payload[i], &crc);
|
||||
}
|
||||
crc_xmodem_accumulate(HYDROLINK_MSG_SET_CMD_CRC_EXTRA, &crc);
|
||||
crc_xmodem_acumulate(HYDROLINK_MSG_SET_CMD_CRC_EXTRA, &crc);
|
||||
packet->crc = crc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,20 +14,19 @@ static inline void hydrolink_msg_set_response_encode(uint8_t src_id, uint8_t dst
|
|||
uint16_t crc;
|
||||
crc_xmodem_init(&crc);
|
||||
packet->id = HYDROLINK_MSG_ID_SET_RESPONSE;
|
||||
packet->payload_length = HYDROLINK_MSG_3_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
crc_xmodem_accumulate(packet->id, &crc);
|
||||
packet->dst_id = dst_id;
|
||||
crc_xmodem_accumulate(packet->dst_id, &crc);
|
||||
packet->src_id = src_id;
|
||||
crc_xmodem_accumulate(packet->src_id, &crc);
|
||||
packet->payload_length = HYDROLINK_MSG_3_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||
crc_xmodem_accumulate(packet->payload_length, &crc);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->result);
|
||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 1, msg->cmd_id);
|
||||
|
||||
for(int i = 0; i < packet->payload_length; ++i) {
|
||||
crc_xmodem_accumulate(packet->payload[i], &crc);
|
||||
}
|
||||
crc_xmodem_accumulate(HYDROLINK_MSG_SET_RESPONSE_CRC_EXTRA, &crc);
|
||||
crc_xmodem_acumulate(HYDROLINK_MSG_SET_RESPONSE_CRC_EXTRA, &crc);
|
||||
packet->crc = crc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue