From c3b2e3ef0f39a4a2b62da76f2cc7517ee4249bc3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Oct 2022 14:08:26 +0200 Subject: [PATCH] rw fix and higher timeout for tctrl locks --- mission/controller/ThermalController.cpp | 60 ++++++++++++------------ mission/controller/ThermalController.h | 1 + mission/devices/RwHandler.cpp | 4 +- tmtc | 2 +- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 10c74fca..608b68b7 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -235,7 +235,7 @@ ReturnValue_t ThermalController::checkModeCommand(Mode_t mode, Submode_t submode void ThermalController::copySensors() { { - PoolReadGuard pg0(&max31865Set0); + PoolReadGuard pg0(&max31865Set0, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg0.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_ploc_heatspreader.value = max31865Set0.temperatureCelcius.value; sensorTemperatures.sensor_ploc_heatspreader.setValid( @@ -247,7 +247,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg1(&max31865Set1); + PoolReadGuard pg1(&max31865Set1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg1.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_ploc_missionboard.value = max31865Set1.temperatureCelcius.value; sensorTemperatures.sensor_ploc_missionboard.setValid( @@ -259,7 +259,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg2(&max31865Set2); + PoolReadGuard pg2(&max31865Set2, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg2.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_4k_camera.value = max31865Set2.temperatureCelcius.value; sensorTemperatures.sensor_4k_camera.setValid(max31865Set2.temperatureCelcius.isValid()); @@ -270,7 +270,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg3(&max31865Set3); + PoolReadGuard pg3(&max31865Set3, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg3.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_dac_heatspreader.value = max31865Set3.temperatureCelcius.value; sensorTemperatures.sensor_dac_heatspreader.setValid( @@ -282,7 +282,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg4(&max31865Set4); + PoolReadGuard pg4(&max31865Set4, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg4.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_startracker.value = max31865Set4.temperatureCelcius.value; sensorTemperatures.sensor_startracker.setValid(max31865Set4.temperatureCelcius.isValid()); @@ -293,7 +293,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg5(&max31865Set5); + PoolReadGuard pg5(&max31865Set5, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg5.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_rw1.value = max31865Set5.temperatureCelcius.value; sensorTemperatures.sensor_rw1.setValid(max31865Set5.temperatureCelcius.isValid()); @@ -304,7 +304,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg6(&max31865Set6); + PoolReadGuard pg6(&max31865Set6, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg6.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_dro.value = max31865Set6.temperatureCelcius.value; sensorTemperatures.sensor_dro.setValid(max31865Set6.temperatureCelcius.isValid()); @@ -315,7 +315,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg7(&max31865Set7); + PoolReadGuard pg7(&max31865Set7, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg7.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_scex.value = max31865Set7.temperatureCelcius.value; sensorTemperatures.sensor_scex.setValid(max31865Set7.temperatureCelcius.isValid()); @@ -326,7 +326,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg8(&max31865Set8); + PoolReadGuard pg8(&max31865Set8, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg8.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_x8.value = max31865Set8.temperatureCelcius.value; sensorTemperatures.sensor_x8.setValid(max31865Set8.temperatureCelcius.isValid()); @@ -337,7 +337,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg9(&max31865Set9); + PoolReadGuard pg9(&max31865Set9, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg9.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_hpa.value = max31865Set9.temperatureCelcius.value; sensorTemperatures.sensor_hpa.setValid(max31865Set9.temperatureCelcius.isValid()); @@ -348,7 +348,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg10(&max31865Set10); + PoolReadGuard pg10(&max31865Set10, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg10.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_tx_modul.value = max31865Set10.temperatureCelcius.value; sensorTemperatures.sensor_tx_modul.setValid(max31865Set10.temperatureCelcius.isValid()); @@ -359,7 +359,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg11(&max31865Set11); + PoolReadGuard pg11(&max31865Set11, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg11.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_mpa.value = max31865Set11.temperatureCelcius.value; sensorTemperatures.sensor_mpa.setValid(max31865Set11.temperatureCelcius.isValid()); @@ -370,7 +370,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg12(&max31865Set12); + PoolReadGuard pg12(&max31865Set12, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg12.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_acu.value = max31865Set12.temperatureCelcius.value; sensorTemperatures.sensor_acu.setValid(max31865Set12.temperatureCelcius.isValid()); @@ -381,7 +381,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg13(&max31865Set13); + PoolReadGuard pg13(&max31865Set13, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg13.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_plpcdu_heatspreader.value = max31865Set13.temperatureCelcius.value; sensorTemperatures.sensor_plpcdu_heatspreader.setValid( @@ -393,7 +393,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg14(&max31865Set14); + PoolReadGuard pg14(&max31865Set14, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg14.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_tcs_board.value = max31865Set14.temperatureCelcius.value; sensorTemperatures.sensor_tcs_board.setValid(max31865Set14.temperatureCelcius.isValid()); @@ -404,7 +404,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg15(&max31865Set15); + PoolReadGuard pg15(&max31865Set15, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg15.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_magnettorquer.value = max31865Set15.temperatureCelcius.value; sensorTemperatures.sensor_magnettorquer.setValid(max31865Set15.temperatureCelcius.isValid()); @@ -415,7 +415,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg111(&tmp1075Set1); + PoolReadGuard pg111(&tmp1075Set1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg111.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_tmp1075_1.value = tmp1075Set1.temperatureCelcius.value; sensorTemperatures.sensor_tmp1075_1.setValid(tmp1075Set1.temperatureCelcius.isValid()); @@ -426,7 +426,7 @@ void ThermalController::copySensors() { } { - PoolReadGuard pg112(&tmp1075Set2); + PoolReadGuard pg112(&tmp1075Set2, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg112.getReadResult() == returnvalue::OK) { sensorTemperatures.sensor_tmp1075_2.value = tmp1075Set2.temperatureCelcius.value; sensorTemperatures.sensor_tmp1075_2.setValid(tmp1075Set2.temperatureCelcius.isValid()); @@ -439,7 +439,7 @@ void ThermalController::copySensors() { void ThermalController::copySus() { { - PoolReadGuard pg0(&susSet0); + PoolReadGuard pg0(&susSet0, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg0.getReadResult() == returnvalue::OK) { susTemperatures.sus_0_n_loc_xfyfzm_pt_xf.value = susSet0.temperatureCelcius.value; susTemperatures.sus_0_n_loc_xfyfzm_pt_xf.setValid(susSet0.temperatureCelcius.isValid()); @@ -450,7 +450,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg1(&susSet1); + PoolReadGuard pg1(&susSet1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg1.getReadResult() == returnvalue::OK) { susTemperatures.sus_6_r_loc_xfybzm_pt_xf.value = susSet1.temperatureCelcius.value; susTemperatures.sus_6_r_loc_xfybzm_pt_xf.setValid(susSet1.temperatureCelcius.isValid()); @@ -461,7 +461,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg2(&susSet2); + PoolReadGuard pg2(&susSet2, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg2.getReadResult() == returnvalue::OK) { susTemperatures.sus_1_n_loc_xbyfzm_pt_xb.value = susSet2.temperatureCelcius.value; susTemperatures.sus_1_n_loc_xbyfzm_pt_xb.setValid(susSet2.temperatureCelcius.isValid()); @@ -472,7 +472,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg3(&susSet3); + PoolReadGuard pg3(&susSet3, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg3.getReadResult() == returnvalue::OK) { susTemperatures.sus_7_r_loc_xbybzm_pt_xb.value = susSet3.temperatureCelcius.value; susTemperatures.sus_7_r_loc_xbybzm_pt_xb.setValid(susSet3.temperatureCelcius.isValid()); @@ -483,7 +483,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg4(&susSet4); + PoolReadGuard pg4(&susSet4, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg4.getReadResult() == returnvalue::OK) { susTemperatures.sus_2_n_loc_xfybzb_pt_yb.value = susSet4.temperatureCelcius.value; susTemperatures.sus_2_n_loc_xfybzb_pt_yb.setValid(susSet4.temperatureCelcius.isValid()); @@ -494,7 +494,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg5(&susSet5); + PoolReadGuard pg5(&susSet5, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg5.getReadResult() == returnvalue::OK) { susTemperatures.sus_8_r_loc_xbybzb_pt_yb.value = susSet5.temperatureCelcius.value; susTemperatures.sus_8_r_loc_xbybzb_pt_yb.setValid(susSet5.temperatureCelcius.isValid()); @@ -505,7 +505,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg6(&susSet6); + PoolReadGuard pg6(&susSet6, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg6.getReadResult() == returnvalue::OK) { susTemperatures.sus_3_n_loc_xfybzf_pt_yf.value = susSet6.temperatureCelcius.value; susTemperatures.sus_3_n_loc_xfybzf_pt_yf.setValid(susSet6.temperatureCelcius.isValid()); @@ -516,7 +516,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg7(&susSet7); + PoolReadGuard pg7(&susSet7, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg7.getReadResult() == returnvalue::OK) { susTemperatures.sus_9_r_loc_xbybzb_pt_yf.value = susSet7.temperatureCelcius.value; susTemperatures.sus_9_r_loc_xbybzb_pt_yf.setValid(susSet7.temperatureCelcius.isValid()); @@ -527,7 +527,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg8(&susSet8); + PoolReadGuard pg8(&susSet8, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg8.getReadResult() == returnvalue::OK) { susTemperatures.sus_4_n_loc_xmyfzf_pt_zf.value = susSet8.temperatureCelcius.value; susTemperatures.sus_4_n_loc_xmyfzf_pt_zf.setValid(susSet8.temperatureCelcius.isValid()); @@ -538,7 +538,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg9(&susSet9); + PoolReadGuard pg9(&susSet9, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg9.getReadResult() == returnvalue::OK) { susTemperatures.sus_10_n_loc_xmybzf_pt_zf.value = susSet9.temperatureCelcius.value; susTemperatures.sus_10_n_loc_xmybzf_pt_zf.setValid(susSet9.temperatureCelcius.isValid()); @@ -549,7 +549,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg10(&susSet10); + PoolReadGuard pg10(&susSet10, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg10.getReadResult() == returnvalue::OK) { susTemperatures.sus_5_n_loc_xfymzb_pt_zb.value = susSet10.temperatureCelcius.value; susTemperatures.sus_5_n_loc_xfymzb_pt_zb.setValid(susSet10.temperatureCelcius.isValid()); @@ -560,7 +560,7 @@ void ThermalController::copySus() { } { - PoolReadGuard pg11(&susSet11); + PoolReadGuard pg11(&susSet11, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg11.getReadResult() == returnvalue::OK) { susTemperatures.sus_11_r_loc_xbymzb_pt_zb.value = susSet11.temperatureCelcius.value; susTemperatures.sus_11_r_loc_xbymzb_pt_zb.setValid(susSet11.temperatureCelcius.isValid()); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 29661d5e..7ca517cb 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -75,6 +75,7 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); + static constexpr dur_millis_t MUTEX_TIMEOUT = 50; void copySensors(); void copySus(); void copyDevices(); diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index b7e26123..732bb9fe 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -304,9 +304,9 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_ return INVALID_SPEED; } - uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); + uint16_t rampTime = (*(commandData + 4) << 8) | *(commandData + 5); - if (rampTime < 10 || rampTime > 10000) { + if (rampTime < 10 || rampTime > 20000) { sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl; return INVALID_RAMP_TIME; } diff --git a/tmtc b/tmtc index 0ddb9587..7957ed84 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 0ddb9587ba48ff9108fb5da9ef39b646960d6022 +Subproject commit 7957ed844e6b2d143cf780d3cc5a3ba485a06e70