diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-05-26 19:17:33 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-05-26 19:17:33 +0200 |
commit | 266fd5ef0c45315fc0bf281a15630a9b4765e68c (patch) | |
tree | a34a86d72e25e3c858577feaff7f61c81b026c61 /shared | |
parent | e75c48a4d79a838844aab071c81b2879aab2b5ee (diff) |
implement SENS command0.2.0
Diffstat (limited to 'shared')
-rw-r--r-- | shared/bin.c | 5 | ||||
-rw-r--r-- | shared/bin.h | 9 | ||||
-rw-r--r-- | shared/protocol.c | 2 | ||||
-rw-r--r-- | shared/protocol.h | 7 | ||||
-rw-r--r-- | shared/serial_parse.c | 1 |
5 files changed, 19 insertions, 5 deletions
diff --git a/shared/bin.c b/shared/bin.c index 4b3dcc6..a0937e8 100644 --- a/shared/bin.c +++ b/shared/bin.c @@ -78,3 +78,8 @@ w2_s_bin *w2_bin_s_cat(w2_s_bin *a, w2_s_bin *b) { free(b); return c; } + +void w2_bin_repl_hton32(uint32_t *h32) { *h32 = w2_bin_hton32(*h32); } +void w2_bin_repl_hton16(uint16_t *h16) { *h16 = w2_bin_hton16(*h16); } +void w2_bin_repl_ntoh32(uint32_t *h32) { *h32 = w2_bin_ntoh32(*h32); } +void w2_bin_repl_ntoh16(uint16_t *h16) { *h16 = w2_bin_ntoh16(*h16); } diff --git a/shared/bin.h b/shared/bin.h index 2b65c95..af3a249 100644 --- a/shared/bin.h +++ b/shared/bin.h @@ -32,3 +32,12 @@ uint16_t w2_bin_hton16(uint16_t h16); uint32_t w2_bin_ntoh32(uint32_t n32); /** convert 16-bit value from network (big-endian) to host endian */ uint16_t w2_bin_ntoh16(uint16_t n16); + +/** replace 32-bit value from host endian to network (big-endian) */ +void w2_bin_repl_hton32(uint32_t *h32); +/** replace 16-bit value from host endian to network (big-endian) */ +void w2_bin_repl_hton16(uint16_t *h16); +/** replace 32-bit value from network (big-endian) to host endian */ +void w2_bin_repl_ntoh32(uint32_t *n32); +/** replace 16-bit value from network (big-endian) to host endian */ +void w2_bin_repl_ntoh16(uint16_t *n16); diff --git a/shared/protocol.c b/shared/protocol.c index 77ec466..fcc9fa4 100644 --- a/shared/protocol.c +++ b/shared/protocol.c @@ -1,5 +1,3 @@ -#include <stdbool.h> - #include "protocol.h" #ifdef W2_SIM #include "../robot/orangutan_shim.h" diff --git a/shared/protocol.h b/shared/protocol.h index b997ec6..7aa5e9f 100644 --- a/shared/protocol.h +++ b/shared/protocol.h @@ -1,12 +1,15 @@ #pragma once -#include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include "bin.h" #include "consts.h" +typedef uint8_t bool; +#define false 0 /* NOLINT */ +#define true 1 /* NOLINT */ + #define W2_SERIAL_START_BYTE 0xff #define W2_CMDDIR_RX 0 @@ -71,7 +74,7 @@ typedef struct { /** motor output struct */ typedef struct { - int speed; + int16_t speed; } w2_s_o_motor; /** underside led output struct */ diff --git a/shared/serial_parse.c b/shared/serial_parse.c index 89c5809..3bc8e3b 100644 --- a/shared/serial_parse.c +++ b/shared/serial_parse.c @@ -1,4 +1,3 @@ -#include <stdbool.h> #include <string.h> #include "consts.h" |