diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-05-25 16:31:23 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-05-25 16:31:23 +0200 |
commit | afa10fa556585d965e3a7d46c2fd5436d29cf3c6 (patch) | |
tree | 358191a988d0d23449d6a0381d3c1016048424f4 | |
parent | 9cd83d662849fe72c83038a018107d9bbf5c2398 (diff) |
`make format`
-rw-r--r-- | robot/hypervisor.c | 3 | ||||
-rw-r--r-- | shared/bin.c | 6 | ||||
-rw-r--r-- | shared/protocol.c | 1 | ||||
-rw-r--r-- | shared/protocol.h | 34 | ||||
-rw-r--r-- | shared/serial_parse.c | 17 | ||||
-rw-r--r-- | shared/serial_parse.h | 1 |
6 files changed, 29 insertions, 33 deletions
diff --git a/robot/hypervisor.c b/robot/hypervisor.c index 0f754a3..c4e7aba 100644 --- a/robot/hypervisor.c +++ b/robot/hypervisor.c @@ -30,7 +30,8 @@ void w2_hypervisor_main() { if (DBG_ENABLE_CYCLEINFO) siminfo("cycle end\n"); if (!g_w2_sim_headless) usleep(100e3); - if (g_w2_sim_headless && DBG_MAX_CYCLES > -1 && g_w2_hypervisor_cycles > DBG_MAX_CYCLES) exit(0); + if (g_w2_sim_headless && DBG_MAX_CYCLES > -1 && g_w2_hypervisor_cycles > DBG_MAX_CYCLES) + exit(0); #endif g_w2_hypervisor_cycles++; diff --git a/shared/bin.c b/shared/bin.c index fc6e14b..44c2e94 100644 --- a/shared/bin.c +++ b/shared/bin.c @@ -1,5 +1,5 @@ -#include <stdlib.h> #include <memory.h> +#include <stdlib.h> #include "bin.h" @@ -65,8 +65,8 @@ uint32_t w2_bin_ntoh32(uint32_t n32) { return w2_bin_hton32(n32); } uint16_t w2_bin_ntoh16(uint16_t n16) { return w2_bin_hton16(n16); } w2_s_bin *w2_bin_s_alloc(uint16_t bytes, uint8_t *data) { - w2_s_bin* temp = malloc(sizeof(w2_s_bin) + sizeof(uint8_t) * bytes); - temp->bytes = bytes; + w2_s_bin *temp = malloc(sizeof(w2_s_bin) + sizeof(uint8_t) * bytes); + temp->bytes = bytes; memcpy(&temp->data, data, bytes); return temp; } diff --git a/shared/protocol.c b/shared/protocol.c index 2707725..c634a09 100644 --- a/shared/protocol.c +++ b/shared/protocol.c @@ -7,4 +7,3 @@ w2_s_cmd_ping_rx *w2_protocol_parse_cmd_ping_rx(w2_s_bin *data) { memcpy(parsed, data->data, data->bytes); return parsed; } - diff --git a/shared/protocol.h b/shared/protocol.h index b0602cf..775c2aa 100644 --- a/shared/protocol.h +++ b/shared/protocol.h @@ -1,8 +1,8 @@ #pragma once +#include <memory.h> #include <stdint.h> #include <stdlib.h> -#include <memory.h> #include "bin.h" @@ -53,7 +53,7 @@ enum w2_e_serial_commands { // generic struct (voor parsen) // parse functie // dump functie -// +// // // als het kan deze allemaal met macro's op deze manier definieren: // @@ -74,25 +74,24 @@ enum w2_e_serial_commands { #define W2_PROTOCOL_INT16_T #define W2_PROTOCOL_INT32_T -#define W2_PROTOCOL_UINT8_T_TYPE uint8_t -#define W2_PROTOCOL_UINT16_T_TYPE uint16_t -#define W2_PROTOCOL_UINT32_T_TYPE uint32_t -#define W2_PROTOCOL_INT8_T_TYPE int8_t -#define W2_PROTOCOL_INT16_T_TYPE int16_t -#define W2_PROTOCOL_INT32_T_TYPE int32_t +#define W2_PROTOCOL_UINT8_T_TYPE uint8_t +#define W2_PROTOCOL_UINT16_T_TYPE uint16_t +#define W2_PROTOCOL_UINT32_T_TYPE uint32_t +#define W2_PROTOCOL_INT8_T_TYPE int8_t +#define W2_PROTOCOL_INT16_T_TYPE int16_t +#define W2_PROTOCOL_INT32_T_TYPE int32_t -#define W2_PROTOCOL_UINT8_T_SIZE 1 +#define W2_PROTOCOL_UINT8_T_SIZE 1 #define W2_PROTOCOL_UINT16_T_SIZE 2 #define W2_PROTOCOL_UINT32_T_SIZE 4 -#define W2_PROTOCOL_INT8_T_SIZE 1 -#define W2_PROTOCOL_INT16_T_SIZE 2 -#define W2_PROTOCOL_INT32_T_SIZE 4 +#define W2_PROTOCOL_INT8_T_SIZE 1 +#define W2_PROTOCOL_INT16_T_SIZE 2 +#define W2_PROTOCOL_INT32_T_SIZE 4 -#define W2_PROTOCOL_CMD_PING_RX \ -W2_PROTOCOL_CMD(ping, W2_CMDDIR_RX, \ - W2_PROTOCOL_PROP(W2_PROTOCOL_UINT8_T, opcode) \ - W2_PROTOCOL_PROP(W2_PROTOCOL_UINT8_T, id) \ -) +#define W2_PROTOCOL_CMD_PING_RX \ + W2_PROTOCOL_CMD(ping, W2_CMDDIR_RX, \ + W2_PROTOCOL_PROP(W2_PROTOCOL_UINT8_T, opcode) \ + W2_PROTOCOL_PROP(W2_PROTOCOL_UINT8_T, id)) W2_PROTOCOL_DECLARE(W2_PROTOCOL_CMD_PING_RX) @@ -102,4 +101,3 @@ typedef struct { } w2_s_cmd_ping_rx; w2_s_cmd_ping_rx *w2_protocol_parse_cmd_ping_rx(w2_s_bin *data); - diff --git a/shared/serial_parse.c b/shared/serial_parse.c index c8a3fae..0cda2d8 100644 --- a/shared/serial_parse.c +++ b/shared/serial_parse.c @@ -1,27 +1,27 @@ #include <stdbool.h> +#include "bin.h" #include "consts.h" #include "serial_parse.h" -#include "bin.h" #ifdef W2_SIM #include "../robot/orangutan_shim.h" #endif void w2_serial_handle(w2_s_bin *code) { #ifdef W2_SIM - serial_send((char*)code->data, code->bytes); + serial_send((char *)code->data, code->bytes); // simprintf("yeah: %02x\n", code); #endif } void w2_serial_parse(uint8_t byte) { static uint8_t current_message[W2_SERIAL_READ_BUFFER_SIZE] = {0}; - static uint8_t current_message_index = 0; - static uint8_t complete_message_length = 2; + static uint8_t current_message_index = 0; + static uint8_t complete_message_length = 2; static bool attentive = false; static bool listening = false; - + if (byte == W2_SERIAL_START_BYTE) { attentive = !attentive; // if (attentive && listening) { @@ -44,11 +44,10 @@ void w2_serial_parse(uint8_t byte) { free(copy); memset(¤t_message, 0, W2_SERIAL_READ_BUFFER_SIZE); - current_message_index = 0; + current_message_index = 0; complete_message_length = 1; - attentive = false; - listening = false; + attentive = false; + listening = false; return; } } - diff --git a/shared/serial_parse.h b/shared/serial_parse.h index 516bf8a..a1c8fb9 100644 --- a/shared/serial_parse.h +++ b/shared/serial_parse.h @@ -6,4 +6,3 @@ /** parse serial data byte by byte */ void w2_serial_parse(uint8_t byte); - |