From bab3f8490645c3e97042520bedd66186397526bb Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 14:59:56 +0100 Subject: [PATCH 01/10] If a service ask a new update overwrite the update time of the existing one. --- engine/core/src/service.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/core/src/service.c b/engine/core/src/service.c index d321c0d01..d20876f7f 100644 --- a/engine/core/src/service.c +++ b/engine/core/src/service.c @@ -139,6 +139,14 @@ void Service_AddAutoUpdateTarget(service_t *service, uint16_t target, uint16_t t LUOS_ASSERT(service && (target != 0)); for (uint16_t i = 0; i < MAX_AUTO_REFRESH_NUMBER; i++) { + // If this target ask something from this service just update the value + if ((service_ctx.auto_refresh[i].service == service) && (service_ctx.auto_refresh[i].target == target)) + { + service_ctx.auto_refresh[i].time_ms = time_ms; + service_ctx.auto_refresh[i].last_update = LuosHAL_GetSystick(); + return; + } + // If this slot is empty this mean that we didn't find the target in the list, just add it. if (service_ctx.auto_refresh[i].time_ms == 0) { service_ctx.auto_refresh[i].service = service; From e35b37a1c6888c1afa0a72bc4ab95efcb9eb61f3 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 15:01:12 +0100 Subject: [PATCH 02/10] [Gate] remove useless auto-update cancelation, Luos now update it. --- tool_services/gate/TinyJSON/convert.c | 7 +------ tool_services/gate/data_manager.c | 6 ------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/tool_services/gate/TinyJSON/convert.c b/tool_services/gate/TinyJSON/convert.c index 9f491aeee..419201e73 100644 --- a/tool_services/gate/TinyJSON/convert.c +++ b/tool_services/gate/TinyJSON/convert.c @@ -543,12 +543,7 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * { if (type != GATE_TYPE) { - // remove any current updates - time = TimeOD_TimeFrom_s(0); - TimeOD_TimeToMsg(&time, &msg); - msg.header.cmd = UPDATE_PUB; - Luos_SendMsg(service, &msg); - // configure the new update value + // Configure the new update value time = TimeOD_TimeFrom_s((float)json_getReal(jobj)); TimeOD_TimeToMsg(&time, &msg); msg.header.cmd = UPDATE_PUB; diff --git a/tool_services/gate/data_manager.c b/tool_services/gate/data_manager.c index abd5e1d3f..8d311859b 100644 --- a/tool_services/gate/data_manager.c +++ b/tool_services/gate/data_manager.c @@ -49,12 +49,6 @@ void DataManager_collect(service_t *service) #endif #else // This service is a sensor so create a msg to enable auto update - // First remove any auto update - time_luos_t reset_time = {.raw = 0}; - update_msg.header.target = result.result_table[i]->id; - TimeOD_TimeToMsg(&reset_time, &update_msg); - update_msg.header.cmd = UPDATE_PUB; - Luos_SendMsg(service, &update_msg); TimeOD_TimeToMsg(&update_time, &update_msg); update_msg.header.cmd = UPDATE_PUB; From 1869edf6832a48baecaf63f6ed968471f3a343f5 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 15:02:20 +0100 Subject: [PATCH 03/10] [Gate] completely remove tempos --- tool_services/gate/gate.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tool_services/gate/gate.c b/tool_services/gate/gate.c index 030d94c82..fbe0837d1 100644 --- a/tool_services/gate/gate.c +++ b/tool_services/gate/gate.c @@ -53,10 +53,6 @@ void Gate_Init(void) ******************************************************************************/ void Gate_Loop(void) { -#ifndef GATE_POLLING - static uint32_t last_time = 0; -#endif - // Check the detection status. if (Luos_IsDetected() == false) { @@ -72,9 +68,7 @@ void Gate_Loop(void) // Manage input and output data DataManager_Run(gate); #ifndef GATE_POLLING - if ((Luos_GetSystick() - last_time >= TimeOD_TimeTo_ms(update_time)) && (Luos_GetSystick() > last_time)) { - last_time = Luos_GetSystick(); if (first_conversion == true) { // This is the first time we perform a convertion @@ -97,7 +91,6 @@ void Gate_Loop(void) DataManager_collect(gate); first_conversion = false; } - } #endif } else From 743178303281a840aeb3916536dee37522458d33 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 15:02:48 +0100 Subject: [PATCH 04/10] [Gate] remove unused polling mode of the Gate --- tool_services/gate/data_manager.c | 31 ++------------------- tool_services/gate/data_manager.h | 2 -- tool_services/gate/gate.c | 45 +++++++++++++------------------ tool_services/gate/gate_config.h | 1 - 4 files changed, 21 insertions(+), 58 deletions(-) diff --git a/tool_services/gate/data_manager.c b/tool_services/gate/data_manager.c index 8d311859b..d291ec918 100644 --- a/tool_services/gate/data_manager.c +++ b/tool_services/gate/data_manager.c @@ -18,13 +18,7 @@ void DataManager_collect(service_t *service) { msg_t update_msg; search_result_t result; -#ifdef GATE_POLLING - update_msg.header.cmd = GET_CMD; - update_msg.header.target_mode = SERVICEID; - update_msg.header.size = 0; -#else update_msg.header.target_mode = SERVICEIDACK; -#endif RTFilter_Reset(&result); // ask services to publish datas for (uint8_t i = 0; i < result.result_nbr; i++) @@ -32,28 +26,12 @@ void DataManager_collect(service_t *service) // Check if this service is a sensor if ((DataManager_ServiceIsSensor(result.result_table[i]->type)) || (result.result_table[i]->type >= LUOS_LAST_TYPE)) { -#ifdef GATE_POLLING - // This service is a sensor so create a msg and send it - update_msg.header.target = result.result_table[i]->id; - Luos_SendMsg(service, &update_msg); - #ifdef GATE_TIMEOUT - // Get the current number of message available - int back_nbr_msg = Luos_NbrAvailableMsg(); - // Get the current time - uint32_t send_time = Luos_GetSystick(); - // Wait for a reply before continuing - while ((back_nbr_msg == Luos_NbrAvailableMsg()) & (send_time == Luos_GetSystick())) - { - Luos_Loop(); - } - #endif -#else // This service is a sensor so create a msg to enable auto update + update_msg.header.target = result.result_table[i]->id; TimeOD_TimeToMsg(&update_time, &update_msg); update_msg.header.cmd = UPDATE_PUB; Luos_SendMsg(service, &update_msg); -#endif } } } @@ -61,9 +39,6 @@ void DataManager_collect(service_t *service) // This function manage entirely data conversion void DataManager_Run(service_t *service) { -#ifdef GATE_POLLING - DataManager_collect(service); -#endif DataManager_Format(service); } // This function manage only commands incoming from pipe @@ -103,10 +78,8 @@ void DataManager_RunPipeOnly(service_t *service) // Generate routing table datas Convert_RoutingTableData(service); // Run the gate - gate_running = RUNNING; -#ifndef GATE_POLLING + gate_running = RUNNING; first_conversion = true; -#endif } } } diff --git a/tool_services/gate/data_manager.h b/tool_services/gate/data_manager.h index f0c62a3c7..e901a1412 100644 --- a/tool_services/gate/data_manager.h +++ b/tool_services/gate/data_manager.h @@ -24,9 +24,7 @@ typedef enum ******************************************************************************/ extern time_luos_t update_time; extern volatile gate_state_t gate_running; -#ifndef GATE_POLLING extern volatile bool first_conversion; -#endif /******************************************************************************* * Function diff --git a/tool_services/gate/gate.c b/tool_services/gate/gate.c index fbe0837d1..4d48d8407 100644 --- a/tool_services/gate/gate.c +++ b/tool_services/gate/gate.c @@ -21,9 +21,7 @@ ******************************************************************************/ service_t *gate; volatile gate_state_t gate_running = NOT_RUNNING; -#ifndef GATE_POLLING -volatile bool first_conversion = false; -#endif +volatile bool first_conversion = false; time_luos_t update_time = {GATE_REFRESH_TIME_S}; /******************************************************************************* @@ -56,9 +54,7 @@ void Gate_Loop(void) // Check the detection status. if (Luos_IsDetected() == false) { -#ifndef GATE_POLLING update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S); -#endif } else { @@ -67,31 +63,28 @@ void Gate_Loop(void) { // Manage input and output data DataManager_Run(gate); -#ifndef GATE_POLLING + if (first_conversion == true) { - if (first_conversion == true) + // This is the first time we perform a convertion +#ifdef GATE_REFRESH_AUTOSCALE + // Evaluate the time needed to convert all the data of this configuration and update refresh rate + search_result_t result; + RTFilter_Reset(&result); + // find the biggest id + if (result.result_table[result.result_nbr - 1]->id) + { + // update time is related to the biggest id + update_time = TimeOD_TimeFrom_s((float)result.result_table[result.result_nbr - 1]->id * 0.001); + } + else { - // This is the first time we perform a convertion - #ifdef GATE_REFRESH_AUTOSCALE - // Evaluate the time needed to convert all the data of this configuration and update refresh rate - search_result_t result; - RTFilter_Reset(&result); - // find the biggest id - if (result.result_table[result.result_nbr - 1]->id) - { - // update time is related to the biggest id - update_time = TimeOD_TimeFrom_s((float)result.result_table[result.result_nbr - 1]->id * 0.001); - } - else - { - update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S); - } - #endif - // Update refresh rate for all services of the network - DataManager_collect(gate); - first_conversion = false; + update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S); } #endif + // Update refresh rate for all services of the network + DataManager_collect(gate); + first_conversion = false; + } } else { diff --git a/tool_services/gate/gate_config.h b/tool_services/gate/gate_config.h index d2f064146..e7ba84c3f 100644 --- a/tool_services/gate/gate_config.h +++ b/tool_services/gate/gate_config.h @@ -14,7 +14,6 @@ * Define | Description * :-----------------------|----------------------------------------------- * GATE_BUFF_SIZE | Formatted Data Buffer. Max size of 1 msg - * GATE_POLLING | No autorefresh always ask data (more intensive to Luos bandwidth.) * NODETECTION | Gate not perform a network detection a power up * GATE_REFRESH_TIME_S | Default refresh Gate recalculate optimal rate at first command * INIT_TIME | Delay before first detection, to verify that all boards are connected From fb4b1f849b7ef11638edfce2884aefa35f1d3749 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 15:16:11 +0100 Subject: [PATCH 05/10] [Gate] remove the GATE_REFRESH_AUTOSCALE use default value at 20Hz instead --- tool_services/gate/gate.c | 15 --------------- tool_services/gate/gate_config.h | 1 - 2 files changed, 16 deletions(-) diff --git a/tool_services/gate/gate.c b/tool_services/gate/gate.c index 4d48d8407..88c8fa38e 100644 --- a/tool_services/gate/gate.c +++ b/tool_services/gate/gate.c @@ -66,21 +66,6 @@ void Gate_Loop(void) if (first_conversion == true) { // This is the first time we perform a convertion -#ifdef GATE_REFRESH_AUTOSCALE - // Evaluate the time needed to convert all the data of this configuration and update refresh rate - search_result_t result; - RTFilter_Reset(&result); - // find the biggest id - if (result.result_table[result.result_nbr - 1]->id) - { - // update time is related to the biggest id - update_time = TimeOD_TimeFrom_s((float)result.result_table[result.result_nbr - 1]->id * 0.001); - } - else - { - update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S); - } -#endif // Update refresh rate for all services of the network DataManager_collect(gate); first_conversion = false; diff --git a/tool_services/gate/gate_config.h b/tool_services/gate/gate_config.h index e7ba84c3f..05f0cfbba 100644 --- a/tool_services/gate/gate_config.h +++ b/tool_services/gate/gate_config.h @@ -29,7 +29,6 @@ #ifndef GATE_REFRESH_TIME_S #define GATE_REFRESH_TIME_S 0.05f - #define GATE_REFRESH_AUTOSCALE #endif #endif /* GATE_CONFIG_H */ From 8ad7fe258e0c7bbf845582eb75e38176b6f5fc79 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 18:26:29 +0100 Subject: [PATCH 06/10] [Gate] Switch gate into an event based management --- .../custom_gate/src/custom_json_conversion.c | 2 +- tool_services/gate/TinyJSON/bootloader_ex.c | 2 +- tool_services/gate/TinyJSON/bootloader_ex.h | 2 +- tool_services/gate/TinyJSON/convert.c | 10 +- tool_services/gate/TinyJSON/custom-json.h | 2 +- tool_services/gate/convert.h | 2 +- tool_services/gate/data_manager.c | 302 ++++++------------ tool_services/gate/data_manager.h | 4 +- tool_services/gate/gate.c | 33 +- 9 files changed, 129 insertions(+), 230 deletions(-) diff --git a/examples/projects/product/custom_gate/src/custom_json_conversion.c b/examples/projects/product/custom_gate/src/custom_json_conversion.c index 6b749be8a..4170c9316 100644 --- a/examples/projects/product/custom_gate/src/custom_json_conversion.c +++ b/examples/projects/product/custom_gate/src/custom_json_conversion.c @@ -92,7 +92,7 @@ void Convert_CustomJsonToMsg(service_t *service, uint16_t target_id, char *prope // This function is called by the gate to convert a message into a piece of Json. // This is typically used when a message is received by the gate with an unknown command. // You can use it to compose your own piece of Json out of the message data. -void Convert_CustomMsgToJson(msg_t *msg, char *data) +void Convert_CustomMsgToJson(const msg_t *msg, char *data) { if (msg->header.cmd == LINEAR_POSITION_2D) { diff --git a/tool_services/gate/TinyJSON/bootloader_ex.c b/tool_services/gate/TinyJSON/bootloader_ex.c index b088208db..7f0620797 100644 --- a/tool_services/gate/TinyJSON/bootloader_ex.c +++ b/tool_services/gate/TinyJSON/bootloader_ex.c @@ -39,7 +39,7 @@ uint16_t Bootloader_StartData(char *data) * @param service pointer, luos message * @return None ******************************************************************************/ -uint16_t Bootloader_LuosToJson(msg_t *msg, char *data) +uint16_t Bootloader_LuosToJson(const msg_t *msg, char *data) { uint16_t response_cmd = msg->header.cmd; uint16_t node_id = RoutingTB_NodeIDFromID(msg->header.source); diff --git a/tool_services/gate/TinyJSON/bootloader_ex.h b/tool_services/gate/TinyJSON/bootloader_ex.h index fe5531d51..724fb9566 100644 --- a/tool_services/gate/TinyJSON/bootloader_ex.h +++ b/tool_services/gate/TinyJSON/bootloader_ex.h @@ -20,7 +20,7 @@ /******************************************************************************* * Function ******************************************************************************/ -uint16_t Bootloader_LuosToJson(msg_t *, char *); +uint16_t Bootloader_LuosToJson(const msg_t *, char *); void Bootloader_JsonToLuos(service_t *, char *, json_t const *); uint16_t Bootloader_StartData(char *); void Bootloader_EndData(service_t *, char *, char *); diff --git a/tool_services/gate/TinyJSON/convert.c b/tool_services/gate/TinyJSON/convert.c index 419201e73..206da2809 100644 --- a/tool_services/gate/TinyJSON/convert.c +++ b/tool_services/gate/TinyJSON/convert.c @@ -45,7 +45,7 @@ __attribute__((weak)) void Convert_CustomJsonToMsg(service_t *service, uint16_t * @param None * @return None ******************************************************************************/ -__attribute__((weak)) void Convert_CustomMsgToJson(msg_t *msg, char *data) +__attribute__((weak)) void Convert_CustomMsgToJson(const msg_t *msg, char *data) { return; } @@ -741,7 +741,7 @@ uint16_t Convert_StartServiceData(char *data, char *alias) return (uint16_t)strlen(data); } // This function create the Json content from a message and return the string size. -uint16_t Convert_MsgToData(msg_t *msg, char *data) +uint16_t Convert_MsgToData(const msg_t *msg, char *data) { float fdata; switch (msg->header.cmd) @@ -1081,12 +1081,6 @@ void Convert_RoutingTableData(service_t *service) *(--json_ptr) = '\0'; // End the Json message sprintf(json_ptr, "]}\n"); - // Run loop before to flush residual msg on the pipe - Luos_Loop(); - // reset all the msg in pipe link - PipeLink_Reset(service); - // call Luos loop to generap a Luos Task with this msg - Luos_Loop(); // Send the message to pipe PipeLink_Send(service, json, strlen(json)); } diff --git a/tool_services/gate/TinyJSON/custom-json.h b/tool_services/gate/TinyJSON/custom-json.h index 91c102398..280979b52 100644 --- a/tool_services/gate/TinyJSON/custom-json.h +++ b/tool_services/gate/TinyJSON/custom-json.h @@ -9,5 +9,5 @@ #include "luos_engine.h" void Convert_CustomJsonToMsg(service_t *service, uint16_t target_id, char *property, const json_t *jobj, char *json_str); -void Convert_CustomMsgToJson(msg_t *msg, char *data); +void Convert_CustomMsgToJson(const msg_t *msg, char *data); const char *Convert_CustomStringFromType(luos_type_t type); diff --git a/tool_services/gate/convert.h b/tool_services/gate/convert.h index 600bf53a1..73c8d1cbb 100644 --- a/tool_services/gate/convert.h +++ b/tool_services/gate/convert.h @@ -31,7 +31,7 @@ void Convert_DataToMsg(service_t *service, char *data); // Luos service information to Data convertion uint16_t Convert_StartData(char *data); uint16_t Convert_StartServiceData(char *data, char *alias); -uint16_t Convert_MsgToData(msg_t *msg, char *data); +uint16_t Convert_MsgToData(const msg_t *msg, char *data); uint16_t Convert_EndServiceData(char *data); void Convert_EndData(service_t *service, char *data, char *data_ptr); void Convert_VoidData(service_t *service); diff --git a/tool_services/gate/data_manager.c b/tool_services/gate/data_manager.c index d291ec918..1974265dd 100644 --- a/tool_services/gate/data_manager.c +++ b/tool_services/gate/data_manager.c @@ -10,7 +10,6 @@ #include "pipe_link.h" #include "bootloader_ex.h" -static void DataManager_Format(service_t *service); uint8_t DataManager_ServiceIsSensor(luos_type_t type); // This function will manage msg collection from sensors @@ -36,239 +35,122 @@ void DataManager_collect(service_t *service) } } -// This function manage entirely data conversion -void DataManager_Run(service_t *service) -{ - DataManager_Format(service); -} -// This function manage only commands incoming from pipe -void DataManager_RunPipeOnly(service_t *service) +// This function will create a data string for services datas +void DataManager_Run(service_t *service, const msg_t *data_msg) { - msg_t data_msg; - if (PipeLink_GetId() != 0) + char data[GATE_BUFF_SIZE]; + search_result_t result; + luos_assert_t assertion; + dead_target_t *dead_target; + char *data_ptr = data; + + // Init the data string + data_ptr += Convert_StartData(data_ptr); + switch (data_msg->header.cmd) { - while (Luos_ReadFromService(service, PipeLink_GetId(), &data_msg) == SUCCEED) - { - // This message is a command from pipe - // Convert the received data into Luos commands - static char data_cmd[GATE_BUFF_SIZE]; - if (data_msg.header.cmd == PARAMETERS) + case ASSERT: + memcpy(assertion.unmap, data_msg->data, data_msg->header.size); + assertion.unmap[data_msg->header.size] = '\0'; + Convert_AssertToData(service, data_msg->header.source, assertion); + break; + + case DEADTARGET: + dead_target = (dead_target_t *)data_msg->data; + if (dead_target->node_id != 0) { - uintptr_t pointer; - memcpy(&pointer, data_msg.data, sizeof(void *)); - PipeLink_SetDirectPipeSend((void *)pointer); - continue; + Convert_DeadNodeToData(service, dead_target->node_id); } - if (Luos_ReceiveData(service, &data_msg, data_cmd) > 0) + if (dead_target->service_id != 0) { - // We finish to receive this data, execute the received command - Convert_DataToMsg(service, data_cmd); + Convert_DeadServiceToData(service, dead_target->service_id); } - } - } - if (Luos_ReadMsg(service, &data_msg) == SUCCEED) - { - // Check if a node send a end detection - if (data_msg.header.cmd == END_DETECTION) - { - // Find a pipe + break; + case BOOTLOADER_START ... BOOTLOADER_ERROR_SIZE: + data_ptr = data; + data_ptr += Bootloader_StartData(data_ptr); + data_ptr += Bootloader_LuosToJson(data_msg, data_ptr); + Bootloader_EndData(service, data, data_ptr); + return; + break; + case END_DETECTION: + // find a pipe PipeLink_Find(service); - if (gate_running == PREPARING) - { - // Generate routing table datas - Convert_RoutingTableData(service); - // Run the gate - gate_running = RUNNING; - first_conversion = true; - } - } - } -} + break; -// This function will create a data string for services datas -void DataManager_Format(service_t *service) -{ - char data[GATE_BUFF_SIZE]; - char boot_data[GATE_BUFF_SIZE]; - msg_t data_msg; - search_result_t result; - static uint32_t FirstNoReceptionDate = 0; - static uint32_t LastVoidMsg = 0; - char *data_ptr = data; - char *boot_data_ptr = boot_data; - uint8_t data_ok = false; - uint8_t boot_data_ok = false; - - RTFilter_Reset(&result); - - if ((Luos_NbrAvailableMsg() > 0)) - { - // Init the data string - data_ptr += Convert_StartData(data_ptr); - boot_data_ptr += Bootloader_StartData(boot_data_ptr); - // loop into services. - int i = 0; - while (i < result.result_nbr) - { - if (Luos_ReadFromService(service, result.result_table[i]->id, &data_msg) == SUCCEED) + default: + // Check if this is a message from pipe + if (data_msg->header.source == PipeLink_GetId()) { - // check if this is an assert - if (data_msg.header.cmd == ASSERT) - { - luos_assert_t assertion; - memcpy(assertion.unmap, data_msg.data, data_msg.header.size); - assertion.unmap[data_msg.header.size] = '\0'; - Convert_AssertToData(service, data_msg.header.source, assertion); - i++; - continue; - } - if (data_msg.header.cmd == DEADTARGET) - { - dead_target_t *dead_target = (dead_target_t *)data_msg.data; - if (dead_target->node_id != 0) - { - Convert_DeadNodeToData(service, dead_target->node_id); - } - if (dead_target->service_id != 0) - { - Convert_DeadServiceToData(service, dead_target->service_id); - } - continue; - } - // check if a node send a bootloader message - if (data_msg.header.cmd >= BOOTLOADER_START && data_msg.header.cmd <= BOOTLOADER_ERROR_SIZE) - { - do - { - boot_data_ptr += Bootloader_LuosToJson(&data_msg, boot_data_ptr); - } while (Luos_ReadFromService(service, data_msg.header.source, &data_msg) == SUCCEED); - boot_data_ok = true; - i++; - continue; - } - // check if a node send a end detection - if (data_msg.header.cmd == END_DETECTION) + // This message is a command from pipe + static char data_cmd[GATE_BUFF_SIZE]; + // Convert the received data into Luos commands + int size = Luos_ReceiveData(service, data_msg, data_cmd); + if (size > 0) { - // find a pipe - PipeLink_Find(service); - i++; - continue; - } - // Check if this is a message from pipe - if (data_msg.header.source == PipeLink_GetId()) - { - do + // We finish to receive this data, execute the received command + char *data_ptr = data_cmd; + if (data_msg->header.cmd == SET_CMD) { - // This message is a command from pipe - static char data_cmd[GATE_BUFF_SIZE]; - // Convert the received data into Luos commands - int size = Luos_ReceiveData(service, &data_msg, data_cmd); - if (size > 0) + while (size > 0 && *data_ptr == '{') { - // We finish to receive this data, execute the received command - char *data_ptr = data_cmd; - if (data_msg.header.cmd == SET_CMD) - { - while (size > 0 && *data_ptr == '{') - { - uint32_t data_consumed = strlen(data_ptr) + 1; - Convert_DataToMsg(service, data_ptr); - size -= data_consumed; - data_ptr += data_consumed; - } - } + uint32_t data_consumed = strlen(data_ptr) + 1; + Convert_DataToMsg(service, data_ptr); + size -= data_consumed; + data_ptr += data_consumed; } - } while (Luos_ReadFromService(service, PipeLink_GetId(), &data_msg) == SUCCEED); - i++; - continue; - } - // get the source of this message - // Create service description - char *alias; - alias = result.result_table[i]->alias; - LUOS_ASSERT(alias != 0); - data_ok = true; - data_ptr += Convert_StartServiceData(data_ptr, alias); - // Convert all msgs from this service into data - do - { - data_ptr += Convert_MsgToData(&data_msg, data_ptr); - } while (Luos_ReadFromService(service, data_msg.header.source, &data_msg) == SUCCEED); - - data_ptr += Convert_EndServiceData(data_ptr); - LUOS_ASSERT((data_ptr - data) < GATE_BUFF_SIZE); - } - i++; - } - if (Luos_NbrAvailableMsg() != 0) - { - // We still have messages.This could be because we received some during the execution of the last loop.Or this could be because the gate have been excluded from the routing table, let's try to catch some message for the Gate service. - // Luos_ReadFromService(service, BROADCAST_VAL, &data_msg); - if (Luos_ReadFromCmd(service, DEADTARGET, &data_msg) == SUCCEED) - { - dead_target_t *dead_target = (dead_target_t *)data_msg.data; - if (dead_target->node_id != 0) - { - Convert_DeadNodeToData(service, dead_target->node_id); - } - if (dead_target->service_id != 0) - { - if (dead_target->service_id == service->id) - { - // This is the exclusion of our Gate service! - // This mean that the gate is not able to communicate with anything anymore and looks like dead. - // To avoid it we will remake the detection. - Luos_Detect(service); - } - else - { - Convert_DeadServiceToData(service, dead_target->service_id); } } + break; } - } - if (data_ok) - { + // get the source of this message + // Create service description + char *alias; + RTFilter_Reset(&result); + RTFilter_ID(&result, data_msg->header.source); + alias = result.result_table[0]->alias; + LUOS_ASSERT(alias != 0); + data_ptr += Convert_StartServiceData(data_ptr, alias); + // Convert all msgs from this service into data + data_ptr += Convert_MsgToData(data_msg, data_ptr); + data_ptr += Convert_EndServiceData(data_ptr); Convert_EndData(service, data, data_ptr); - FirstNoReceptionDate = 0; - } - else if (boot_data_ok) + LUOS_ASSERT((data_ptr - data) < GATE_BUFF_SIZE); + break; + } +} + +// This function manage only commands incoming from pipe +void DataManager_RunPipeOnly(service_t *service, const msg_t *data_msg) +{ + if ((PipeLink_GetId() != 0) && (data_msg->header.source == PipeLink_GetId())) + { + // This message is a command from pipe + // Convert the received data into Luos commands + static char data_cmd[GATE_BUFF_SIZE]; + if (data_msg->header.cmd == PARAMETERS) { - Bootloader_EndData(service, boot_data, boot_data_ptr); + uintptr_t pointer; + memcpy(&pointer, data_msg->data, sizeof(void *)); + PipeLink_SetDirectPipeSend((void *)pointer); } - else + else if (Luos_ReceiveData(service, data_msg, data_cmd) > 0) { - // We don't receive anything. - // After 1s void reception send void data allowing client to send commands (because client could be synchronized to reception). - if (FirstNoReceptionDate == 0) - { - FirstNoReceptionDate = Luos_GetSystick(); - } - else if ((Luos_GetSystick() - FirstNoReceptionDate) > 1000) - { - if ((Luos_GetSystick() - LastVoidMsg) > 10) - { - LastVoidMsg = Luos_GetSystick(); - Convert_VoidData(service); - } - } + // We finish to receive this data, execute the received command + Convert_DataToMsg(service, data_cmd); } } - else + // Check if a node send a end detection + if (data_msg->header.cmd == END_DETECTION) { - // We don't receive anything. - // After 1s void reception send void data allowing client to send commands (because client could be synchronized to reception). - if (FirstNoReceptionDate == 0) + // Find a pipe + PipeLink_Find(service); + if (gate_running == PREPARING) { - FirstNoReceptionDate = Luos_GetSystick(); - } - else if (Luos_GetSystick() - FirstNoReceptionDate > 1000) - { - if ((Luos_GetSystick() - LastVoidMsg) > 10) - { - LastVoidMsg = Luos_GetSystick(); - Convert_VoidData(service); - } + // Generate routing table datas + Convert_RoutingTableData(service); + // Run the gate + gate_running = RUNNING; + first_conversion = true; } } } diff --git a/tool_services/gate/data_manager.h b/tool_services/gate/data_manager.h index e901a1412..0b119e088 100644 --- a/tool_services/gate/data_manager.h +++ b/tool_services/gate/data_manager.h @@ -34,9 +34,9 @@ extern volatile bool first_conversion; void DataManager_collect(service_t *service); // This function manage entirely data conversion -void DataManager_Run(service_t *service); +void DataManager_Run(service_t *service, const msg_t *data_msg); // This function manage only commande incoming from pipe -void DataManager_RunPipeOnly(service_t *service); +void DataManager_RunPipeOnly(service_t *service, const msg_t *data_msg); #endif /* DATA_MNGR_H */ diff --git a/tool_services/gate/gate.c b/tool_services/gate/gate.c index 88c8fa38e..a8f4b20d2 100644 --- a/tool_services/gate/gate.c +++ b/tool_services/gate/gate.c @@ -15,6 +15,7 @@ /******************************************************************************* * Definitions ******************************************************************************/ +static void Gate_msgHandler(service_t *service, const msg_t *msg); /******************************************************************************* * Variables @@ -22,6 +23,7 @@ service_t *gate; volatile gate_state_t gate_running = NOT_RUNNING; volatile bool first_conversion = false; +uint32_t LastReceptionDate = 0; time_luos_t update_time = {GATE_REFRESH_TIME_S}; /******************************************************************************* @@ -35,7 +37,7 @@ time_luos_t update_time = {GATE_REFRESH_TIME_S}; void Gate_Init(void) { revision_t revision = {.major = 2, .minor = 0, .build = 0}; - gate = Luos_CreateService(0, GATE_TYPE, "gate", revision); + gate = Luos_CreateService(Gate_msgHandler, GATE_TYPE, "gate", revision); #ifndef NODETECTION uint32_t init_timer = Luos_GetSystick(); while (Luos_GetSystick() - init_timer < INIT_TIME) @@ -50,30 +52,51 @@ void Gate_Init(void) * @return None ******************************************************************************/ void Gate_Loop(void) +{ + static uint32_t LastVoidMsg = 0; + // We don't receive anything. + // After 1s void reception send void data allowing client to send commands (because client could be synchronized to reception). + if (LastReceptionDate == 0) + { + LastReceptionDate = Luos_GetSystick(); + } + else if ((Luos_GetSystick() - LastReceptionDate > 1000) && (gate_running == RUNNING)) + { + if ((Luos_GetSystick() - LastVoidMsg) > TimeOD_TimeTo_ms(update_time)) + { + LastVoidMsg = Luos_GetSystick(); + Convert_VoidData(gate); + } + } +} + +void Gate_msgHandler(service_t *service, const msg_t *msg) { // Check the detection status. if (Luos_IsDetected() == false) { - update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S); + update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S); + LastReceptionDate = 0; } else { // Network have been detected, We are good to go + LastReceptionDate = Luos_GetSystick(); if (gate_running == RUNNING) { // Manage input and output data - DataManager_Run(gate); + DataManager_Run(service, msg); if (first_conversion == true) { // This is the first time we perform a convertion // Update refresh rate for all services of the network - DataManager_collect(gate); + DataManager_collect(service); first_conversion = false; } } else { - DataManager_RunPipeOnly(gate); + DataManager_RunPipeOnly(service, msg); } } } From f5ca3178c8766980fcf37ad392d77996b3339257 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 18:27:04 +0100 Subject: [PATCH 07/10] [Gate] reduce the size of Json start to optimize --- tool_services/gate/TinyJSON/convert.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tool_services/gate/TinyJSON/convert.c b/tool_services/gate/TinyJSON/convert.c index 206da2809..7a2dad13f 100644 --- a/tool_services/gate/TinyJSON/convert.c +++ b/tool_services/gate/TinyJSON/convert.c @@ -132,7 +132,7 @@ void Convert_DataToMsg(service_t *service, char *data) return; } - json_t const *services = json_getProperty(root, "services"); + json_t const *services = json_getProperty(root, "s"); // Get services if (services != 0) { @@ -731,8 +731,8 @@ void Convert_JsonToMsg(service_t *service, uint16_t id, luos_type_t type, char * // This function start a Json structure and return the string size. uint16_t Convert_StartData(char *data) { - memcpy(data, "{\"services\":{", sizeof("{\"services\":{")); - return (sizeof("{\"services\":{") - 1); + memcpy(data, "{\"s\":{", sizeof("{\"s\":{")); + return (sizeof("{\"s\":{") - 1); } // This function start a Service into a Json structure and return the string size. uint16_t Convert_StartServiceData(char *data, char *alias) From d03b7f3eb4779275210167a0d110472ece2d6607 Mon Sep 17 00:00:00 2001 From: Nicolas Rabault Date: Fri, 22 Mar 2024 18:27:34 +0100 Subject: [PATCH 08/10] [Pipe] Increase default serial baudrate to 3000000 Baud --- tool_services/pipe/_pipe.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool_services/pipe/_pipe.h b/tool_services/pipe/_pipe.h index 09948448a..f0e86c15f 100644 --- a/tool_services/pipe/_pipe.h +++ b/tool_services/pipe/_pipe.h @@ -10,7 +10,7 @@ * Definitions ******************************************************************************/ #ifndef PIPE_SERIAL_BAUDRATE - #define PIPE_SERIAL_BAUDRATE 1000000 + #define PIPE_SERIAL_BAUDRATE 3000000 #endif #ifndef PIPE_TX_BUFFER_SIZE #define PIPE_TX_BUFFER_SIZE 1024 @@ -29,4 +29,4 @@ * Function ******************************************************************************/ streaming_channel_t *Pipe_GetTxStreamChannel(void); -streaming_channel_t *Pipe_GetRxStreamChannel(void); \ No newline at end of file +streaming_channel_t *Pipe_GetRxStreamChannel(void); From 8c199af4fc84062f7896560e97c22596d6ada921 Mon Sep 17 00:00:00 2001 From: Maxime COZZI Date: Mon, 6 May 2024 16:27:36 +0200 Subject: [PATCH 09/10] fix timeout management on ROBUS protocol --- network/robus_network/HAL/STM32G4/robus_hal.c | 37 +++++++++++++------ network/robus_network/HAL/STM32G4/robus_hal.h | 2 +- network/robus_network/src/reception.c | 2 +- network/robus_network/src/transmission.c | 2 +- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/network/robus_network/HAL/STM32G4/robus_hal.c b/network/robus_network/HAL/STM32G4/robus_hal.c index 6ddc0b427..956920053 100644 --- a/network/robus_network/HAL/STM32G4/robus_hal.c +++ b/network/robus_network/HAL/STM32G4/robus_hal.c @@ -198,7 +198,7 @@ _CRITICAL void RobusHAL_SetRxState(uint8_t Enable) _CRITICAL void ROBUS_COM_IRQHANDLER() { // Reset timeout to it's default value - RobusHAL_ResetTimeout(DEFAULT_TIMEOUT); + RobusHAL_ResetTimeout(true, 0); // reception management if ((LL_USART_IsActiveFlag_RXNE(ROBUS_COM) != RESET) && (LL_USART_IsEnabledIT_RXNE(ROBUS_COM) != RESET)) { @@ -305,7 +305,7 @@ _CRITICAL void RobusHAL_ComTransmit(uint8_t *data, uint16_t size) // Enable Transmission complete interrupt because we only have one. LL_USART_EnableIT_TC(ROBUS_COM); } - RobusHAL_ResetTimeout(DEFAULT_TIMEOUT); + RobusHAL_ResetTimeout(true, 0); } /****************************************************************************** * @brief set state of Txlock detection pin @@ -339,7 +339,7 @@ _CRITICAL uint8_t RobusHAL_GetTxLockState(void) #ifdef USART_ISR_BUSY if (LL_USART_IsActiveFlag_BUSY(ROBUS_COM) == true) { - RobusHAL_ResetTimeout(DEFAULT_TIMEOUT); + RobusHAL_ResetTimeout(true, 0); result = true; } #else @@ -353,7 +353,7 @@ _CRITICAL uint8_t RobusHAL_GetTxLockState(void) { if (result == true) { - RobusHAL_ResetTimeout(DEFAULT_TIMEOUT); + RobusHAL_ResetTimeout(true, 0); } } } @@ -388,15 +388,28 @@ static void RobusHAL_TimeoutInit(void) * @param None * @return None ******************************************************************************/ -_CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) +_CRITICAL void RobusHAL_ResetTimeout(uint16_t enable, uint16_t nbrbit) { - LL_TIM_DisableCounter(ROBUS_TIMER); - NVIC_ClearPendingIRQ(ROBUS_TIMER_IRQ); // Clear IT pending NVIC - LL_TIM_ClearFlag_UPDATE(ROBUS_TIMER); - LL_TIM_SetCounter(ROBUS_TIMER, 0); // Reset counter - if (nbrbit != 0) - { + uint32_t arr_val, diff; + arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value + diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout + + if( diff < DEFAULT_TIMEOUT ){ + // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, SET); + LL_TIM_DisableCounter(ROBUS_TIMER); + NVIC_ClearPendingIRQ(ROBUS_TIMER_IRQ); // Clear IT pending NVIC + LL_TIM_ClearFlag_UPDATE(ROBUS_TIMER); + + LL_TIM_SetAutoReload(ROBUS_TIMER, DEFAULT_TIMEOUT); + LL_TIM_SetCounter(ROBUS_TIMER, 0); + // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, RESET); + } + if(nbrbit != 0){ LL_TIM_SetAutoReload(ROBUS_TIMER, nbrbit); // reload value + LL_TIM_SetCounter(ROBUS_TIMER, 0); // Reset counter + } + + if(enable){ LL_TIM_EnableCounter(ROBUS_TIMER); } } @@ -544,7 +557,7 @@ _CRITICAL void PINOUT_IRQHANDLER(uint16_t GPIO_Pin) if ((GPIO_Pin == TX_LOCK_DETECT_PIN) && (TX_LOCK_DETECT_IRQ != DISABLE)) { ctx.tx.lock = true; - RobusHAL_ResetTimeout(DEFAULT_TIMEOUT); + RobusHAL_ResetTimeout(true, 0); EXTI->IMR1 &= ~TX_LOCK_DETECT_PIN; } else diff --git a/network/robus_network/HAL/STM32G4/robus_hal.h b/network/robus_network/HAL/STM32G4/robus_hal.h index 192085d38..22f2dfd88 100644 --- a/network/robus_network/HAL/STM32G4/robus_hal.h +++ b/network/robus_network/HAL/STM32G4/robus_hal.h @@ -22,7 +22,7 @@ void RobusHAL_SetRxState(uint8_t Enable); void RobusHAL_ComTransmit(uint8_t *data, uint16_t size); uint8_t RobusHAL_GetTxLockState(void); void RobusHAL_SetRxDetecPin(uint8_t Enable); -void RobusHAL_ResetTimeout(uint16_t nbrbit); +void RobusHAL_ResetTimeout(uint16_t enable, uint16_t nbrbit); void RobusHAL_SetPTPDefaultState(uint8_t PTPNbr); void RobusHAL_SetPTPReverseState(uint8_t PTPNbr); void RobusHAL_PushPTP(uint8_t PTPNbr); diff --git a/network/robus_network/src/reception.c b/network/robus_network/src/reception.c index 473479e6a..27abfaef4 100644 --- a/network/robus_network/src/reception.c +++ b/network/robus_network/src/reception.c @@ -243,7 +243,7 @@ _CRITICAL void Recep_GetCollision(luos_phy_t *phy_robus, volatile uint8_t *data) // Collision detection end data_count = 0; RobusHAL_SetRxState(false); - RobusHAL_ResetTimeout(0); + RobusHAL_ResetTimeout(false, 0); if (ctx.tx.status == TX_NOK) { // Switch to catch Ack. diff --git a/network/robus_network/src/transmission.c b/network/robus_network/src/transmission.c index eae2bfa7e..8d623f380 100644 --- a/network/robus_network/src/transmission.c +++ b/network/robus_network/src/transmission.c @@ -256,7 +256,7 @@ _CRITICAL void Transmit_End(void) // A tx_task failed nbrRetry++; // compute a delay before retry - RobusHAL_ResetTimeout(20 * nbrRetry * (Phy_GetNodeId() + 1)); + RobusHAL_ResetTimeout(true, 20 * nbrRetry * (Phy_GetNodeId() + 1)); // Lock the trasmission to be sure no one can send something from this node until next timeout. ctx.tx.lock = true; ctx.tx.status = TX_DISABLE; From 1e8c300c15731da967e7f6c1b3e3b288fbc23355 Mon Sep 17 00:00:00 2001 From: Maxime COZZI Date: Tue, 14 May 2024 10:58:06 +0200 Subject: [PATCH 10/10] remove boolen from RobusHAL_ResetTimeout() arguments and cleanup code --- network/robus_network/HAL/STM32G4/robus_hal.c | 27 ++++++++----------- network/robus_network/HAL/STM32G4/robus_hal.h | 2 +- network/robus_network/src/reception.c | 2 +- network/robus_network/src/transmission.c | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/network/robus_network/HAL/STM32G4/robus_hal.c b/network/robus_network/HAL/STM32G4/robus_hal.c index 956920053..c3d0fd34d 100644 --- a/network/robus_network/HAL/STM32G4/robus_hal.c +++ b/network/robus_network/HAL/STM32G4/robus_hal.c @@ -198,7 +198,7 @@ _CRITICAL void RobusHAL_SetRxState(uint8_t Enable) _CRITICAL void ROBUS_COM_IRQHANDLER() { // Reset timeout to it's default value - RobusHAL_ResetTimeout(true, 0); + RobusHAL_ResetTimeout(DEFAULT_TIMEOUT); // reception management if ((LL_USART_IsActiveFlag_RXNE(ROBUS_COM) != RESET) && (LL_USART_IsEnabledIT_RXNE(ROBUS_COM) != RESET)) { @@ -305,7 +305,7 @@ _CRITICAL void RobusHAL_ComTransmit(uint8_t *data, uint16_t size) // Enable Transmission complete interrupt because we only have one. LL_USART_EnableIT_TC(ROBUS_COM); } - RobusHAL_ResetTimeout(true, 0); + RobusHAL_ResetTimeout(0); } /****************************************************************************** * @brief set state of Txlock detection pin @@ -339,7 +339,7 @@ _CRITICAL uint8_t RobusHAL_GetTxLockState(void) #ifdef USART_ISR_BUSY if (LL_USART_IsActiveFlag_BUSY(ROBUS_COM) == true) { - RobusHAL_ResetTimeout(true, 0); + RobusHAL_ResetTimeout(0); result = true; } #else @@ -353,7 +353,7 @@ _CRITICAL uint8_t RobusHAL_GetTxLockState(void) { if (result == true) { - RobusHAL_ResetTimeout(true, 0); + RobusHAL_ResetTimeout(0); } } } @@ -388,28 +388,23 @@ static void RobusHAL_TimeoutInit(void) * @param None * @return None ******************************************************************************/ -_CRITICAL void RobusHAL_ResetTimeout(uint16_t enable, uint16_t nbrbit) +_CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) { uint32_t arr_val, diff; - arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value - diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout + arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value + diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout if( diff < DEFAULT_TIMEOUT ){ - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, SET); LL_TIM_DisableCounter(ROBUS_TIMER); - NVIC_ClearPendingIRQ(ROBUS_TIMER_IRQ); // Clear IT pending NVIC + NVIC_ClearPendingIRQ(ROBUS_TIMER_IRQ); LL_TIM_ClearFlag_UPDATE(ROBUS_TIMER); LL_TIM_SetAutoReload(ROBUS_TIMER, DEFAULT_TIMEOUT); LL_TIM_SetCounter(ROBUS_TIMER, 0); - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, RESET); } if(nbrbit != 0){ - LL_TIM_SetAutoReload(ROBUS_TIMER, nbrbit); // reload value - LL_TIM_SetCounter(ROBUS_TIMER, 0); // Reset counter - } - - if(enable){ + LL_TIM_SetAutoReload(ROBUS_TIMER, nbrbit); + LL_TIM_SetCounter(ROBUS_TIMER, 0); LL_TIM_EnableCounter(ROBUS_TIMER); } } @@ -557,7 +552,7 @@ _CRITICAL void PINOUT_IRQHANDLER(uint16_t GPIO_Pin) if ((GPIO_Pin == TX_LOCK_DETECT_PIN) && (TX_LOCK_DETECT_IRQ != DISABLE)) { ctx.tx.lock = true; - RobusHAL_ResetTimeout(true, 0); + RobusHAL_ResetTimeout(0); EXTI->IMR1 &= ~TX_LOCK_DETECT_PIN; } else diff --git a/network/robus_network/HAL/STM32G4/robus_hal.h b/network/robus_network/HAL/STM32G4/robus_hal.h index 22f2dfd88..192085d38 100644 --- a/network/robus_network/HAL/STM32G4/robus_hal.h +++ b/network/robus_network/HAL/STM32G4/robus_hal.h @@ -22,7 +22,7 @@ void RobusHAL_SetRxState(uint8_t Enable); void RobusHAL_ComTransmit(uint8_t *data, uint16_t size); uint8_t RobusHAL_GetTxLockState(void); void RobusHAL_SetRxDetecPin(uint8_t Enable); -void RobusHAL_ResetTimeout(uint16_t enable, uint16_t nbrbit); +void RobusHAL_ResetTimeout(uint16_t nbrbit); void RobusHAL_SetPTPDefaultState(uint8_t PTPNbr); void RobusHAL_SetPTPReverseState(uint8_t PTPNbr); void RobusHAL_PushPTP(uint8_t PTPNbr); diff --git a/network/robus_network/src/reception.c b/network/robus_network/src/reception.c index 27abfaef4..473479e6a 100644 --- a/network/robus_network/src/reception.c +++ b/network/robus_network/src/reception.c @@ -243,7 +243,7 @@ _CRITICAL void Recep_GetCollision(luos_phy_t *phy_robus, volatile uint8_t *data) // Collision detection end data_count = 0; RobusHAL_SetRxState(false); - RobusHAL_ResetTimeout(false, 0); + RobusHAL_ResetTimeout(0); if (ctx.tx.status == TX_NOK) { // Switch to catch Ack. diff --git a/network/robus_network/src/transmission.c b/network/robus_network/src/transmission.c index 8d623f380..eae2bfa7e 100644 --- a/network/robus_network/src/transmission.c +++ b/network/robus_network/src/transmission.c @@ -256,7 +256,7 @@ _CRITICAL void Transmit_End(void) // A tx_task failed nbrRetry++; // compute a delay before retry - RobusHAL_ResetTimeout(true, 20 * nbrRetry * (Phy_GetNodeId() + 1)); + RobusHAL_ResetTimeout(20 * nbrRetry * (Phy_GetNodeId() + 1)); // Lock the trasmission to be sure no one can send something from this node until next timeout. ctx.tx.lock = true; ctx.tx.status = TX_DISABLE;