diff --git a/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/can_utility.c b/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/can_utility.c index 64cf974f2..1cef7b1f8 100644 --- a/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/can_utility.c +++ b/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/can_utility.c @@ -147,7 +147,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) } /* Enable - Disable CAN Transmission from EMS */ - if(((RxHeader.StdId & 0x700) >> 8) == 2 && (RxHeader.IDE == CAN_ID_STD)) // GOT MESSAGE FROM CLASS ICUBCANPROTO_CLASS_POLLING_ANALOGSENSOR + if( (RxHeader.IDE == CAN_ID_STD) && ((RxHeader.StdId & 0x700) >> 8) == 2 ) // GOT MESSAGE FROM CLASS ICUBCANPROTO_CLASS_POLLING_ANALOGSENSOR { if((RxData[0] & 0x7F) == 7) // GOT MESSAGE OF TYPE ICUBCANPROTO_POL_AS_CMD__SET_TXMODE { diff --git a/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/main.c b/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/main.c index e4d6fdd1f..223837123 100644 --- a/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/main.c +++ b/emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/main.c @@ -303,6 +303,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){ } if(htim->Instance==TIM16){ // timer 100ms toggle_100ms = toggle_100ms^1; + if(TX_ENABLED == 0) + return; CANBUS(); } if(htim->Instance==TIM17){ // timer 1s @@ -504,8 +506,6 @@ void calcMean(){ // The rest can be sent with a higher frequency void CANBUS(void){ - if(TX_ENABLED == 0) - return; switch(can_message){ #ifdef ENABLE_GUI_CUSTOM_MSG // Define to be added as -DENABLE_GUI_CUSTOM_MSG in `Option for target... >> C/C++ >> Misc controls` for enabling all messages (Also the custom ones not related to protocol) diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/embot_app_eth_theBATservice.cpp b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/embot_app_eth_theBATservice.cpp index 0ed7887d9..ef6fd13f3 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/embot_app_eth_theBATservice.cpp +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/embot_app_eth_theBATservice.cpp @@ -90,7 +90,7 @@ struct embot::app::eth::theBATservice::Impl { CANmonitor canmonitor{}; static constexpr CANmonitor::Config defaultcanmonitorconfig{ {}, // the map is left empty - 100 * embot::core::time1millisec, + 300 * embot::core::time1millisec, CANmonitor::Report::ALL, 10 * embot::core::time1second, s_eobj_ownname, @@ -284,8 +284,7 @@ eOresult_t embot::app::eth::theBATservice::Impl::Verify(const eOmn_serv_configur diagnostics.errorDescriptor.par64 = 0; EOaction_strg astrg = {0}; EOaction *act = (EOaction *)&astrg; - eo_action_SetCallback(act, s_send_periodic_error_report, this, - eov_callbackman_GetTask(eov_callbackman_GetHandle())); + eo_action_SetCallback(act, s_send_periodic_error_report, this, eov_callbackman_GetTask(eov_callbackman_GetHandle())); diagnostics.errorType = eo_errortype_debug; diagnostics.errorDescriptor.code = eoerror_code_get(eoerror_category_Config, eoerror_value_CFG_bat_ok); @@ -336,7 +335,8 @@ eOresult_t embot::app::eth::theBATservice::Impl::Activate(const eOmn_serv_config // - init the theBATnetvariables // we must load all the boards into can mapping, entities etc - for (uint8_t s = 0; s < numofsensors; s++) { + for (uint8_t s = 0; s < numofsensors; s++) + { const eOas_battery_sensordescriptor_t *sd = reinterpret_cast( eo_constarray_At(carray, s)); @@ -404,27 +404,24 @@ eOresult_t embot::app::eth::theBATservice::Impl::Deactivate() // entity-can-mapping and the board-can-mapping, reset all things inside this // object - if (eobool_true == service.started) { + if (eobool_true == service.started) + { Stop(); } SetRegulars(nullptr, nullptr); // deconfig EOtheCANmapping - eo_canmap_DeconfigEntity(eo_canmap_GetHandle(), eoprot_endpoint_analogsensors, - eoprot_entity_as_battery, - sharedcan.entitydescriptor); + eo_canmap_DeconfigEntity(eo_canmap_GetHandle(), eoprot_endpoint_analogsensors, eoprot_entity_as_battery, sharedcan.entitydescriptor); eo_canmap_UnloadBoards(eo_canmap_GetHandle(), sharedcan.boardproperties); // clear data used by this class for (auto &item : theBATnetvariables) { if (nullptr != item) { // i reset the status to its default value - std::memmove(&item->status, &defaultBATstatus, - sizeof(eOas_battery_status_t)); + std::memmove(&item->status, &defaultBATstatus, sizeof(eOas_battery_status_t)); // i reset the config to its default value - std::memmove(&item->config, &defaultBATconfig, - sizeof(eOas_battery_config_t)); + std::memmove(&item->config, &defaultBATconfig, sizeof(eOas_battery_config_t)); } item = nullptr; @@ -445,8 +442,7 @@ eOresult_t embot::app::eth::theBATservice::Impl::Deactivate() service.active = eobool_false; service.state = eomn_serv_state_idle; - eo_service_hid_SynchServiceState(eo_services_GetHandle(), - eomn_serv_category_battery, service.state); + eo_service_hid_SynchServiceState(eo_services_GetHandle(), eomn_serv_category_battery, service.state); return (eores_OK); } @@ -478,7 +474,8 @@ eOresult_t embot::app::eth::theBATservice::Impl::Start() { CANmonitor::Config cfg = defaultcanmonitorconfig; // use ... cfg.target.clear(); - cfg.periodofcheck = embot::core::time1millisec * service.servconfig.data.as.battery.canmonitorconfig.periodofcheck; + //cfg.periodofcheck = embot::core::time1millisec * service.servconfig.data.as.battery.canmonitorconfig.periodofcheck; + cfg.periodofcheck = embot::core::time1millisec * (uint8_t)300; cfg.periodofreport = embot::core::time1millisec * service.servconfig.data.as.battery.canmonitorconfig.periodofreport; cfg.reportmode = static_cast(service.servconfig.data.as.battery.canmonitorconfig.reportmode); canmonitor.configure(cfg);