that should do it
Some checks are pending
EIVE/eive-obsw/pipeline/head Build queued...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-04-07 11:37:17 +02:00
parent d5d43e8d44
commit d98873c9a6
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 48 additions and 47 deletions

View File

@ -22,6 +22,11 @@ will consitute of a breaking change warranting a new major release:
when this was due to two devices being marked faulty.
- RW dummy and STR dummy components: Set/Update modes correctly.
## Changed
- RW shutdown now waits for the speed to be near 0 or for a OFF transition countdown to be expired
before going to off.
# [v1.43.2] 2023-04-05
## Changed

View File

@ -30,7 +30,7 @@ void RwHandler::doStartUp() {
internalState = InternalState::DEFAULT;
if (gpioComIF->pullHigh(enableGpio) != returnvalue::OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high";
sif::error << "RW Handler " << rwIdx << ": Failed to pull ENABLE pin high for startup";
}
updatePeriodicReply(true, rws::REPLY_ID);
statusSet.setReportingEnabled(true);
@ -38,10 +38,16 @@ void RwHandler::doStartUp() {
}
void RwHandler::doShutDown() {
if (gpioComIF->pullLow(enableGpio) != returnvalue::OK) {
sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low";
if (internalState != InternalState::SHUTDOWN) {
internalState = InternalState::SHUTDOWN;
commandExecuted = false;
offTransitionCountdown.resetTimer();
}
if (((internalState == InternalState::SHUTDOWN) and commandExecuted) or
offTransitionCountdown.hasTimedOut()) {
if (gpioComIF->pullLow(enableGpio) != returnvalue::OK) {
sif::error << "RW Handler " << rwIdx << ": Failed to pull ENABLE pin low for shutdown";
}
internalState = InternalState::DEFAULT;
updatePeriodicReply(false, rws::REPLY_ID);
{
PoolReadGuard pg(&statusSet);
@ -55,12 +61,11 @@ void RwHandler::doShutDown() {
PoolReadGuard pg(&tmDataset);
tmDataset.setValidity(false, true);
}
{
PoolReadGuard pg(&rwSpeedActuationSet);
rwSpeedActuationSet.setRwSpeed(0, 10);
}
commandExecuted = false;
internalState = InternalState::DEFAULT;
// The power switch is handled by the assembly, so we can go off here directly.
setMode(MODE_OFF);
}
}
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
@ -77,6 +82,14 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
}
ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if (internalState == InternalState::SHUTDOWN) {
{
PoolReadGuard pg(&rwSpeedActuationSet);
rwSpeedActuationSet.setRwSpeed(0, 10);
}
*id = rws::REQUEST_ID;
return buildCommandFromCommand(*id, nullptr, 0);
}
return NOTHING_TO_SEND;
}
@ -381,6 +394,11 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) {
statusSet.setValidity(true, true);
if (internalState == InternalState::SHUTDOWN and std::abs(tmDataset.rwCurrSpeed.value) <= 2) {
// Finish transition to off.
commandExecuted = true;
}
if (statusSet.state == rws::STATE_ERROR) {
// Trigger FDIR reaction, first recovery, then faulty if it doesnt fix the issue.
triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT, statusSet.state.value, 0);

View File

@ -75,6 +75,8 @@ class RwHandler : public DeviceHandlerBase {
GpioIF* gpioComIF = nullptr;
gpioId_t enableGpio = gpio::NO_GPIO;
bool debugMode = false;
bool commandExecuted = false;
Countdown offTransitionCountdown = Countdown(5000);
rws::StatusSet statusSet;
rws::LastResetSatus lastResetStatusSet;
@ -87,27 +89,10 @@ class RwHandler : public DeviceHandlerBase {
PoolEntry<int32_t> rwSpeed = PoolEntry<int32_t>({0});
PoolEntry<uint16_t> rampTime = PoolEntry<uint16_t>({10});
enum class InternalState {
DEFAULT,
GET_TM,
INIT_RW_CONTROLLER,
RESET_MCU,
// GET_RESET_STATUS,
// CLEAR_RESET_STATUS,
// READ_TEMPERATURE,
// SET_SPEED,
// GET_RW_SATUS
};
enum class InternalState { DEFAULT, GET_TM, INIT_RW_CONTROLLER, RESET_MCU, SHUTDOWN };
InternalState internalState = InternalState::DEFAULT;
/**
* @brief This function can be used to build commands which do not contain any data apart
* from the command id and the CRC.
* @param commandId The command id of the command to build.
*/
// void prepareSimpleCommand(DeviceCommandId_t id);
/**
* @brief This function checks if the receiced speed and ramp time to set are in a valid
* range.
@ -115,13 +100,6 @@ class RwHandler : public DeviceHandlerBase {
*/
ReturnValue_t checkSpeedAndRampTime();
/**
* @brief This function prepares the set speed command from the dataSet received with
* an action message or set in the software.
* @return returnvalue::OK if successful, otherwise error code.
*/
// ReturnValue_t prepareSetSpeedCmd();
/**
* @brief This function writes the last reset status retrieved with the get last reset status
* command into the reset status dataset.