Skip to content

Commit

Permalink
Update some test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MSECode committed Dec 27, 2023
1 parent 95c349a commit 2603a27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions emBODY/eBcode/arch-arm/board/bat/BAT_Rev_B/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<const eOas_battery_sensordescriptor_t *>(
eo_constarray_At(carray, s));
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<CANmonitor::Report>(service.servconfig.data.as.battery.canmonitorconfig.reportmode);
canmonitor.configure(cfg);
Expand Down

0 comments on commit 2603a27

Please sign in to comment.