From 79969a7ee8b8e9ee35a50d37a0f6739cb9f19da0 Mon Sep 17 00:00:00 2001 From: Salem-Luos Date: Thu, 19 Nov 2020 17:18:52 +0100 Subject: [PATCH 01/12] Add Luos workflow build test for GitHub Action --- .github/workflows/build.yml | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..14894ef13 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,93 @@ +name: Build + +on: [push] + +jobs: + + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + + + steps: + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install platformio + + - name: Check out Luos repository + uses: actions/checkout@v2 +# - name: Setup tmate session +# uses: mxschmitt/action-tmate@v3 + - name: Create env repo + run: | + pwd + cd .. + git clone https://github.com/Luos-io/LuosHAL.git + git clone https://github.com/Luos-io/Examples.git + pwd + + - name: Run PlatformIO ubuntu or macos + if: matrix.os != 'windows-latest' + env: + PLATFORMIO_LIB_EXTRA_DIRS: ~/work/Luos + run: | + cd .. + platformio run -d Examples/Projects/Button + platformio run -d Examples/Projects/Controller_motor + platformio run -d Examples/Projects/Dc_motor + platformio run -d Examples/Projects/Distance + platformio run -d Examples/Projects/Dxl + platformio run -d Examples/Projects/Gate + platformio run -d Examples/Projects/Gpio + platformio run -d Examples/Projects/Imu + platformio run -d Examples/Projects/Led + platformio run -d Examples/Projects/Led_strip + platformio run -d Examples/Projects/Light_sensor + platformio run -d Examples/Projects/Load + platformio run -d Examples/Projects/Potentiometer + platformio run -d Examples/Projects/Power_switch + platformio run -d Examples/Projects/Servo + platformio run -d Examples/Projects/Stepper + platformio run -d Examples/Projects/Bike_alarm/Alarm_controller + platformio run -d Examples/Projects/Bike_alarm/Start_controller + + - name: Run PlatformIO windows + if: matrix.os == 'windows-latest' + env: + PLATFORMIO_LIB_EXTRA_DIRS: D:\a\Luos + run: | + cd .. + platformio run -d Examples/Projects/Button + platformio run -d Examples/Projects/Controller_motor + platformio run -d Examples/Projects/Dc_motor + platformio run -d Examples/Projects/Distance + platformio run -d Examples/Projects/Dxl + platformio run -d Examples/Projects/Gate + platformio run -d Examples/Projects/Gpio + platformio run -d Examples/Projects/Imu + platformio run -d Examples/Projects/Led + platformio run -d Examples/Projects/Led_strip + platformio run -d Examples/Projects/Light_sensor + platformio run -d Examples/Projects/Load + platformio run -d Examples/Projects/Potentiometer + platformio run -d Examples/Projects/Power_switch + platformio run -d Examples/Projects/Servo + platformio run -d Examples/Projects/Stepper + platformio run -d Examples/Projects/Bike_alarm/Alarm_controller + platformio run -d Examples/Projects/Bike_alarm/Start_controller + + + + + + From 706db9d749c3a706bc6b11d6fddfaca7bc4ead6a Mon Sep 17 00:00:00 2001 From: Salem-Luos Date: Mon, 23 Nov 2020 15:37:31 +0100 Subject: [PATCH 02/12] clean luos capital Luos_ReceiveData to fit with example --- Robus/src/portManager.c | 2 +- inc/luos.h | 1 + src/luos.c | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Robus/src/portManager.c b/Robus/src/portManager.c index e9e4f4d87..f5589f117 100644 --- a/Robus/src/portManager.c +++ b/Robus/src/portManager.c @@ -8,7 +8,7 @@ #include "portManager.h" #include "transmission.h" #include "context.h" -#include "LuosHAL.h" +#include "luosHAL.h" /******************************************************************************* * Definitions diff --git a/inc/luos.h b/inc/luos.h index 1ddc26a63..a088e5425 100644 --- a/inc/luos.h +++ b/inc/luos.h @@ -56,5 +56,6 @@ void Luos_SetBaudrate(uint32_t baudrate); void Luos_SendBaudrate(container_t *container, uint32_t baudrate); error_return_t Luos_SetExternId(container_t *container, target_mode_t target_mode, uint16_t target, uint16_t newid); uint16_t Luos_NbrAvailableMsg(void); +error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_data); #endif /* LUOS_H */ diff --git a/src/luos.c b/src/luos.c index 0d9c3db98..b61b39f93 100644 --- a/src/luos.c +++ b/src/luos.c @@ -9,7 +9,7 @@ #include #include "msgAlloc.h" #include "robus.h" -#include "LuosHAL.h" +#include "luosHAL.h" /******************************************************************************* * Definitions @@ -37,7 +37,6 @@ static error_return_t Luos_SaveAlias(container_t *container, uint8_t *alias); static void Luos_WriteAlias(uint16_t local_id, uint8_t *alias); static error_return_t Luos_ReadAlias(uint16_t local_id, uint8_t *alias); static error_return_t Luos_IsALuosCmd(uint8_t cmd, uint16_t size); -static error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_data); /****************************************************************************** * @brief Luos init must be call in project init @@ -633,7 +632,7 @@ error_return_t Luos_SendData(container_t *container, msg_t *msg, void *bin_data, * @param pointer to data * @return error ******************************************************************************/ -static error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_data) +error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_data) { // Manage buffer session (one per container) static uint32_t data_size[MAX_CONTAINER_NUMBER] = {0}; From 87f081cbb8e9cf5f1afd272e031209b03167a8d6 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Mon, 23 Nov 2020 18:26:43 +0100 Subject: [PATCH 03/12] Check if there is branch related (same name) to this one on LuosHAL and Examples --- .github/workflows/build.yml | 67 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14894ef13..ff4c2a102 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,13 @@ jobs: strategy: matrix: os: [macos-latest, windows-latest, ubuntu-latest] + include: + - os: windows-latest + pio_lib_path: D:\a\Luos + - os: macos-latest + pio_lib_path: ~/work/Luos + - os: ubuntu-latest + pio_lib_path: ~/work/Luos steps: @@ -28,43 +35,39 @@ jobs: uses: actions/checkout@v2 # - name: Setup tmate session # uses: mxschmitt/action-tmate@v3 + - name: Create env repo + shell: bash run: | - pwd + # Save branch name + branch_name=$(git branch --show-current) + origine_branch_name="origin/${branch_name}" + # Step back and get dependancies cd .. + + # LuosHAL git clone https://github.com/Luos-io/LuosHAL.git - git clone https://github.com/Luos-io/Examples.git - pwd + cd LuosHAL + if [ `git branch -r --list $origine_branch_name` ] + then + echo A dependant branch have been found on LuosHAL + git checkout $branch_name + fi + cd .. - - name: Run PlatformIO ubuntu or macos - if: matrix.os != 'windows-latest' - env: - PLATFORMIO_LIB_EXTRA_DIRS: ~/work/Luos - run: | + # Examples + git clone https://github.com/Luos-io/Examples.git + cd Examples + if [ `git branch -r --list $origine_branch_name` ] + then + echo A dependant branch have been found on Examples + git checkout $branch_name + fi cd .. - platformio run -d Examples/Projects/Button - platformio run -d Examples/Projects/Controller_motor - platformio run -d Examples/Projects/Dc_motor - platformio run -d Examples/Projects/Distance - platformio run -d Examples/Projects/Dxl - platformio run -d Examples/Projects/Gate - platformio run -d Examples/Projects/Gpio - platformio run -d Examples/Projects/Imu - platformio run -d Examples/Projects/Led - platformio run -d Examples/Projects/Led_strip - platformio run -d Examples/Projects/Light_sensor - platformio run -d Examples/Projects/Load - platformio run -d Examples/Projects/Potentiometer - platformio run -d Examples/Projects/Power_switch - platformio run -d Examples/Projects/Servo - platformio run -d Examples/Projects/Stepper - platformio run -d Examples/Projects/Bike_alarm/Alarm_controller - platformio run -d Examples/Projects/Bike_alarm/Start_controller - - name: Run PlatformIO windows - if: matrix.os == 'windows-latest' + - name: Run PlatformIO env: - PLATFORMIO_LIB_EXTRA_DIRS: D:\a\Luos + PLATFORMIO_LIB_EXTRA_DIRS: ${{ matrix.pio_lib_path }} run: | cd .. platformio run -d Examples/Projects/Button @@ -85,9 +88,3 @@ jobs: platformio run -d Examples/Projects/Stepper platformio run -d Examples/Projects/Bike_alarm/Alarm_controller platformio run -d Examples/Projects/Bike_alarm/Start_controller - - - - - - From c545d79a2bb445eab2eba37e735b22fca4982ca5 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Tue, 24 Nov 2020 12:18:20 +0100 Subject: [PATCH 04/12] fix some typos and remove useless code --- Robus/inc/msgAlloc.h | 2 +- Robus/src/msgAlloc.c | 57 ++++++++++++++++++----------------------- inc/container_structs.h | 34 ------------------------ inc/luos_list.h | 2 -- inc/routingTable.h | 4 +-- src/routingTable.c | 5 +--- 6 files changed, 28 insertions(+), 76 deletions(-) diff --git a/Robus/inc/msgAlloc.h b/Robus/inc/msgAlloc.h index 14f19b3a3..036fa6a77 100644 --- a/Robus/inc/msgAlloc.h +++ b/Robus/inc/msgAlloc.h @@ -23,7 +23,7 @@ void MsgAlloc_Init(memory_stats_t *memory_stats); void MsgAlloc_loop(void); // msg buffering functions -void MsgAlloc_ValidHeader(uint8_t status, uint16_t data_size); +void MsgAlloc_ValidHeader(uint8_t valid, uint16_t data_size); void MsgAlloc_InvalidMsg(void); void MsgAlloc_EndMsg(void); void MsgAlloc_SetData(uint8_t data); diff --git a/Robus/src/msgAlloc.c b/Robus/src/msgAlloc.c index c7d7307d0..6ed4c940a 100644 --- a/Robus/src/msgAlloc.c +++ b/Robus/src/msgAlloc.c @@ -60,8 +60,8 @@ ******************************************************************************/ typedef struct __attribute__((__packed__)) { - msg_t *msg_pt; /*!< Start pointer of the msg on msg_buffer. */ - ll_container_t *ll_container_pt; /*!< Pointer to the concerned ll_container. */ + msg_t *msg_pt; /*!< Start pointer of the msg on msg_buffer. */ + ll_container_t *ll_container_pt; /*!< Pointer to the concerned ll_container. */ } luos_task_t; /******************************************************************************* * Variables @@ -74,7 +74,7 @@ volatile msg_t *current_msg; /*!< current work in progress msg volatile uint8_t *data_ptr; /*!< Pointer to the next data able to be writen into msgbuffer. */ // Allocator task stack -volatile header_t *copy_task_pointer = NULL; /*!< This pointer is used to perform a header copy from the end of the msg_buffer to the begin of the msg_buffer. If this pointer if different than NULL there is a copy to make. */ +volatile header_t *copy_task_pointer = NULL; /*!< This pointer is used to perform a header copy from the end of the msg_buffer to the begin of the msg_buffer. If this pointer if different than NULL there is a copy to make. */ // msg interpretation task stack volatile msg_t *msg_tasks[MAX_MSG_NB]; /*!< ready message table. */ @@ -180,29 +180,22 @@ void MsgAlloc_InvalidMsg(void) //clean the memory zone MsgAlloc_ClearMsgSpace((void *)current_msg, (void *)(data_ptr)); data_ptr = (uint8_t *)current_msg; - if(current_msg == (volatile msg_t *)&msg_buffer[0]) + if (current_msg == (volatile msg_t *)&msg_buffer[0]) { copy_task_pointer = NULL; } } /****************************************************************************** * @brief Valid the current message header by preparing the allocator to get the message data - * @param concerned_module : The module concerned by this message + * @param valid : is the header valid or not + * @param data_size : size of the data to receive * @return None ******************************************************************************/ -void MsgAlloc_ValidHeader(uint8_t status, uint16_t data_size) +void MsgAlloc_ValidHeader(uint8_t valid, uint16_t data_size) { -//******** Prepare the allocator to get data ********* -// Save the concerned module pointer into the concerned module pointer stack -#ifdef DEBUG - if (module_concerned_stack_pointer >= MAX_CONTAINER_NUMBER) - { - while (1) - ; - } -#endif - - if(status == true) + //******** Prepare the allocator to get data ********* + // Save the concerned module pointer into the concerned module pointer stack + if (valid == true) { if (MsgAlloc_DoWeHaveSpace((void *)(¤t_msg->data[data_size + 2])) == FAIL) { @@ -215,14 +208,14 @@ void MsgAlloc_ValidHeader(uint8_t status, uint16_t data_size) data_ptr = &msg_buffer[sizeof(header_t)]; } // check if there is a msg traitement pending - if(((uint32_t)used_msg >= (uint32_t)current_msg) && ((uint32_t)used_msg<= (uint32_t)(¤t_msg->data[data_size + 2]))) + if (((uint32_t)used_msg >= (uint32_t)current_msg) && ((uint32_t)used_msg <= (uint32_t)(¤t_msg->data[data_size + 2]))) { - used_msg = NULL; - // This message is in the space we want to use, clear the task - if (mem_stat->msg_drop_number < 0xFF) - { - mem_stat->msg_drop_number++; - } + used_msg = NULL; + // This message is in the space we want to use, clear the task + if (mem_stat->msg_drop_number < 0xFF) + { + mem_stat->msg_drop_number++; + } } } else @@ -232,8 +225,6 @@ void MsgAlloc_ValidHeader(uint8_t status, uint16_t data_size) } /****************************************************************************** * @brief Finish the current message - * @param module_concerned_by_current_msg list of concerned modules - * @param module_concerned_stack_pointer Number of module concerned * @return None ******************************************************************************/ void MsgAlloc_EndMsg(void) @@ -265,7 +256,7 @@ void MsgAlloc_EndMsg(void) } else { - if(*data_ptr % 2 != 1) + if (*data_ptr % 2 != 1) { data_ptr++; } @@ -348,7 +339,7 @@ msg_t *MsgAlloc_GetCurrentMsg(void) ******************************************************************************/ error_return_t MsgAlloc_IsEmpty(void) { - if(data_ptr == &msg_buffer[0]) + if (data_ptr == &msg_buffer[0]) { return SUCESS; } @@ -379,7 +370,7 @@ static inline error_return_t MsgAlloc_ClearMsgSpace(void *from, void *to) //******** Prepare a memory space to be writable ********** // check if there is a msg traitement pending - if(((uint32_t)used_msg >= (uint32_t)from) && ((uint32_t)used_msg<= (uint32_t)to)) + if (((uint32_t)used_msg >= (uint32_t)from) && ((uint32_t)used_msg <= (uint32_t)to)) { used_msg = NULL; // This message is in the space we want to use, clear the task @@ -423,7 +414,8 @@ static inline void MsgAlloc_ClearMsgTask(void) { if (msg_tasks_stack_id > MAX_MSG_NB) { - while(1); + while (1) + ; } for (uint16_t rm = 0; rm < msg_tasks_stack_id; rm++) { @@ -474,9 +466,10 @@ void MsgAlloc_UsedMsgEnd(void) ******************************************************************************/ static inline void MsgAlloc_ClearLuosTask(uint16_t luos_task_id) { - if((luos_task_id > luos_tasks_stack_id)||(luos_tasks_stack_id > MAX_MSG_NB)) + if ((luos_task_id > luos_tasks_stack_id) || (luos_tasks_stack_id > MAX_MSG_NB)) { - while(1); + while (1) + ; } for (uint16_t rm = luos_task_id; rm < luos_tasks_stack_id; rm++) { diff --git a/inc/container_structs.h b/inc/container_structs.h index 4c2384e6d..264aa33cd 100644 --- a/inc/container_structs.h +++ b/inc/container_structs.h @@ -63,40 +63,6 @@ typedef struct __attribute__((__packed__)) }; } luos_uuid_t; -/* - * Pid - */ -typedef struct __attribute__((__packed__)) -{ - union - { - struct __attribute__((__packed__)) - { - float p; - float i; - float d; - }; - unsigned char unmap[3 * sizeof(float)]; - }; -} asserv_pid_t; - -/* - * Servo - */ -typedef struct -{ - union - { - struct __attribute__((__packed__)) - { - angular_position_t max_angle; - float min_pulse_time; - float max_pulse_time; - }; - unsigned char unmap[3 * sizeof(float)]; - }; -} servo_parameters_t; - /* * controle */ diff --git a/inc/luos_list.h b/inc/luos_list.h index 6d531ed0b..bc1190afb 100644 --- a/inc/luos_list.h +++ b/inc/luos_list.h @@ -24,8 +24,6 @@ typedef enum DYNAMIXEL_MOD, STEPPER_MOD, DCMOTOR_MOD, - Compatibility_line, - HANDY_MOD, IMU_MOD, LIGHT_MOD, CONTROLLER_MOTOR_MOD, diff --git a/inc/routingTable.h b/inc/routingTable.h index 1cc2e3327..db16dd97d 100644 --- a/inc/routingTable.h +++ b/inc/routingTable.h @@ -75,13 +75,11 @@ void RoutingTB_ComputeRoutingTableEntryNB(void); void RoutingTB_DetectContainers(container_t *container); void RoutingTB_ConvertNodeToRoutingTable(routing_table_t *entry, node_t *node); void RoutingTB_ConvertContainerToRoutingTable(routing_table_t *entry, container_t *container); -// void RoutingTB_InsertOnRoutingTable(routing_table_t *entry); -void RoutingTB_RemoveOnRoutingTable(int id); +void RoutingTB_RemoveOnRoutingTable(uint16_t id); void RoutingTB_Erase(void); routing_table_t *RoutingTB_Get(void); uint16_t RoutingTB_GetLastContainer(void); uint16_t *RoutingTB_GetLastNode(void); uint16_t RoutingTB_GetLastEntry(void); -void RoutingTB_BootstrapNextNodes(container_t *container); #endif /* TABLE */ diff --git a/src/routingTable.c b/src/routingTable.c index c8da14f3b..bac96dae1 100644 --- a/src/routingTable.c +++ b/src/routingTable.c @@ -175,9 +175,6 @@ char *RoutingTB_StringFromType(luos_type_t type) return "DCMotor"; break; break; - case HANDY_MOD: - return "Handy"; - break; case IMU_MOD: return "Imu"; break; @@ -503,7 +500,7 @@ void RoutingTB_ConvertContainerToRoutingTable(routing_table_t *entry, container_ * @param index of container * @return None ******************************************************************************/ -void RoutingTB_RemoveOnRoutingTable(int index) +void RoutingTB_RemoveOnRoutingTable(uint16_t index) { routing_table[index].alias[0] = '\0'; routing_table[index].type = VOID_MOD; From 999bca5daf3d008fa24a4236b841a2f326f6f131 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Tue, 24 Nov 2020 12:22:58 +0100 Subject: [PATCH 05/12] Add ASSERT command ready to be used --- Robus/inc/robus_struct.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Robus/inc/robus_struct.h b/Robus/inc/robus_struct.h index a5f588907..26948f4ca 100644 --- a/Robus/inc/robus_struct.h +++ b/Robus/inc/robus_struct.h @@ -129,6 +129,7 @@ typedef enum WRITE_NODE_ID, /*!< Get and save a new given node ID. */ RESET_DETECTION, /*!< Reset detection*/ SET_BAUDRATE, /*!< Set Robus baudrate*/ + ASSERT, /*!< Node Assert message (only broadcast with a source as a node */ ROBUS_PROTOCOL_NB, } robus_cmd_t; From eceb95fdfca459b19e4c33eb7a30237a4cb9c097 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Tue, 24 Nov 2020 12:31:39 +0100 Subject: [PATCH 06/12] rename files following our convention --- Robus/inc/context.h | 2 +- Robus/inc/{msgAlloc.h => msg_alloc.h} | 0 Robus/inc/{portManager.h => port_manager.h} | 0 Robus/src/{msgAlloc.c => msg_alloc.c} | 4 ++-- Robus/src/{portManager.c => port_manager.c} | 4 ++-- Robus/src/reception.c | 4 ++-- Robus/src/robus.c | 6 +++--- Robus/src/transmission.c | 2 +- inc/luos.h | 2 +- inc/{routingTable.h => routing_table.h} | 0 src/luos.c | 4 ++-- src/{routingTable.c => routing_table.c} | 4 ++-- 12 files changed, 16 insertions(+), 16 deletions(-) rename Robus/inc/{msgAlloc.h => msg_alloc.h} (100%) rename Robus/inc/{portManager.h => port_manager.h} (100%) rename Robus/src/{msgAlloc.c => msg_alloc.c} (99%) rename Robus/src/{portManager.c => port_manager.c} (98%) rename inc/{routingTable.h => routing_table.h} (100%) rename src/{routingTable.c => routing_table.c} (99%) diff --git a/Robus/inc/context.h b/Robus/inc/context.h index 1beb5979e..b867a1caf 100644 --- a/Robus/inc/context.h +++ b/Robus/inc/context.h @@ -9,7 +9,7 @@ #include #include "config.h" -#include "portManager.h" +#include "port_manager.h" #include "reception.h" #include "transmission.h" /******************************************************************************* diff --git a/Robus/inc/msgAlloc.h b/Robus/inc/msg_alloc.h similarity index 100% rename from Robus/inc/msgAlloc.h rename to Robus/inc/msg_alloc.h diff --git a/Robus/inc/portManager.h b/Robus/inc/port_manager.h similarity index 100% rename from Robus/inc/portManager.h rename to Robus/inc/port_manager.h diff --git a/Robus/src/msgAlloc.c b/Robus/src/msg_alloc.c similarity index 99% rename from Robus/src/msgAlloc.c rename to Robus/src/msg_alloc.c index 6ed4c940a..0713b9c48 100644 --- a/Robus/src/msgAlloc.c +++ b/Robus/src/msg_alloc.c @@ -44,8 +44,8 @@ #include #include #include "config.h" -#include "msgAlloc.h" -#include "luosHAL.h" +#include "msg_alloc.h" +#include "luos_hal.h" /******************************************************************************* * Definitions diff --git a/Robus/src/portManager.c b/Robus/src/port_manager.c similarity index 98% rename from Robus/src/portManager.c rename to Robus/src/port_manager.c index f5589f117..5ed2f0b21 100644 --- a/Robus/src/portManager.c +++ b/Robus/src/port_manager.c @@ -5,10 +5,10 @@ * @version 0.0.0 ******************************************************************************/ #include -#include "portManager.h" +#include "port_manager.h" #include "transmission.h" #include "context.h" -#include "luosHAL.h" +#include "luos_hal.h" /******************************************************************************* * Definitions diff --git a/Robus/src/reception.c b/Robus/src/reception.c index 662e6acce..a52595f2b 100644 --- a/Robus/src/reception.c +++ b/Robus/src/reception.c @@ -8,10 +8,10 @@ #include #include -#include "luosHAL.h" +#include "luos_hal.h" #include "target.h" #include "transmission.h" -#include "msgAlloc.h" +#include "msg_alloc.h" /******************************************************************************* * Definitions diff --git a/Robus/src/robus.c b/Robus/src/robus.c index 55237dd9e..71197ae68 100644 --- a/Robus/src/robus.c +++ b/Robus/src/robus.c @@ -10,10 +10,10 @@ #include #include "transmission.h" #include "reception.h" -#include "portManager.h" +#include "port_manager.h" #include "context.h" -#include "luosHAL.h" -#include "msgAlloc.h" +#include "luos_hal.h" +#include "msg_alloc.h" /******************************************************************************* * Definitions diff --git a/Robus/src/transmission.c b/Robus/src/transmission.c index 679d6de5b..8c867ab5a 100644 --- a/Robus/src/transmission.c +++ b/Robus/src/transmission.c @@ -6,7 +6,7 @@ ******************************************************************************/ #include -#include "luosHAL.h" +#include "luos_hal.h" #include #include #include "context.h" diff --git a/inc/luos.h b/inc/luos.h index a088e5425..f54fba3bb 100644 --- a/inc/luos.h +++ b/inc/luos.h @@ -9,7 +9,7 @@ #include "luos_list.h" #include "container_structs.h" -#include "routingTable.h" +#include "routing_table.h" #include "luos_od.h" #include "streaming.h" diff --git a/inc/routingTable.h b/inc/routing_table.h similarity index 100% rename from inc/routingTable.h rename to inc/routing_table.h diff --git a/src/luos.c b/src/luos.c index b61b39f93..69be0afb3 100644 --- a/src/luos.c +++ b/src/luos.c @@ -7,9 +7,9 @@ #include "luos.h" #include #include -#include "msgAlloc.h" +#include "msg_alloc.h" #include "robus.h" -#include "luosHAL.h" +#include "luos_hal.h" /******************************************************************************* * Definitions diff --git a/src/routingTable.c b/src/routing_table.c similarity index 99% rename from src/routingTable.c rename to src/routing_table.c index bac96dae1..8c347acf0 100644 --- a/src/routingTable.c +++ b/src/routing_table.c @@ -4,12 +4,12 @@ * @author Luos * @version 0.0.0 ******************************************************************************/ -#include +#include #include #include #include -#include "luosHAL.h" +#include "luos_hal.h" #include "context.h" /******************************************************************************* From 7c6f5edbd04dc8d3782c2dea42e4b8e0ee63d8c9 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Tue, 24 Nov 2020 14:15:14 +0100 Subject: [PATCH 07/12] lint files --- Robus/inc/context.h | 14 +++++++------- Robus/inc/port_manager.h | 7 +++---- Robus/inc/reception.h | 3 +-- Robus/inc/robus_struct.h | 2 +- Robus/inc/transmission.h | 5 ++--- Robus/src/reception.c | 10 +++++----- Robus/src/robus.c | 15 +++++++++------ inc/container_structs.h | 2 +- inc/streaming.h | 3 +-- src/luos.c | 12 ++++++------ 10 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Robus/inc/context.h b/Robus/inc/context.h index b867a1caf..942a2b436 100644 --- a/Robus/inc/context.h +++ b/Robus/inc/context.h @@ -19,15 +19,15 @@ typedef struct { // Variables - node_t node; /*!< Node informations. */ - RxCom_t rx; /*!< Receiver informations. */ - TxCom_t tx; /*!< Transmitter informations. */ - uint8_t ack; /*!< Ack informations. */ - PortMng_t port; /*!< port informations. */ + node_t node; /*!< Node informations. */ + RxCom_t rx; /*!< Receiver informations. */ + TxCom_t tx; /*!< Transmitter informations. */ + uint8_t ack; /*!< Ack informations. */ + PortMng_t port; /*!< port informations. */ //Virtual container management - ll_container_t ll_container_table[MAX_CONTAINER_NUMBER]; /*!< Virtual Container table. */ - uint16_t ll_container_number; /*!< Virtual Container number. */ + ll_container_t ll_container_table[MAX_CONTAINER_NUMBER]; /*!< Virtual Container table. */ + uint16_t ll_container_number; /*!< Virtual Container number. */ } context_t; diff --git a/Robus/inc/port_manager.h b/Robus/inc/port_manager.h index b708dd64b..0361db544 100644 --- a/Robus/inc/port_manager.h +++ b/Robus/inc/port_manager.h @@ -20,10 +20,9 @@ typedef struct { //Port manager - volatile uint8_t activ; //last Port where thereis activity - volatile uint8_t keepLine; //status of the line poked by your node -} -PortMng_t; + volatile uint8_t activ; //last Port where thereis activity + volatile uint8_t keepLine; //status of the line poked by your node +} PortMng_t; /******************************************************************************* * Function ******************************************************************************/ diff --git a/Robus/inc/reception.h b/Robus/inc/reception.h index 2814872f4..829b4632c 100644 --- a/Robus/inc/reception.h +++ b/Robus/inc/reception.h @@ -32,8 +32,7 @@ typedef struct { DATA_CB callback; status_t status; -} -RxCom_t; +} RxCom_t; /******************************************************************************* * Variables ******************************************************************************/ diff --git a/Robus/inc/robus_struct.h b/Robus/inc/robus_struct.h index 26948f4ca..253e2276f 100644 --- a/Robus/inc/robus_struct.h +++ b/Robus/inc/robus_struct.h @@ -69,7 +69,7 @@ typedef struct __attribute__((__packed__)) { struct __attribute__((__packed__)) { - header_t header; /*!< Header filed. */ + header_t header; /*!< Header filed. */ uint8_t data[MAX_DATA_MSG_SIZE]; /*!< Data with size known. */ }; uint8_t stream[sizeof(header_t) + MAX_DATA_MSG_SIZE]; /*!< unmaped option. */ diff --git a/Robus/inc/transmission.h b/Robus/inc/transmission.h index 1dcd718e9..685883d43 100644 --- a/Robus/inc/transmission.h +++ b/Robus/inc/transmission.h @@ -13,11 +13,10 @@ ******************************************************************************/ typedef struct { - uint8_t* data; + uint8_t *data; volatile uint8_t lock; volatile uint8_t collision; -} -TxCom_t; +} TxCom_t; /******************************************************************************* * Variables ******************************************************************************/ diff --git a/Robus/src/reception.c b/Robus/src/reception.c index a52595f2b..39e94d2a5 100644 --- a/Robus/src/reception.c +++ b/Robus/src/reception.c @@ -92,9 +92,9 @@ void Recep_GetHeader(volatile unsigned char *data) data_size = current_msg->header.size; } - if ((keep)&&(ctx.rx.status.rx_framing_error == false)) + if ((keep) && (ctx.rx.status.rx_framing_error == false)) { - if(data_size) + if (data_size) { MsgAlloc_ValidHeader(true, data_size); } @@ -143,9 +143,9 @@ void Recep_GetData(volatile unsigned char *data) // Make an exception for reset detection command if (current_msg->header.cmd == RESET_DETECTION) { - ctx.node.node_id = 0; - PortMng_Init(); - MsgAlloc_Init(NULL); + ctx.node.node_id = 0; + PortMng_Init(); + MsgAlloc_Init(NULL); } else { diff --git a/Robus/src/robus.c b/Robus/src/robus.c index 71197ae68..74615ef63 100644 --- a/Robus/src/robus.c +++ b/Robus/src/robus.c @@ -287,7 +287,9 @@ uint16_t Robus_TopologyDetection(ll_container_t *ll_container) static error_return_t Robus_ResetNetworkDetection(ll_container_t *ll_container) { msg_t msg; - uint8_t try = 0; + uint8_t + try + = 0; msg.header.target = BROADCAST_VAL; msg.header.target_mode = BROADCAST; @@ -302,14 +304,15 @@ static error_return_t Robus_ResetNetworkDetection(ll_container_t *ll_container) // wait for some 2ms to be sure all previous messages are received and treated uint32_t start_tick = LuosHAL_GetSystick(); - while (LuosHAL_GetSystick() - start_tick < 2); - try++; - } - while((MsgAlloc_IsEmpty() != SUCESS)||(try > 5)); + while (LuosHAL_GetSystick() - start_tick < 2) + ; + try + ++; + } while ((MsgAlloc_IsEmpty() != SUCESS) || (try > 5)); ctx.node.node_id = 0; PortMng_Init(); - if(try < 5) + if (try < 5) { return SUCESS; } diff --git a/inc/container_structs.h b/inc/container_structs.h index 264aa33cd..9cf71cd63 100644 --- a/inc/container_structs.h +++ b/inc/container_structs.h @@ -35,7 +35,7 @@ typedef struct __attribute__((__packed__)) container_t // Variables uint8_t default_alias[MAX_ALIAS_SIZE]; /*!< container default alias. */ uint8_t alias[MAX_ALIAS_SIZE]; /*!< container alias. */ - timed_update_t auto_refresh; /*!< container auto refresh context. */ + timed_update_t auto_refresh; /*!< container auto refresh context. */ uint8_t firm_version[20]; /*!< container firmware version. */ } container_t; diff --git a/inc/streaming.h b/inc/streaming.h index 912a28f47..adac54cc6 100644 --- a/inc/streaming.h +++ b/inc/streaming.h @@ -26,7 +26,7 @@ typedef struct void *end_ring_buffer; // End of the ring buffer void *sample_ptr; // Current sample pointer (pointer always point a fresh data) void *data_ptr; // Current pointer of data - uint8_t data_size; // Size granulariry of the data contained on the ring buffer + uint8_t data_size; // Size granulariry of the data contained on the ring buffer } streaming_channel_t; /******************************************************************************* * Variables @@ -41,5 +41,4 @@ uint8_t Stream_PutSample(streaming_channel_t *stream, const void *data, uint16_t uint8_t Stream_GetSample(streaming_channel_t *stream, void *data, uint16_t size); uint8_t Stream_GetAvailableSampleNB(streaming_channel_t *stream); - #endif /* LUOS_H */ diff --git a/src/luos.c b/src/luos.c index 69be0afb3..e931f6937 100644 --- a/src/luos.c +++ b/src/luos.c @@ -93,7 +93,7 @@ void Luos_Loop(void) if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCESS) { // be sure the content of this message need to be managed by Luos and do it if it is. - if (Luos_MsgHandler((container_t *)container, returned_msg)==FAIL) + if (Luos_MsgHandler((container_t *)container, returned_msg) == FAIL) { // we should not go there there is a mistake on Luos_IsALuosCmd or Luos_MsgHandler while (1) @@ -524,7 +524,7 @@ error_return_t Luos_ReadMsg(container_t *container, msg_t **returned_msg) { error = MsgAlloc_PullMsg(container->ll_container, returned_msg); // check if the content of this message need to be managed by Luos and do it if it is. - if ((Luos_MsgHandler(container, *returned_msg)==FAIL) & (error == SUCESS)) + if ((Luos_MsgHandler(container, *returned_msg) == FAIL) & (error == SUCESS)) { // This message is for the user, pass it to the user. return SUCESS; @@ -557,7 +557,7 @@ error_return_t Luos_ReadFromContainer(container_t *container, short id, msg_t ** // Source id of this message match, get it and treat it. error = MsgAlloc_PullMsg(container->ll_container, returned_msg); // check if the content of this message need to be managed by Luos and do it if it is. - if ((Luos_MsgHandler(container, *returned_msg)==FAIL) & (error == SUCESS)) + if ((Luos_MsgHandler(container, *returned_msg) == FAIL) & (error == SUCESS)) { // This message is for the user, pass it to the user. return SUCESS; @@ -639,7 +639,7 @@ error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_da static uint16_t last_msg_size = 0; uint16_t id = Luos_GetContainerIndex(container); // check good container index - if(id == 0xFFFF) + if (id == 0xFFFF) { return FAIL; } @@ -780,7 +780,7 @@ static error_return_t Luos_SaveAlias(container_t *container, uint8_t *alias) // Get container index uint16_t i = (uint16_t)(Luos_GetContainerIndex(container)); - if ((i >= 0)&&(i != 0xFFFF)) + if ((i >= 0) && (i != 0xFFFF)) { Luos_WriteAlias(i, alias); return SUCESS; @@ -860,7 +860,7 @@ error_return_t Luos_SetExternId(container_t *container, target_mode_t target_mod msg.header.size = 2; msg.data[1] = newid; msg.data[0] = (newid << 8); - if (Robus_SendMsg(container->ll_container, &msg)==SUCESS) + if (Robus_SendMsg(container->ll_container, &msg) == SUCESS) { return SUCESS; } From 7446850e11a73318bc4d49ada85e7cc8359086be Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Tue, 24 Nov 2020 17:11:05 +0100 Subject: [PATCH 08/12] avoid error_return_t redefinition --- Robus/inc/robus_struct.h | 4 +- Robus/src/msg_alloc.c | 46 ++++++++--------- Robus/src/port_manager.c | 4 +- Robus/src/robus.c | 37 +++++++------- src/luos.c | 106 +++++++++++++++++++-------------------- 5 files changed, 98 insertions(+), 99 deletions(-) diff --git a/Robus/inc/robus_struct.h b/Robus/inc/robus_struct.h index 253e2276f..c282c774f 100644 --- a/Robus/inc/robus_struct.h +++ b/Robus/inc/robus_struct.h @@ -98,8 +98,8 @@ typedef struct __attribute__((__packed__)) ******************************************************************************/ typedef enum { - SUCESS, /*!< function work properly. */ - FAIL = 0xFF /*!< function fail. */ + SUCCEED, /*!< function work properly. */ + FAILED = 0xFF /*!< function fail. */ } error_return_t; /****************************************************************************** diff --git a/Robus/src/msg_alloc.c b/Robus/src/msg_alloc.c index 0713b9c48..57f7434ce 100644 --- a/Robus/src/msg_alloc.c +++ b/Robus/src/msg_alloc.c @@ -165,9 +165,9 @@ static inline error_return_t MsgAlloc_DoWeHaveSpace(void *to) if ((uint32_t)to > ((uint32_t)&msg_buffer[MSG_BUFFER_SIZE - 1])) { // We reach msg_buffer end return an error - return FAIL; + return FAILED; } - return SUCESS; + return SUCCEED; } /****************************************************************************** * @brief Invalid the current message header by removing it (data will be ignored). @@ -197,7 +197,7 @@ void MsgAlloc_ValidHeader(uint8_t valid, uint16_t data_size) // Save the concerned module pointer into the concerned module pointer stack if (valid == true) { - if (MsgAlloc_DoWeHaveSpace((void *)(¤t_msg->data[data_size + 2])) == FAIL) + if (MsgAlloc_DoWeHaveSpace((void *)(¤t_msg->data[data_size + 2])) == FAILED) { // We are at the end of msg_buffer, we need to move the current space to the begin of msg_buffer // Create a task to copy the header at the begining of msg_buffer @@ -250,7 +250,7 @@ void MsgAlloc_EndMsg(void) //data_ptr is actually 2 bytes after the message data because of the CRC. Remove the CRC. data_ptr -= 2; // clean space between data_ptr (data_ptr + sizeof(header_t)+2) - if (MsgAlloc_DoWeHaveSpace((void *)(data_ptr + sizeof(header_t) + 2)) == FAIL) + if (MsgAlloc_DoWeHaveSpace((void *)(data_ptr + sizeof(header_t) + 2)) == FAILED) { data_ptr = &msg_buffer[0]; } @@ -298,7 +298,7 @@ void MsgAlloc_SetMessage(msg_t *msg) } LuosHAL_SetIrqState(false); - if (MsgAlloc_DoWeHaveSpace((void *)(¤t_msg->stream[data_size])) == FAIL) + if (MsgAlloc_DoWeHaveSpace((void *)(¤t_msg->stream[data_size])) == FAILED) { // We are at the end of msg_buffer, we need to move the current space to the begin of msg_buffer // Move current_msg to msg_buffer @@ -341,11 +341,11 @@ error_return_t MsgAlloc_IsEmpty(void) { if (data_ptr == &msg_buffer[0]) { - return SUCESS; + return SUCCEED; } else { - return FAIL; + return FAILED; } } @@ -365,7 +365,7 @@ static inline error_return_t MsgAlloc_ClearMsgSpace(void *from, void *to) if ((uint32_t)to > ((uint32_t)&msg_buffer[MSG_BUFFER_SIZE - 1])) { // We reach msg_buffer end return an error - return FAIL; + return FAILED; } //******** Prepare a memory space to be writable ********** @@ -399,7 +399,7 @@ static inline error_return_t MsgAlloc_ClearMsgSpace(void *from, void *to) } } // if we go here there is no reason to continue because newest messages can't overlap the memory zone. - return SUCESS; + return SUCCEED; } /******************************************************************************* * Functions --> msg interpretation task stack @@ -439,10 +439,10 @@ error_return_t MsgAlloc_PullMsgToInterpret(msg_t **returned_msg) { *returned_msg = (msg_t *)msg_tasks[0]; MsgAlloc_ClearMsgTask(); - return SUCESS; + return SUCCEED; } // At this point we don't find any message for this module - return FAIL; + return FAILED; } /******************************************************************************* @@ -530,11 +530,11 @@ error_return_t MsgAlloc_PullMsg(ll_container_t *target_module, msg_t **returned_ // Clear the slot by sliding others to the left on it used_msg = *returned_msg; MsgAlloc_ClearLuosTask(i); - return SUCESS; + return SUCCEED; } } // At this point we don't find any message for this module - return FAIL; + return FAILED; } /****************************************************************************** * @brief Pull a message allocated to a specific luos task @@ -552,10 +552,10 @@ error_return_t MsgAlloc_PullMsgFromLuosTask(uint16_t luos_task_id, msg_t **retur // Clear the slot by sliding others to the left on it used_msg = *returned_msg; MsgAlloc_ClearLuosTask(luos_task_id); - return SUCESS; + return SUCCEED; } // At this point we don't find any message for this module - return FAIL; + return FAILED; } /****************************************************************************** * @brief get back the module who received the oldest message @@ -568,9 +568,9 @@ error_return_t MsgAlloc_LookAtLuosTask(uint16_t luos_task_id, ll_container_t **a if (luos_task_id < luos_tasks_stack_id) { *allocated_module = luos_tasks[luos_task_id].ll_container_pt; - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief get back a specific slot message command @@ -583,9 +583,9 @@ error_return_t MsgAlloc_GetLuosTaskCmd(uint16_t luos_task_id, uint8_t *cmd) if (luos_task_id < luos_tasks_stack_id) { *cmd = luos_tasks[luos_task_id].msg_pt->header.cmd; - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief get back a specific slot message command @@ -598,9 +598,9 @@ error_return_t MsgAlloc_GetLuosTaskSourceId(uint16_t luos_task_id, uint16_t *sou if (luos_task_id < luos_tasks_stack_id) { *source_id = luos_tasks[luos_task_id].msg_pt->header.source; - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief get back a specific slot message command @@ -613,9 +613,9 @@ error_return_t MsgAlloc_GetLuosTaskSize(uint16_t luos_task_id, uint16_t *size) if (luos_task_id < luos_tasks_stack_id) { *size = luos_tasks[luos_task_id].msg_pt->header.size; - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief return the number of allocated messages diff --git a/Robus/src/port_manager.c b/Robus/src/port_manager.c index 5ed2f0b21..2fc3277b6 100644 --- a/Robus/src/port_manager.c +++ b/Robus/src/port_manager.c @@ -120,7 +120,7 @@ error_return_t PortMng_PokeNextPort(void) // this port have not been poked if (PortMng_PokePort(port)) { - return SUCESS; + return SUCCEED; } else { @@ -130,7 +130,7 @@ error_return_t PortMng_PokeNextPort(void) } } PortMng_Reset(); - return FAIL; + return FAILED; } /****************************************************************************** * @brief reinit the detection state machine diff --git a/Robus/src/robus.c b/Robus/src/robus.c index 74615ef63..cff56519f 100644 --- a/Robus/src/robus.c +++ b/Robus/src/robus.c @@ -90,10 +90,10 @@ void Robus_Loop(void) MsgAlloc_loop(); // Interpreat received messages and create luos task for it. msg_t *msg = NULL; - while (MsgAlloc_PullMsgToInterpret(&msg) == SUCESS) + while (MsgAlloc_PullMsgToInterpret(&msg) == SUCCEED) { // Check if this message is a protocole one - if (Robus_MsgHandler(msg) == FAIL) + if (Robus_MsgHandler(msg) == FAILED) { // If not create luos tasks. Recep_InterpretMsgProtocol(msg); @@ -138,7 +138,7 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) { // Compute the full message size based on the header size info. uint16_t data_size = 0; - error_return_t fail = SUCCESS; + error_return_t fail = SUCCEED; if (msg->header.size > MAX_DATA_MSG_SIZE) { data_size = MAX_DATA_MSG_SIZE; @@ -227,7 +227,7 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) { // Set the dead container ID into the ll_container ll_container->dead_container_spotted = (uint16_t)(msg->header.target); - fail = FAIL; + fail = FAILED; } } ctx.ack = 0; @@ -263,7 +263,7 @@ uint16_t Robus_TopologyDetection(ll_container_t *ll_container) // setup sending ll_container ll_container->id = 1; - if (Robus_DetectNextNodes(ll_container) == FAIL) + if (Robus_DetectNextNodes(ll_container) == FAILED) { // check the number of retry we made if (redetect_nb > 4) @@ -308,16 +308,16 @@ static error_return_t Robus_ResetNetworkDetection(ll_container_t *ll_container) ; try ++; - } while ((MsgAlloc_IsEmpty() != SUCESS) || (try > 5)); + } while ((MsgAlloc_IsEmpty() != SUCCEED) || (try > 5)); ctx.node.node_id = 0; PortMng_Init(); if (try < 5) { - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief run the procedure allowing to detect the next nodes on the next port @@ -327,7 +327,7 @@ static error_return_t Robus_ResetNetworkDetection(ll_container_t *ll_container) static error_return_t Robus_DetectNextNodes(ll_container_t *ll_container) { // Lets try to poke other nodes - while (PortMng_PokeNextPort() == SUCESS) + while (PortMng_PokeNextPort() == SUCCEED) { // There is someone here // Ask an ID to the detector container. @@ -336,7 +336,7 @@ static error_return_t Robus_DetectNextNodes(ll_container_t *ll_container) msg.header.target = 1; msg.header.cmd = WRITE_NODE_ID; msg.header.size = 0; - if (Robus_SendMsg(ll_container, &msg) == FAIL) + if (Robus_SendMsg(ll_container, &msg) == FAILED) { // Message transmission failure // Consider this port unconnected @@ -354,16 +354,16 @@ static error_return_t Robus_DetectNextNodes(ll_container_t *ll_container) if (LuosHAL_GetSystick() - start_tick > 1000) { // topology detection is too long, we should abort it and restart - return FAIL; + return FAILED; } } } - return SUCESS; + return SUCCEED; } /****************************************************************************** * @brief check if received messages are protocols one and manage it if it is. * @param msg pointer to the reeived message - * @return error_return_t success if the message have been consumed. + * @return error_return_t SUCCEED if the message have been consumed. ******************************************************************************/ static error_return_t Robus_MsgHandler(msg_t *input) { @@ -419,22 +419,21 @@ static error_return_t Robus_MsgHandler(msg_t *input) default: break; } - return SUCCESS; + return SUCCEED; break; case RESET_DETECTION: - return SUCCESS; + return SUCCEED; break; case SET_BAUDRATE: memcpy(&baudrate, input->data, sizeof(uint32_t)); LuosHAL_ComInit(baudrate); - return SUCCESS; + return SUCCEED; break; - default: - return FAIL; + return FAILED; break; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief get node structure diff --git a/src/luos.c b/src/luos.c index e931f6937..b0f533373 100644 --- a/src/luos.c +++ b/src/luos.c @@ -68,32 +68,32 @@ void Luos_Loop(void) } Robus_Loop(); // look at all received messages - while (MsgAlloc_LookAtLuosTask(remaining_msg_number, &oldest_ll_container) != FAIL) + while (MsgAlloc_LookAtLuosTask(remaining_msg_number, &oldest_ll_container) != FAILED) { // There is a message available find the container linked to it container_t *container = Luos_GetContainer(oldest_ll_container); // check if this is a Luos Command uint8_t cmd = 0; uint16_t size = 0; - if (MsgAlloc_GetLuosTaskCmd(remaining_msg_number, &cmd) == FAIL) + if (MsgAlloc_GetLuosTaskCmd(remaining_msg_number, &cmd) == FAILED) { // this is a critical failure we should never go here while (1) ; } - if (MsgAlloc_GetLuosTaskSize(remaining_msg_number, &size) == FAIL) + if (MsgAlloc_GetLuosTaskSize(remaining_msg_number, &size) == FAILED) { // this is a critical failure we should never go here while (1) ; } //check if this msg cmd should be consumed by Luos_MsgHandler - if (Luos_IsALuosCmd(cmd, size) == SUCESS) + if (Luos_IsALuosCmd(cmd, size) == SUCCEED) { - if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCESS) + if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCCEED) { // be sure the content of this message need to be managed by Luos and do it if it is. - if (Luos_MsgHandler((container_t *)container, returned_msg) == FAIL) + if (Luos_MsgHandler((container_t *)container, returned_msg) == FAILED) { // we should not go there there is a mistake on Luos_IsALuosCmd or Luos_MsgHandler while (1) @@ -114,7 +114,7 @@ void Luos_Loop(void) if (container->cont_cb != 0) { // This container have a callback pull the message - if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCESS) + if (MsgAlloc_PullMsgFromLuosTask(remaining_msg_number, &returned_msg) == SUCCEED) { // This message is for the user, pass it to the user. container->cont_cb(container, returned_msg); @@ -136,7 +136,7 @@ void Luos_Loop(void) /****************************************************************************** * @brief Check if this command concern luos * @param cmd The command value - * @return Success if the command if for Luos else Fail + * @return SUCCEED if the command if for Luos else Fail ******************************************************************************/ static error_return_t Luos_IsALuosCmd(uint8_t cmd, uint16_t size) { @@ -152,7 +152,7 @@ static error_return_t Luos_IsALuosCmd(uint8_t cmd, uint16_t size) case RTB_CMD: case WRITE_ALIAS: case UPDATE_PUB: - return SUCESS; + return SUCCEED; break; case REVISION: @@ -161,14 +161,14 @@ static error_return_t Luos_IsALuosCmd(uint8_t cmd, uint16_t size) case LUOS_STATISTICS: if (size == 0) { - return SUCESS; + return SUCCEED; } break; default: - return FAIL; + return FAILED; break; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief handling msg for Luos library @@ -179,7 +179,7 @@ static error_return_t Luos_IsALuosCmd(uint8_t cmd, uint16_t size) ******************************************************************************/ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) { - error_return_t error = FAIL; + error_return_t error = FAILED; msg_t output_msg; routing_table_t *route_tab = &RoutingTB_Get()[RoutingTB_GetLastEntry()]; time_luos_t time; @@ -228,14 +228,14 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) Luos_TransmitLocalRoutingTable(container, &output_msg); break; default: - if (Luos_ReceiveData(container, input, (void *)route_tab) == SUCESS) + if (Luos_ReceiveData(container, input, (void *)route_tab) == SUCCEED) { // route table section reception complete RoutingTB_ComputeRoutingTableEntryNB(); } break; } - error = SUCESS; + error = SUCCEED; break; case REVISION: if (input->header.size == 0) @@ -248,7 +248,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) output.header.size = strlen((char *)output.data); output.header.target = input->header.source; Luos_SendMsg(container, &output); - error = SUCESS; + error = SUCCEED; } break; case LUOS_REVISION: @@ -263,7 +263,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) output.header.size = strlen((char *)output.data); output.header.target = input->header.source; Luos_SendMsg(container, &output); - error = SUCESS; + error = SUCCEED; } break; case NODE_UUID: @@ -280,7 +280,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) uuid.uuid[2] = LUOS_UUID[2]; memcpy(output.data, &uuid.unmap, sizeof(luos_uuid_t)); Luos_SendMsg(container, &output); - error = SUCESS; + error = SUCCEED; } break; case LUOS_STATISTICS: @@ -293,7 +293,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) output.header.target = input->header.source; memcpy(output.data, &luos_stats.unmap, sizeof(luos_stats_t)); Luos_SendMsg(container, &output); - error = SUCESS; + error = SUCCEED; } break; case WRITE_ALIAS: @@ -324,7 +324,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) Luos_SaveAlias(container, '\0'); memcpy(container->alias, container->default_alias, MAX_ALIAS_SIZE); } - error = SUCESS; + error = SUCCEED; break; case UPDATE_PUB: // this container need to be auto updated @@ -332,7 +332,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) container->auto_refresh.target = input->header.source; container->auto_refresh.time_ms = (uint16_t)TimeOD_TimeTo_ms(time); container->auto_refresh.last_update = LuosHAL_GetSystick(); - error = SUCESS; + error = SUCCEED; break; default: break; @@ -476,7 +476,7 @@ container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *ali container->default_alias[i] = '\0'; // Initialise the container alias to 0 memset((void *)container->alias, 0, sizeof(container->alias)); - if (Luos_ReadAlias(container_number, (uint8_t *)container->alias) == FAIL) + if (Luos_ReadAlias(container_number, (uint8_t *)container->alias) == FAILED) { // if no alias saved keep the default one for (i = 0; i < MAX_ALIAS_SIZE - 1; i++) @@ -515,37 +515,37 @@ error_return_t Luos_SendMsg(container_t *container, msg_t *msg) * @brief read last msg from buffer for a container * @param container who receive the message we are looking for * @param returned_msg oldest message of the container - * @return FAIL if no message available + * @return FAILED if no message available ******************************************************************************/ error_return_t Luos_ReadMsg(container_t *container, msg_t **returned_msg) { - error_return_t error = SUCESS; - while (error == SUCESS) + error_return_t error = SUCCEED; + while (error == SUCCEED) { error = MsgAlloc_PullMsg(container->ll_container, returned_msg); // check if the content of this message need to be managed by Luos and do it if it is. - if ((Luos_MsgHandler(container, *returned_msg) == FAIL) & (error == SUCESS)) + if ((Luos_MsgHandler(container, *returned_msg) == FAILED) & (error == SUCCEED)) { // This message is for the user, pass it to the user. - return SUCESS; + return SUCCEED; } MsgAlloc_ClearMsgFromLuosTasks(*returned_msg); } - return FAIL; + return FAILED; } /****************************************************************************** * @brief read last msg from buffer from a special id container * @param container who receive the message we are looking for * @param id who sent the message we are looking for * @param returned_msg oldest message of the container - * @return FAIL if no message available + * @return FAILED if no message available ******************************************************************************/ error_return_t Luos_ReadFromContainer(container_t *container, short id, msg_t **returned_msg) { uint16_t remaining_msg_number = 0; ll_container_t *oldest_ll_container = NULL; - error_return_t error = SUCESS; - while (MsgAlloc_LookAtLuosTask(remaining_msg_number, &oldest_ll_container) != FAIL) + error_return_t error = SUCCEED; + while (MsgAlloc_LookAtLuosTask(remaining_msg_number, &oldest_ll_container) != FAILED) { // Check the source id if (oldest_ll_container == container->ll_container) @@ -557,10 +557,10 @@ error_return_t Luos_ReadFromContainer(container_t *container, short id, msg_t ** // Source id of this message match, get it and treat it. error = MsgAlloc_PullMsg(container->ll_container, returned_msg); // check if the content of this message need to be managed by Luos and do it if it is. - if ((Luos_MsgHandler(container, *returned_msg) == FAIL) & (error == SUCESS)) + if ((Luos_MsgHandler(container, *returned_msg) == FAILED) & (error == SUCCEED)) { // This message is for the user, pass it to the user. - return SUCESS; + return SUCCEED; } MsgAlloc_ClearMsgFromLuosTasks(*returned_msg); } @@ -574,7 +574,7 @@ error_return_t Luos_ReadFromContainer(container_t *container, short id, msg_t ** remaining_msg_number++; } } - return FAIL; + return FAILED; } /****************************************************************************** * @brief Send large among of data and formating to send into multiple msg @@ -614,16 +614,16 @@ error_return_t Luos_SendData(container_t *container, msg_t *msg, void *bin_data, msg->header.size = size - sent_size; // Send message - if (Luos_SendMsg(container, msg) == FAIL) + if (Luos_SendMsg(container, msg) == FAILED) { // This message fail stop transmission and return an error - return SUCESS; + return SUCCEED; } // Save current state sent_size = sent_size + chunk_size; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief receive a multi msg data @@ -641,7 +641,7 @@ error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_da // check good container index if (id == 0xFFFF) { - return FAIL; + return FAILED; } // check message integrity @@ -651,7 +651,7 @@ error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_da // reset session and return an error. data_size[id] = 0; last_msg_size = 0; - return FAIL; + return FAILED; } // Get chunk size @@ -678,9 +678,9 @@ error_return_t Luos_ReceiveData(container_t *container, msg_t *msg, void *bin_da // Data collection finished, reset buffer session state data_size[id] = 0; last_msg_size = 0; - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief Send datas of a streaming channel @@ -719,7 +719,7 @@ error_return_t Luos_SendStreaming(container_t *container, msg_t *msg, streaming_ Stream_GetSample(stream, msg->data, chunk_size); // Send message - if (Luos_SendMsg(container, msg) == FAIL) + if (Luos_SendMsg(container, msg) == FAILED) { // this message fail stop transmission, retrieve datas and return an error stream->sample_ptr = stream->sample_ptr - (chunk_size * stream->data_size); @@ -727,7 +727,7 @@ error_return_t Luos_SendStreaming(container_t *container, msg_t *msg, streaming_ { stream->sample_ptr = stream->end_ring_buffer - (stream->ring_buffer - stream->sample_ptr); } - return FAIL; + return FAILED; } // check end of data @@ -740,7 +740,7 @@ error_return_t Luos_SendStreaming(container_t *container, msg_t *msg, streaming_ data_size = 0; } } - return SUCESS; + return SUCCEED; } /****************************************************************************** * @brief Receive a streaming channel datas @@ -765,9 +765,9 @@ error_return_t Luos_ReceiveStreaming(container_t *container, msg_t *msg, streami if ((msg->header.size <= MAX_DATA_MSG_SIZE)) { // Chunk collection finished - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief store alias name container in flash @@ -783,9 +783,9 @@ static error_return_t Luos_SaveAlias(container_t *container, uint8_t *alias) if ((i >= 0) && (i != 0xFFFF)) { Luos_WriteAlias(i, alias); - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief write alias name container from flash @@ -811,11 +811,11 @@ static error_return_t Luos_ReadAlias(uint16_t local_id, uint8_t *alias) // Check name integrity if ((((alias[0] < 'A') | (alias[0] > 'Z')) & ((alias[0] < 'a') | (alias[0] > 'z'))) | (alias[0] == '\0')) { - return FAIL; + return FAILED; } else { - return SUCESS; + return SUCCEED; } } /****************************************************************************** @@ -860,11 +860,11 @@ error_return_t Luos_SetExternId(container_t *container, target_mode_t target_mod msg.header.size = 2; msg.data[1] = newid; msg.data[0] = (newid << 8); - if (Robus_SendMsg(container->ll_container, &msg) == SUCESS) + if (Robus_SendMsg(container->ll_container, &msg) == SUCCEED) { - return SUCESS; + return SUCCEED; } - return FAIL; + return FAILED; } /****************************************************************************** * @brief return the number of messages available From 3bf36220c130761c21810d4227261b7cc54a71de Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Wed, 25 Nov 2020 16:22:55 +0100 Subject: [PATCH 09/12] Add platformio release automation --- .github/workflows/pio_release.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/pio_release.yml diff --git a/.github/workflows/pio_release.yml b/.github/workflows/pio_release.yml new file mode 100644 index 000000000..01b59779d --- /dev/null +++ b/.github/workflows/pio_release.yml @@ -0,0 +1,25 @@ +name: Upload platformio library + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install platformio + - name: Build and publish + env: + PLATFORMIO_AUTH_TOKEN: ${{ secrets.PIO_TOKEN }} + run: | + pio package pack + pio package publish --owner "Luos" \ No newline at end of file From fa61c39e6eaba3bd68bd8104608d2607911ca82e Mon Sep 17 00:00:00 2001 From: Salem-Luos Date: Wed, 25 Nov 2020 20:03:46 +0100 Subject: [PATCH 10/12] clean up reception --- Robus/src/reception.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Robus/src/reception.c b/Robus/src/reception.c index 39e94d2a5..51896afc5 100644 --- a/Robus/src/reception.c +++ b/Robus/src/reception.c @@ -28,6 +28,7 @@ uint16_t data_count = 0; uint16_t data_size = 0; uint16_t crc_val = 0; msg_t *current_msg; + /******************************************************************************* * Function ******************************************************************************/ @@ -50,7 +51,7 @@ void Recep_Init(void) * @param data come from RX * @return None ******************************************************************************/ -void Recep_GetHeader(volatile unsigned char *data) +void Recep_GetHeader(volatile uint8_t *data) { // Catch a byte. MsgAlloc_SetData(*data); @@ -116,7 +117,7 @@ void Recep_GetHeader(volatile unsigned char *data) * @param data come from RX * @return None ******************************************************************************/ -void Recep_GetData(volatile unsigned char *data) +void Recep_GetData(volatile uint8_t *data) { if (keep) { @@ -173,7 +174,7 @@ void Recep_GetData(volatile unsigned char *data) * @param data come from RX * @return None ******************************************************************************/ -void Recep_GetCollision(volatile unsigned char *data) +void Recep_GetCollision(volatile uint8_t *data) { // send all received datas Recep_GetHeader(data); @@ -223,7 +224,7 @@ void Recep_Reset(void) * @param data come from RX * @return None ******************************************************************************/ -void Recep_CatchAck(volatile unsigned char *data) +void Recep_CatchAck(volatile uint8_t *data) { ctx.ack = *data; ctx.rx.callback = Recep_GetHeader; From fab886117fbe9c20c5064119d39729f566a37f70 Mon Sep 17 00:00:00 2001 From: Salem-Luos Date: Wed, 25 Nov 2020 20:04:22 +0100 Subject: [PATCH 11/12] add container statistic and ll_container_stat --- Robus/inc/robus_struct.h | 10 ++++++++++ Robus/src/robus.c | 29 +++++++++++++++++++++++++---- inc/container_structs.h | 18 ++++++++++++++++++ inc/luos.h | 15 ++++++++++++++- src/luos.c | 28 +++++++++++++++++++++++++--- 5 files changed, 92 insertions(+), 8 deletions(-) diff --git a/Robus/inc/robus_struct.h b/Robus/inc/robus_struct.h index c282c774f..b569eb1e5 100644 --- a/Robus/inc/robus_struct.h +++ b/Robus/inc/robus_struct.h @@ -25,6 +25,13 @@ typedef struct __attribute__((__packed__)) uint8_t msg_drop_number; } memory_stats_t; +typedef struct __attribute__((__packed__)) +{ + uint8_t msg_nbr; + uint8_t fail_msg_nbr; + uint8_t *max_collision_retry; + uint8_t *max_nak_retry; +} ll_stats_t; /* * This structure is used to get the message addressing mode list. */ @@ -90,6 +97,9 @@ typedef struct __attribute__((__packed__)) uint16_t max_multicast_target; /*!< Position pointer of the last multicast target. */ uint16_t multicast_target_bank[MAX_MULTICAST_ADDRESS]; /*!< multicast target bank. */ uint16_t dead_container_spotted; /*!< The ID of a container that don't reply to a lot of ACK msg */ + + //variable stat on robus com for ll_container + ll_stats_t ll_stat; } ll_container_t; /****************************************************************************** diff --git a/Robus/src/robus.c b/Robus/src/robus.c index cff56519f..3bd4b99b7 100644 --- a/Robus/src/robus.c +++ b/Robus/src/robus.c @@ -76,6 +76,7 @@ void Robus_Init(memory_stats_t *memory_stats) // Initialize the robus container status ctx.rx.status.unmap = 0; ctx.rx.status.identifier = 0xF; + // Init hal LuosHAL_Init(); } @@ -138,7 +139,6 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) { // Compute the full message size based on the header size info. uint16_t data_size = 0; - error_return_t fail = SUCCEED; if (msg->header.size > MAX_DATA_MSG_SIZE) { data_size = MAX_DATA_MSG_SIZE; @@ -148,7 +148,6 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) data_size = msg->header.size; } uint16_t full_size = sizeof(header_t) + data_size; - uint8_t nbr_nak_retry = 0; // Set protocol revision and source ID on the message msg->header.protocol = PROTOCOL_REVISION; if (ll_container->id != 0) @@ -161,8 +160,14 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) } // Add the CRC to the total size of the message full_size += 2; + + //try to send msg computed + error_return_t result = SUCCEED; + uint8_t nbr_nak_retry = 0; + uint8_t RetryCollision = 0; ack_restart: nbr_nak_retry++; + RetryCollision = 0; LuosHAL_SetIrqState(false); ctx.ack = FALSE; LuosHAL_SetIrqState(true); @@ -176,6 +181,13 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) LuosHAL_SetIrqState(true); // wait timeout of collided packet Transmit_WaitUnlockTx(); + //max collision possible + RetryCollision++; + if(RetryCollision > NBR_NAK_RETRY) + { + result = FAILED; + break; + } // timer proportional to ID if (ll_container->id > 1) { @@ -183,6 +195,10 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) ; } } + if(*ll_container->ll_stat.max_collision_retry < RetryCollision) + { + *ll_container->ll_stat.max_collision_retry = RetryCollision; + } // Check if ACK needed if ((msg->header.target_mode == IDACK) || (msg->header.target_mode == NODEIDACK)) { @@ -226,13 +242,18 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) else { // Set the dead container ID into the ll_container + result = FAILED; ll_container->dead_container_spotted = (uint16_t)(msg->header.target); - fail = FAILED; } } ctx.ack = 0; } + if(*ll_container->ll_stat.max_nak_retry < nbr_nak_retry) + { + *ll_container->ll_stat.max_nak_retry = nbr_nak_retry; + } } + // localhost management if (Recep_NodeConcerned(&msg->header)) { @@ -242,7 +263,7 @@ error_return_t Robus_SendMsg(ll_container_t *ll_container, msg_t *msg) // set message into the allocator MsgAlloc_SetMessage(msg); } - return fail; + return result; } /****************************************************************************** * @brief Start a topology detection procedure diff --git a/inc/container_structs.h b/inc/container_structs.h index 9cf71cd63..33c34d114 100644 --- a/inc/container_structs.h +++ b/inc/container_structs.h @@ -14,6 +14,23 @@ /******************************************************************************* * Definitions ******************************************************************************/ +/* This structure is used to manage containers statistic + * please refer to the documentation + */ +typedef struct __attribute__((__packed__)) container_stats_t +{ + union + { + struct __attribute__((__packed__)) + { + uint8_t msg_fail_ratio; + uint8_t max_collision_retry; + uint8_t max_nak_retry; + }; + uint8_t unmap[3]; /*!< streamable form. */ + }; +} container_stats_t; + /* This structure is used to manage containers timed auto update * please refer to the documentation */ @@ -37,6 +54,7 @@ typedef struct __attribute__((__packed__)) container_t uint8_t alias[MAX_ALIAS_SIZE]; /*!< container alias. */ timed_update_t auto_refresh; /*!< container auto refresh context. */ uint8_t firm_version[20]; /*!< container firmware version. */ + container_stats_t statistic; } container_t; typedef void (*CONT_CB)(container_t *container, msg_t *msg); diff --git a/inc/luos.h b/inc/luos.h index f54fba3bb..7f3d86582 100644 --- a/inc/luos.h +++ b/inc/luos.h @@ -21,6 +21,7 @@ * @struct luos_stats_t * @brief store informations about luos stats ******************************************************************************/ + typedef struct __attribute__((__packed__)) { union @@ -30,10 +31,22 @@ typedef struct __attribute__((__packed__)) memory_stats_t memory; uint8_t max_loop_time_ms; }; - uint8_t unmap[5]; /*!< streamable form. */ + uint8_t unmap[sizeof(memory_stats_t)+1]; /*!< streamable form. */ }; } luos_stats_t; +typedef struct __attribute__((__packed__)) +{ + union + { + struct __attribute__((__packed__)) + { + luos_stats_t node_stat; + container_stats_t container_stat; + }; + uint8_t unmap[sizeof(luos_stats_t)+sizeof(container_stats_t)]; /*!< streamable form. */ + }; +} general_stats_t; /******************************************************************************* * Variables ******************************************************************************/ diff --git a/src/luos.c b/src/luos.c index b0f533373..decfdbe96 100644 --- a/src/luos.c +++ b/src/luos.c @@ -25,6 +25,7 @@ uint16_t container_number; volatile routing_table_t *routing_table_pt; luos_stats_t luos_stats; +general_stats_t general_stats; /******************************************************************************* * Function ******************************************************************************/ @@ -289,9 +290,11 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) msg_t output; output.header.cmd = LUOS_STATISTICS; output.header.target_mode = ID; - output.header.size = sizeof(luos_stats_t); + output.header.size = sizeof(general_stats_t); output.header.target = input->header.source; - memcpy(output.data, &luos_stats.unmap, sizeof(luos_stats_t)); + memcpy(&general_stats.node_stat, &luos_stats.unmap, sizeof(luos_stats_t)); + memcpy(&general_stats.container_stat, &container->statistic.unmap, sizeof(container_stats_t)); + memcpy(output.data, &general_stats.unmap, sizeof(general_stats_t)); Luos_SendMsg(container, &output); error = SUCCEED; } @@ -498,6 +501,10 @@ container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *ali break; } + //initiate container statistic + container->ll_container->ll_stat.max_collision_retry = &container->statistic.max_collision_retry ; + container->ll_container->ll_stat.max_nak_retry = &container->statistic.max_nak_retry; + container_number++; return container; } @@ -509,7 +516,22 @@ container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *ali ******************************************************************************/ error_return_t Luos_SendMsg(container_t *container, msg_t *msg) { - return Robus_SendMsg(container->ll_container, msg); + error_return_t result = SUCCEED; + if(Robus_SendMsg(container->ll_container, msg) != SUCCEED) + { + container->ll_container->ll_stat.fail_msg_nbr++; + result = FAILED; + } + container->ll_container->ll_stat.msg_nbr++; + + if(container->ll_container->ll_stat.msg_nbr == 0xFF) + { + container->ll_container->ll_stat.msg_nbr = container->ll_container->ll_stat.msg_nbr>>1; + } + + container->statistic.msg_fail_ratio = (uint8_t)(((uint32_t)container->ll_container->ll_stat.fail_msg_nbr * 100) / container->ll_container->ll_stat.msg_nbr); + + return result; } /****************************************************************************** * @brief read last msg from buffer for a container From 640fffbee19b2b88274d791ea9ae3402eb0e943b Mon Sep 17 00:00:00 2001 From: Salem-Luos Date: Fri, 27 Nov 2020 12:05:01 +0100 Subject: [PATCH 12/12] update revision management and switch to 1.0.0 --- inc/container_structs.h | 18 +++++++++++++++++- inc/luos.h | 8 +++----- library.json | 5 ++--- src/luos.c | 38 ++++++++++++++++---------------------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/inc/container_structs.h b/inc/container_structs.h index 33c34d114..e002c7fc0 100644 --- a/inc/container_structs.h +++ b/inc/container_structs.h @@ -14,6 +14,22 @@ /******************************************************************************* * Definitions ******************************************************************************/ +/* This structure is used to create containers version + * please refer to the documentation + */ +typedef struct __attribute__((__packed__)) +{ + union + { + struct __attribute__((__packed__)) + { + uint8_t Major; + uint8_t Minor; + uint8_t Build; + }; + uint8_t unmap[3]; /*!< streamable form. */ + }; +} revision_t; /* This structure is used to manage containers statistic * please refer to the documentation */ @@ -53,7 +69,7 @@ typedef struct __attribute__((__packed__)) container_t uint8_t default_alias[MAX_ALIAS_SIZE]; /*!< container default alias. */ uint8_t alias[MAX_ALIAS_SIZE]; /*!< container alias. */ timed_update_t auto_refresh; /*!< container auto refresh context. */ - uint8_t firm_version[20]; /*!< container firmware version. */ + revision_t revision; /*!< container firmware version. */ container_stats_t statistic; } container_t; diff --git a/inc/luos.h b/inc/luos.h index 7f3d86582..d87a9d285 100644 --- a/inc/luos.h +++ b/inc/luos.h @@ -21,7 +21,6 @@ * @struct luos_stats_t * @brief store informations about luos stats ******************************************************************************/ - typedef struct __attribute__((__packed__)) { union @@ -31,7 +30,7 @@ typedef struct __attribute__((__packed__)) memory_stats_t memory; uint8_t max_loop_time_ms; }; - uint8_t unmap[sizeof(memory_stats_t)+1]; /*!< streamable form. */ + uint8_t unmap[sizeof(memory_stats_t) + 1]; /*!< streamable form. */ }; } luos_stats_t; @@ -44,7 +43,7 @@ typedef struct __attribute__((__packed__)) luos_stats_t node_stat; container_stats_t container_stat; }; - uint8_t unmap[sizeof(luos_stats_t)+sizeof(container_stats_t)]; /*!< streamable form. */ + uint8_t unmap[sizeof(luos_stats_t) + sizeof(container_stats_t)]; /*!< streamable form. */ }; } general_stats_t; /******************************************************************************* @@ -54,11 +53,10 @@ typedef struct __attribute__((__packed__)) /******************************************************************************* * Function ******************************************************************************/ - void Luos_Init(void); void Luos_Loop(void); void Luos_ContainersClear(void); -container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *alias, char *firm_revision); +container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *alias, revision_t revision); error_return_t Luos_SendMsg(container_t *container, msg_t *msg); error_return_t Luos_ReadMsg(container_t *container, msg_t **returned_msg); error_return_t Luos_ReadFromContainer(container_t *container, int16_t id, msg_t **returned_msg); diff --git a/library.json b/library.json index edf6d208b..18c529f33 100644 --- a/library.json +++ b/library.json @@ -2,7 +2,7 @@ "name": "Luos", "keywords": "robus,network,microservice,luos,operating system,os,embedded,communication,module,ST", "description": "Luos turns your embedded system into modules like microservices architecture does it in software.", - "version": "0.7.0", + "version": "1.0.0", "authors": { "name": "Luos", "url": "https://luos.io" @@ -11,8 +11,7 @@ "flags": [ "-I inc", "-I OD", - "-I Robus/inc", - "-DVERSION=0.7.0" + "-I Robus/inc" ], "srcFilter": [ "+<*.c>", diff --git a/src/luos.c b/src/luos.c index decfdbe96..d5c8d1a4b 100644 --- a/src/luos.c +++ b/src/luos.c @@ -14,12 +14,11 @@ /******************************************************************************* * Definitions ******************************************************************************/ -#define STRINGIFY(s) STRINGIFY1(s) -#define STRINGIFY1(s) #s /******************************************************************************* * Variables ******************************************************************************/ +revision_t luos_version = {.Major = 1, .Minor = 0, .Build = 0}; container_t container_table[MAX_CONTAINER_NUMBER]; uint16_t container_number; volatile routing_table_t *routing_table_pt; @@ -244,9 +243,8 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) msg_t output; output.header.cmd = REVISION; output.header.target_mode = ID; - sprintf((char *)output.data, "%s", container->firm_version); - memcpy(output.data, container->firm_version, sizeof(output.data)); - output.header.size = strlen((char *)output.data); + memcpy(output.data, container->revision.unmap, sizeof(revision_t)); + output.header.size = sizeof(revision_t); output.header.target = input->header.source; Luos_SendMsg(container, &output); error = SUCCEED; @@ -258,10 +256,8 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) msg_t output; output.header.cmd = LUOS_REVISION; output.header.target_mode = ID; - const char *luos_version = STRINGIFY(VERSION); - sprintf((char *)output.data, "%s", luos_version); - memcpy(output.data, luos_version, sizeof(output.data)); - output.header.size = strlen((char *)output.data); + memcpy(output.data, &luos_version.unmap, sizeof(revision_t)); + output.header.size = sizeof(revision_t); output.header.target = input->header.source; Luos_SendMsg(container, &output); error = SUCCEED; @@ -293,7 +289,7 @@ static error_return_t Luos_MsgHandler(container_t *container, msg_t *input) output.header.size = sizeof(general_stats_t); output.header.target = input->header.source; memcpy(&general_stats.node_stat, &luos_stats.unmap, sizeof(luos_stats_t)); - memcpy(&general_stats.container_stat, &container->statistic.unmap, sizeof(container_stats_t)); + memcpy(&general_stats.container_stat, container->statistic.unmap, sizeof(container_stats_t)); memcpy(output.data, &general_stats.unmap, sizeof(general_stats_t)); Luos_SendMsg(container, &output); error = SUCCEED; @@ -458,10 +454,10 @@ void Luos_ContainersClear(void) * @param callback msg handler for the container * @param type of container corresponding to object dictionnary * @param alias for the container string (15 caracters max). - * @param version FW for the container + * @param version FW for the container (tab[MajorVersion,MinorVersion,Patch]) * @return container object pointer. ******************************************************************************/ -container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *alias, char *firm_revision) +container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *alias, revision_t revision) { uint8_t i = 0; container_t *container = &container_table[container_number]; @@ -491,18 +487,16 @@ container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *ali container->alias[i] = '\0'; } - //Initialise the container firm_version to 0 - memset((void *)container->firm_version, 0, sizeof(container->firm_version)); + //Initialise the container revision to 0 + memset((void *)container->revision.unmap, 0, sizeof(revision_t)); // Save firmware version - for (i = 0; i < 20; i++) + for (i = 0; i < sizeof(revision_t); i++) { - container->firm_version[i] = firm_revision[i]; - if (container->firm_version[i] == '\0') - break; + container->revision.unmap[i] = revision.unmap[i]; } //initiate container statistic - container->ll_container->ll_stat.max_collision_retry = &container->statistic.max_collision_retry ; + container->ll_container->ll_stat.max_collision_retry = &container->statistic.max_collision_retry; container->ll_container->ll_stat.max_nak_retry = &container->statistic.max_nak_retry; container_number++; @@ -517,16 +511,16 @@ container_t *Luos_CreateContainer(CONT_CB cont_cb, uint8_t type, const char *ali error_return_t Luos_SendMsg(container_t *container, msg_t *msg) { error_return_t result = SUCCEED; - if(Robus_SendMsg(container->ll_container, msg) != SUCCEED) + if (Robus_SendMsg(container->ll_container, msg) != SUCCEED) { container->ll_container->ll_stat.fail_msg_nbr++; result = FAILED; } container->ll_container->ll_stat.msg_nbr++; - if(container->ll_container->ll_stat.msg_nbr == 0xFF) + if (container->ll_container->ll_stat.msg_nbr == 0xFF) { - container->ll_container->ll_stat.msg_nbr = container->ll_container->ll_stat.msg_nbr>>1; + container->ll_container->ll_stat.msg_nbr = container->ll_container->ll_stat.msg_nbr >> 1; } container->statistic.msg_fail_ratio = (uint8_t)(((uint32_t)container->ll_container->ll_stat.fail_msg_nbr * 100) / container->ll_container->ll_stat.msg_nbr);