From d341ea723ec2efc2574f8558350fa56046d0b7fc Mon Sep 17 00:00:00 2001 From: Thies Lennart Alff Date: Thu, 20 Feb 2025 17:40:01 +0100 Subject: [PATCH] added missing static keywords and fixed message definition --- include/hydrolink/hydrolink_msg_get_response.h | 6 +++--- include/hydrolink/protocol.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hydrolink/hydrolink_msg_get_response.h b/include/hydrolink/hydrolink_msg_get_response.h index cbf97bc..261d188 100644 --- a/include/hydrolink/hydrolink_msg_get_response.h +++ b/include/hydrolink/hydrolink_msg_get_response.h @@ -1,8 +1,8 @@ #pragma once #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_3_LEN 6 +#define HYDROLINK_MSG_ID_5_LEN 6 #define HYDROLINK_MSG_ID_GET_RESPONSE_CRC_EXTRA 28 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->src_id = src_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_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 4, msg->result); hydrolink_put_uint8_t(HYDROLINK_PAYLOAD_NON_CONST(packet), 5, msg->cmd_id); diff --git a/include/hydrolink/protocol.h b/include/hydrolink/protocol.h index 40e57ef..e506bac 100644 --- a/include/hydrolink/protocol.h +++ b/include/hydrolink/protocol.h @@ -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_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[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[1] = src[2]; dst[2] = src[1]; 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[1] = src[6]; dst[2] = src[5]; @@ -87,9 +87,9 @@ HYDROLINK_MSG_RETURN_TYPE(int64_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); for (uint8_t j = 0; j < 8; j++) { 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; crc_xmodem_init(&crc); for (uint8_t i = 0; i < length; i++) {