From c219a6b7d6c92433020d2d98411bafc94d1aaba4 Mon Sep 17 00:00:00 2001 From: Mateusz Lubecki Date: Wed, 11 Oct 2023 18:28:37 +0200 Subject: [PATCH] reduced frequency of modbus rtu status messages on error --- include/etc/rtu_configuration.h | 2 +- include/pwr_save.h | 14 +++++++------- src/pwr_save.c | 14 +++++++------- system/src/modbus_rtu/rtu_serial_io.c | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/etc/rtu_configuration.h b/include/etc/rtu_configuration.h index 7554d13..dda807b 100644 --- a/include/etc/rtu_configuration.h +++ b/include/etc/rtu_configuration.h @@ -21,7 +21,7 @@ //#endif -#define RTU_NUMBER_OF_ERRORS_TO_TRIG_STATUS 32 +#define RTU_NUMBER_OF_ERRORS_TO_TRIG_STATUS 128 #define RTU_POOL_QUEUE_LENGHT 6 diff --git a/include/pwr_save.h b/include/pwr_save.h index 75fca11..5283569 100644 --- a/include/pwr_save.h +++ b/include/pwr_save.h @@ -114,13 +114,13 @@ extern int8_t pwr_save_currently_cutoff; void pwr_save_init(config_data_powersave_mode_t mode); int pwr_save_switch_mode_to_c0(void); int pwr_save_switch_mode_to_c1(void); -//void pwr_save_switch_mode_to_c2(void); -//void pwr_save_switch_mode_to_c3(void); -//int pwr_save_switch_mode_to_m4(void); -//int pwr_save_switch_mode_to_m4a(void); -//void pwr_save_switch_mode_to_i5(void); -//void pwr_save_switch_mode_to_l6(uint16_t sleep_time); -//void pwr_save_switch_mode_to_l7(uint16_t sleep_time); +void pwr_save_switch_mode_to_c2(void); +void pwr_save_switch_mode_to_c3(void); +int pwr_save_switch_mode_to_m4(void); +int pwr_save_switch_mode_to_m4a(void); +void pwr_save_switch_mode_to_i5(void); +void pwr_save_switch_mode_to_l6(uint16_t sleep_time); +void pwr_save_switch_mode_to_l7(uint16_t sleep_time); config_data_powersave_mode_t pwr_save_pooling_handler(const config_data_mode_t * config, const config_data_basic_t * timers, int16_t minutes_to_wx, uint16_t vbatt); // this should be called from 10 seconds pooler #endif diff --git a/src/pwr_save.c b/src/pwr_save.c index bb473ea..6e772e4 100644 --- a/src/pwr_save.c +++ b/src/pwr_save.c @@ -368,7 +368,7 @@ int pwr_save_switch_mode_to_c1(void) { // this mode is not avaliable in HW Revision B as internal radio // is powered from +5V_S and external one is switched on with the same // line which controls +4V_G -static void pwr_save_switch_mode_to_c2(void) { +void pwr_save_switch_mode_to_c2(void) { if ((REGISTER & ALL_STATES_BITMASK) == IN_C2_STATE) { return; @@ -408,7 +408,7 @@ static void pwr_save_switch_mode_to_c2(void) { } -static void pwr_save_switch_mode_to_c3(void) { +void pwr_save_switch_mode_to_c3(void) { if ((REGISTER & ALL_STATES_BITMASK) == IN_C3_STATE) { return; @@ -446,7 +446,7 @@ static void pwr_save_switch_mode_to_c3(void) { } // in HW-RevB this will keep internal VHF radio module working! -static int pwr_save_switch_mode_to_m4(void) { +int pwr_save_switch_mode_to_m4(void) { if ((REGISTER & ALL_STATES_BITMASK) == IN_M4_STATE) { return 0; @@ -487,7 +487,7 @@ static int pwr_save_switch_mode_to_m4(void) { return 1; } -static int pwr_save_switch_mode_to_m4a(void) { +int pwr_save_switch_mode_to_m4a(void) { if ((REGISTER & ALL_STATES_BITMASK) == IN_M4_STATE) { return 0; } @@ -524,7 +524,7 @@ static int pwr_save_switch_mode_to_m4a(void) { return 1; } -static void pwr_save_switch_mode_to_i5(void) { +void pwr_save_switch_mode_to_i5(void) { if ((REGISTER & ALL_STATES_BITMASK) == IN_I5_STATE) { return; @@ -565,7 +565,7 @@ static void pwr_save_switch_mode_to_i5(void) { } // this will keep external VHF radio working in HW-RevB -static void pwr_save_switch_mode_to_l6(uint16_t sleep_time) { +void pwr_save_switch_mode_to_l6(uint16_t sleep_time) { uint16_t counter = 0; @@ -652,7 +652,7 @@ static void pwr_save_switch_mode_to_l6(uint16_t sleep_time) { } -static void pwr_save_switch_mode_to_l7(uint16_t sleep_time) { +void pwr_save_switch_mode_to_l7(uint16_t sleep_time) { uint16_t counter = 0; diff --git a/system/src/modbus_rtu/rtu_serial_io.c b/system/src/modbus_rtu/rtu_serial_io.c index bfd39ea..70577c6 100644 --- a/system/src/modbus_rtu/rtu_serial_io.c +++ b/system/src/modbus_rtu/rtu_serial_io.c @@ -224,11 +224,11 @@ int32_t rtu_serial_pool(void) { rte_rtu_number_of_serial_io_errors++; // stupid workaround. If there is a lot of I/O errors reset the controller - - if (rte_rtu_number_of_serial_io_errors >= 0xF0) - { - rte_main_reboot_req = 1; - } + // no more stupid workarounds here +// if (rte_rtu_number_of_serial_io_errors >= 0xF0) +// { +// rte_main_reboot_req = 1; +// } // latch the current value of last successfull communication rtu_time_of_last_succ_comm_at_previous_error_status = rtu_time_of_last_successfull_comm;