Skip to content

Commit

Permalink
Stima V4.6
Browse files Browse the repository at this point in the history
Fix bug missed download VWC Firmware file (missing name file)
Fix bug reset flags (firmware ready) on start newer firmware version
Add RPC Direct upload single firmware command master and slave
Fix Bug verify file upgarding available with only master newer file
  • Loading branch information
digitecomg committed Jun 17, 2024
1 parent 21e061e commit 7443f16
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 19 deletions.
3 changes: 3 additions & 0 deletions platformio/stima_v4/libraries/RmapCommon/stima_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ bool checkStimaFirmwareType(char *file_name, uint8_t *type, uint8_t *version, ui
} else if (strstr(file_name, STIMA_MODULE_NAME_POWER_MPPT)) {
*type = STIMA_MODULE_TYPE_POWER_MPPT;
ptrcheck = file_name + sizeof(STIMA_MODULE_NAME_POWER_MPPT);
} else if (strstr(file_name, STIMA_MODULE_NAME_VWC)) {
*type = STIMA_MODULE_TYPE_VWC;
ptrcheck = file_name + sizeof(STIMA_MODULE_NAME_VWC);
} else {
// Error unknown module file
return false;
Expand Down
2 changes: 1 addition & 1 deletion platformio/stima_v4/master/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define MODULE_MAIN_VERSION (4)

/// @brief Module minor version.
#define MODULE_MINOR_VERSION (5)
#define MODULE_MINOR_VERSION (6)

/// @brief Module minor version.
#define CONFIGURATION_VERSION (1)
Expand Down
37 changes: 26 additions & 11 deletions platformio/stima_v4/master/src/rpc_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,24 +235,39 @@ int RegisterRPC::admin(JsonObject params, JsonObject result)
{
error_command = false;
uint8_t node_id_rpc = it.value().as<unsigned int>();
// Starting queue request direct command remote Node over Cyphal
if(param.configuration->board_slave[node_id_rpc].module_type != Module_Type::undefined) {
if(param.system_status->data_slave[node_id_rpc].fw_upgradable) {
if(node_id_rpc == CMD_PARAM_MASTER_ADDRESS) {
if(param.system_status->data_master.fw_upgradable) {
// Starting queue request direct command firmware update remote Node over Cyphal
system_message_t system_message = {0};
system_message.task_dest = CAN_TASK_ID;
system_message.task_dest = SD_TASK_ID;
system_message.command.do_update_fw = true;
// Parameter is Node Slave ID (Command destination Node Id)
system_message.node_id = (Module_Type)node_id_rpc;
param.systemMessageQueue->Enqueue(&system_message);
TRACE_INFO_F(F("RPC: DO DIRECT REMOTE UPGRADE FIRMWARE ON NODE ID:%d\r\n"), system_message.node_id);
TRACE_INFO_F(F("RPC: DO DIRECT UPGRADE FIRMWARE ON MASTER\r\n"));
} else {
TRACE_INFO_F(F("RPC: ERROR REMOTE UPGRADE FIRMWARE ON UNNECESSARY NODE\r\n"));
TRACE_INFO_F(F("RPC: ERROR UPGRADE FIRMWARE ON MASTER WITHOUT (.BIN) FILE\r\n"));
error_command = true;
}
} else {
TRACE_INFO_F(F("RPC: ERROR REMOTE UPGRADE FIRMWARE ON UNCONFIGURED NODE\r\n"));
error_command = true;
// Starting queue request direct command remote Node over Cyphal
if(param.configuration->board_slave[node_id_rpc].module_type != Module_Type::undefined) {
if(param.system_status->data_slave[node_id_rpc].fw_upgradable) {
// Starting queue request direct command firmware update remote Node over Cyphal
system_message_t system_message = {0};
system_message.task_dest = CAN_TASK_ID;
system_message.command.do_update_fw = true;
// Parameter is Node Slave ID (Command destination Node Id)
system_message.node_id = (Module_Type)node_id_rpc;
param.systemMessageQueue->Enqueue(&system_message);
TRACE_INFO_F(F("RPC: DO DIRECT REMOTE UPGRADE FIRMWARE ON NODE ID:%d\r\n"), system_message.node_id);
} else {
TRACE_INFO_F(F("RPC: ERROR REMOTE UPGRADE FIRMWARE ON UNNECESSARY NODE\r\n"));
error_command = true;
}
} else {
TRACE_INFO_F(F("RPC: ERROR REMOTE UPGRADE FIRMWARE ON UNCONFIGURED NODE\r\n"));
error_command = true;
}
}
}
else if (strcmp(it.key().c_str(), "rstflags") == 0)
Expand Down Expand Up @@ -379,7 +394,7 @@ int RegisterRPC::configure(JsonObject params, JsonObject result)
system_message.command.do_remote_cfg = true;
// Parameter is Node Slave ID (Command destination Node Id)
system_message.node_id = slaveId;
param.systemMessageQueue->Enqueue(&system_message, 0);
param.systemMessageQueue->Enqueue(&system_message);
}
else error_command = true;
// Reset and deinit info current module and parameter pointer configure sequence
Expand Down Expand Up @@ -1705,7 +1720,7 @@ int RegisterRPC::reboot(JsonObject params, JsonObject result)
system_message_t system_message = {0};
system_message.task_dest = CAN_TASK_ID;
system_message.command.do_reboot = true;
param.systemMessageQueue->Enqueue(&system_message, 0);
param.systemMessageQueue->Enqueue(&system_message);
}
#endif

Expand Down
12 changes: 12 additions & 0 deletions platformio/stima_v4/master/src/tasks/can_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,8 @@ void CanTask::Run() {
param.system_status->data_slave[queueId].module_revision = retTHData->revision;
// Module type also setted on load config module CAN
param.system_status->data_slave[queueId].module_type = clCanard.slave[queueId].get_module_type();
// Reset flag before recheck exixting firmware available
param.system_status->data_slave[queueId].fw_upgradable = false;
// Check if module can be updated
for(uint8_t checkId=0; checkId<STIMA_MODULE_TYPE_MAX_AVAIABLE; checkId++) {
if(clCanard.slave[queueId].get_module_type() == param.system_status->boards_update_avaiable[checkId].module_type) {
Expand Down Expand Up @@ -2076,6 +2078,8 @@ void CanTask::Run() {
param.system_status->data_slave[queueId].module_revision = retRainData->revision;
// Module type also setted on load config module CAN
param.system_status->data_slave[queueId].module_type = clCanard.slave[queueId].get_module_type();
// Reset flag before recheck exixting firmware available
param.system_status->data_slave[queueId].fw_upgradable = false;
// Check if module can be updated
for(uint8_t checkId=0; checkId<STIMA_MODULE_TYPE_MAX_AVAIABLE; checkId++) {
if(clCanard.slave[queueId].get_module_type() == param.system_status->boards_update_avaiable[checkId].module_type) {
Expand Down Expand Up @@ -2159,6 +2163,8 @@ void CanTask::Run() {
param.system_status->data_slave[queueId].module_revision = retWindData->revision;
// Module type also setted on load config module CAN
param.system_status->data_slave[queueId].module_type = clCanard.slave[queueId].get_module_type();
// Reset flag before recheck exixting firmware available
param.system_status->data_slave[queueId].fw_upgradable = false;
// Check if module can be updated
for(uint8_t checkId=0; checkId<STIMA_MODULE_TYPE_MAX_AVAIABLE; checkId++) {
if(clCanard.slave[queueId].get_module_type() == param.system_status->boards_update_avaiable[checkId].module_type) {
Expand Down Expand Up @@ -2239,6 +2245,8 @@ void CanTask::Run() {
param.system_status->data_slave[queueId].module_revision = retRadiationData->revision;
// Module type also setted on load config module CAN
param.system_status->data_slave[queueId].module_type = clCanard.slave[queueId].get_module_type();
// Reset flag before recheck exixting firmware available
param.system_status->data_slave[queueId].fw_upgradable = false;
// Check if module can be updated
for(uint8_t checkId=0; checkId<STIMA_MODULE_TYPE_MAX_AVAIABLE; checkId++) {
if(clCanard.slave[queueId].get_module_type() == param.system_status->boards_update_avaiable[checkId].module_type) {
Expand Down Expand Up @@ -2316,6 +2324,8 @@ void CanTask::Run() {
param.system_status->data_slave[queueId].module_revision = retPwrData->revision;
// Module type also setted on load config module CAN
param.system_status->data_slave[queueId].module_type = clCanard.slave[queueId].get_module_type();
// Reset flag before recheck exixting firmware available
param.system_status->data_slave[queueId].fw_upgradable = false;
// Check if module can be updated
for(uint8_t checkId=0; checkId<STIMA_MODULE_TYPE_MAX_AVAIABLE; checkId++) {
if(clCanard.slave[queueId].get_module_type() == param.system_status->boards_update_avaiable[checkId].module_type) {
Expand Down Expand Up @@ -2403,6 +2413,8 @@ void CanTask::Run() {
param.system_status->data_slave[queueId].module_revision = retVwcData->revision;
// Module type also setted on load config module CAN
param.system_status->data_slave[queueId].module_type = clCanard.slave[queueId].get_module_type();
// Reset flag before recheck exixting firmware available
param.system_status->data_slave[queueId].fw_upgradable = false;
// Check if module can be updated
for(uint8_t checkId=0; checkId<STIMA_MODULE_TYPE_MAX_AVAIABLE; checkId++) {
if(clCanard.slave[queueId].get_module_type() == param.system_status->boards_update_avaiable[checkId].module_type) {
Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/master/src/tasks/mqtt_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,9 @@ error_t MqttTask::makeSensorMessageClassSpeed(rmap_sensors_WindClassSpeed_1_0 se
if (sensor.class4.val.value > rmap_tableb_B11214_1_0_MAX) sensor.class4.val.value = 0;
if (sensor.class5.val.value > rmap_tableb_B11215_1_0_MAX) sensor.class5.val.value = 0;
if (sensor.class6.val.value > rmap_tableb_B11216_1_0_MAX) sensor.class6.val.value = 0;
uint8_t chkVal = sensor.class1.val.value + sensor.class2.val.value + sensor.class3.val.value +
sensor.class4.val.value + sensor.class5.val.value + sensor.class6.val.value;
if(chkVal != rmap_tableb_B11216_1_0_MAX) sensor.class1.val.value += (rmap_tableb_B11216_1_0_MAX - chkVal);
}

if (!error)
Expand Down
16 changes: 9 additions & 7 deletions platformio/stima_v4/master/src/tasks/sd_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,15 +940,17 @@ void SdTask::Run()
param.system_status->boards_update_avaiable[brd].module_type = module_type;
param.system_status->boards_update_avaiable[brd].version = fw_version;
param.system_status->boards_update_avaiable[brd].revision = fw_revision;
// ?Is this module ->Master? (check directly if fw upgrade is avaiable with last version file present)
if(param.configuration->module_type == module_type) {
if((fw_version > param.configuration->module_main_version) ||
((fw_version == param.configuration->module_main_version) && (fw_revision > param.configuration->module_minor_version))) {
param.system_status->data_master.fw_upgradable = true;
}
}
param.systemStatusLock->Give();
}
// ?Is this module ->Master? (check directly if fw upgrade is avaiable with last version file present)
if(param.configuration->module_type == module_type) {
if((fw_version > param.configuration->module_main_version) ||
((fw_version == param.configuration->module_main_version) && (fw_revision > param.configuration->module_minor_version))) {
param.systemStatusLock->Take();
param.system_status->data_master.fw_upgradable = true;
param.systemStatusLock->Give();
}
}
break;
}
}
Expand Down

0 comments on commit 7443f16

Please sign in to comment.