added missing static keywords and fixed message definition
This commit is contained in:
parent
381963b988
commit
d341ea723e
2 changed files with 9 additions and 9 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#define HYDROLINK_MSG_ID_GET_RESPONSE 3
|
#define HYDROLINK_MSG_ID_GET_RESPONSE 5
|
||||||
#define HYDROLINK_MSG_ID_GET_RESPONSE_LEN 6
|
#define HYDROLINK_MSG_ID_GET_RESPONSE_LEN 6
|
||||||
#define HYDROLINK_MSG_ID_3_LEN 6
|
#define HYDROLINK_MSG_ID_5_LEN 6
|
||||||
#define HYDROLINK_MSG_ID_GET_RESPONSE_CRC_EXTRA 28
|
#define HYDROLINK_MSG_ID_GET_RESPONSE_CRC_EXTRA 28
|
||||||
|
|
||||||
typedef struct hydrolink_msg_get_response_t_s {
|
typedef struct hydrolink_msg_get_response_t_s {
|
||||||
|
|
@ -15,7 +15,7 @@ void hydrolink_get_response_msg_encode(uint8_t src_id, uint8_t dst_id, const hyd
|
||||||
packet->id = HYDROLINK_MSG_ID_GET_RESPONSE;
|
packet->id = HYDROLINK_MSG_ID_GET_RESPONSE;
|
||||||
packet->src_id = src_id;
|
packet->src_id = src_id;
|
||||||
packet->dst_id = dst_id;
|
packet->dst_id = dst_id;
|
||||||
packet->payload_length = HYDROLINK_MSG_ID_3_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
packet->payload_length = HYDROLINK_MSG_ID_5_LEN + HYDROLINK_NON_PAYLOAD_LEN;
|
||||||
hydrolink_put_int32_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 0, msg->value);
|
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), 4, msg->result);
|
||||||
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 5, msg->cmd_id);
|
hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 5, msg->cmd_id);
|
||||||
|
|
|
||||||
|
|
@ -38,19 +38,19 @@ struct hydrolink_msg_s {
|
||||||
#define hydrolink_put_int64_t(buf, wire_offset, b) byte_swap_8(&buf[wire_offset], (const char *)&b)
|
#define hydrolink_put_int64_t(buf, wire_offset, b) byte_swap_8(&buf[wire_offset], (const char *)&b)
|
||||||
#define hydrolink_put_uint64_t(buf, wire_offset, b) byte_swap_8(&buf[wire_offset], (const char *)&b)
|
#define hydrolink_put_uint64_t(buf, wire_offset, b) byte_swap_8(&buf[wire_offset], (const char *)&b)
|
||||||
|
|
||||||
inline void byte_swap_2(char *dst, const char *src) {
|
static inline void byte_swap_2(char *dst, const char *src) {
|
||||||
dst[0] = src[1];
|
dst[0] = src[1];
|
||||||
dst[1] = src[0];
|
dst[1] = src[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void byte_swap_4(char *dst, const char *src) {
|
static inline void byte_swap_4(char *dst, const char *src) {
|
||||||
dst[0] = src[3];
|
dst[0] = src[3];
|
||||||
dst[1] = src[2];
|
dst[1] = src[2];
|
||||||
dst[2] = src[1];
|
dst[2] = src[1];
|
||||||
dst[3] = src[0];
|
dst[3] = src[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void byte_swap_8(char *dst, const char *src) {
|
static inline void byte_swap_8(char *dst, const char *src) {
|
||||||
dst[0] = src[7];
|
dst[0] = src[7];
|
||||||
dst[1] = src[6];
|
dst[1] = src[6];
|
||||||
dst[2] = src[5];
|
dst[2] = src[5];
|
||||||
|
|
@ -87,9 +87,9 @@ HYDROLINK_MSG_RETURN_TYPE(int64_t, 8)
|
||||||
|
|
||||||
HYDROLINK_MSG_RETURN_TYPE(uint64_t, 8)
|
HYDROLINK_MSG_RETURN_TYPE(uint64_t, 8)
|
||||||
|
|
||||||
inline void crc_xmodem_init(uint16_t *crc) { *crc = 0; }
|
static inline void crc_xmodem_init(uint16_t *crc) { *crc = 0; }
|
||||||
|
|
||||||
inline void crc_xmodem_accumulate(uint8_t data, uint16_t *crc) {
|
static inline void crc_xmodem_accumulate(uint8_t data, uint16_t *crc) {
|
||||||
*crc = *crc ^ ((uint16_t)data << 8);
|
*crc = *crc ^ ((uint16_t)data << 8);
|
||||||
for (uint8_t j = 0; j < 8; j++) {
|
for (uint8_t j = 0; j < 8; j++) {
|
||||||
if (*crc & 0x8000) {
|
if (*crc & 0x8000) {
|
||||||
|
|
@ -100,7 +100,7 @@ inline void crc_xmodem_accumulate(uint8_t data, uint16_t *crc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t crc_xmodem_calculate(const uint8_t *data, uint8_t length) {
|
static inline uint16_t crc_xmodem_calculate(const uint8_t *data, uint8_t length) {
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
crc_xmodem_init(&crc);
|
crc_xmodem_init(&crc);
|
||||||
for (uint8_t i = 0; i < length; i++) {
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue