continue rw refactoring
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -45,23 +45,23 @@ void RwHandler::doShutDown() {
|
||||
ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
switch (internalState) {
|
||||
case InternalState::SET_SPEED:
|
||||
*id = RwDefinitions::SET_SPEED;
|
||||
*id = rws::SET_SPEED;
|
||||
internalState = InternalState::GET_RESET_STATUS;
|
||||
break;
|
||||
case InternalState::GET_RESET_STATUS:
|
||||
*id = RwDefinitions::GET_LAST_RESET_STATUS;
|
||||
*id = rws::GET_LAST_RESET_STATUS;
|
||||
internalState = InternalState::READ_TEMPERATURE;
|
||||
break;
|
||||
case InternalState::READ_TEMPERATURE:
|
||||
*id = RwDefinitions::GET_TEMPERATURE;
|
||||
*id = rws::GET_TEMPERATURE;
|
||||
internalState = InternalState::GET_RW_SATUS;
|
||||
break;
|
||||
case InternalState::GET_RW_SATUS:
|
||||
*id = RwDefinitions::GET_RW_STATUS;
|
||||
*id = rws::GET_RW_STATUS;
|
||||
internalState = InternalState::CLEAR_RESET_STATUS;
|
||||
break;
|
||||
case InternalState::CLEAR_RESET_STATUS:
|
||||
*id = RwDefinitions::CLEAR_LAST_RESET_STATUS;
|
||||
*id = rws::CLEAR_LAST_RESET_STATUS;
|
||||
/** After reset status is cleared, reset status will be polled again for verification */
|
||||
internalState = InternalState::GET_RESET_STATUS;
|
||||
break;
|
||||
@ -82,27 +82,27 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
switch (deviceCommand) {
|
||||
case (RwDefinitions::RESET_MCU): {
|
||||
case (rws::RESET_MCU): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RwDefinitions::GET_LAST_RESET_STATUS): {
|
||||
case (rws::GET_LAST_RESET_STATUS): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RwDefinitions::CLEAR_LAST_RESET_STATUS): {
|
||||
case (rws::CLEAR_LAST_RESET_STATUS): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RwDefinitions::GET_RW_STATUS): {
|
||||
case (rws::GET_RW_STATUS): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RwDefinitions::INIT_RW_CONTROLLER): {
|
||||
case (rws::INIT_RW_CONTROLLER): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RwDefinitions::SET_SPEED): {
|
||||
case (rws::SET_SPEED): {
|
||||
if (commandData != nullptr && commandDataLen != 6) {
|
||||
sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with"
|
||||
<< " invalid length" << std::endl;
|
||||
@ -136,11 +136,11 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand
|
||||
result = prepareSetSpeedCmd();
|
||||
return result;
|
||||
}
|
||||
case (RwDefinitions::GET_TEMPERATURE): {
|
||||
case (rws::GET_TEMPERATURE): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (RwDefinitions::GET_TM): {
|
||||
case (rws::GET_TM): {
|
||||
prepareSimpleCommand(deviceCommand);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
@ -151,60 +151,56 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand
|
||||
}
|
||||
|
||||
void RwHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(RwDefinitions::RESET_MCU);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet,
|
||||
RwDefinitions::SIZE_GET_RESET_STATUS);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr,
|
||||
RwDefinitions::SIZE_CLEAR_RESET_STATUS);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet,
|
||||
RwDefinitions::SIZE_GET_RW_STATUS);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr,
|
||||
RwDefinitions::SIZE_INIT_RW);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, nullptr,
|
||||
RwDefinitions::SIZE_GET_TEMPERATURE_REPLY);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr,
|
||||
RwDefinitions::SIZE_SET_SPEED_REPLY);
|
||||
this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset,
|
||||
RwDefinitions::SIZE_GET_TELEMETRY_REPLY);
|
||||
this->insertInCommandMap(rws::RESET_MCU);
|
||||
this->insertInCommandAndReplyMap(rws::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet,
|
||||
rws::SIZE_GET_RESET_STATUS);
|
||||
this->insertInCommandAndReplyMap(rws::CLEAR_LAST_RESET_STATUS, 1, nullptr,
|
||||
rws::SIZE_CLEAR_RESET_STATUS);
|
||||
this->insertInCommandAndReplyMap(rws::GET_RW_STATUS, 1, &statusSet, rws::SIZE_GET_RW_STATUS);
|
||||
this->insertInCommandAndReplyMap(rws::INIT_RW_CONTROLLER, 1, nullptr, rws::SIZE_INIT_RW);
|
||||
this->insertInCommandAndReplyMap(rws::GET_TEMPERATURE, 1, nullptr,
|
||||
rws::SIZE_GET_TEMPERATURE_REPLY);
|
||||
this->insertInCommandAndReplyMap(rws::SET_SPEED, 1, nullptr, rws::SIZE_SET_SPEED_REPLY);
|
||||
this->insertInCommandAndReplyMap(rws::GET_TM, 1, &tmDataset, rws::SIZE_GET_TELEMETRY_REPLY);
|
||||
}
|
||||
|
||||
ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
uint8_t replyByte = *start;
|
||||
switch (replyByte) {
|
||||
case (RwDefinitions::GET_LAST_RESET_STATUS): {
|
||||
*foundLen = RwDefinitions::SIZE_GET_RESET_STATUS;
|
||||
*foundId = RwDefinitions::GET_LAST_RESET_STATUS;
|
||||
case (rws::GET_LAST_RESET_STATUS): {
|
||||
*foundLen = rws::SIZE_GET_RESET_STATUS;
|
||||
*foundId = rws::GET_LAST_RESET_STATUS;
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::CLEAR_LAST_RESET_STATUS): {
|
||||
*foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS;
|
||||
*foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS;
|
||||
case (rws::CLEAR_LAST_RESET_STATUS): {
|
||||
*foundLen = rws::SIZE_CLEAR_RESET_STATUS;
|
||||
*foundId = rws::CLEAR_LAST_RESET_STATUS;
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::GET_RW_STATUS): {
|
||||
*foundLen = RwDefinitions::SIZE_GET_RW_STATUS;
|
||||
*foundId = RwDefinitions::GET_RW_STATUS;
|
||||
case (rws::GET_RW_STATUS): {
|
||||
*foundLen = rws::SIZE_GET_RW_STATUS;
|
||||
*foundId = rws::GET_RW_STATUS;
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::INIT_RW_CONTROLLER): {
|
||||
*foundLen = RwDefinitions::SIZE_INIT_RW;
|
||||
*foundId = RwDefinitions::INIT_RW_CONTROLLER;
|
||||
case (rws::INIT_RW_CONTROLLER): {
|
||||
*foundLen = rws::SIZE_INIT_RW;
|
||||
*foundId = rws::INIT_RW_CONTROLLER;
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::SET_SPEED): {
|
||||
*foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY;
|
||||
*foundId = RwDefinitions::SET_SPEED;
|
||||
case (rws::SET_SPEED): {
|
||||
*foundLen = rws::SIZE_SET_SPEED_REPLY;
|
||||
*foundId = rws::SET_SPEED;
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::GET_TEMPERATURE): {
|
||||
*foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY;
|
||||
*foundId = RwDefinitions::GET_TEMPERATURE;
|
||||
case (rws::GET_TEMPERATURE): {
|
||||
*foundLen = rws::SIZE_GET_TEMPERATURE_REPLY;
|
||||
*foundId = rws::GET_TEMPERATURE;
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::GET_TM): {
|
||||
*foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY;
|
||||
*foundId = RwDefinitions::GET_TM;
|
||||
case (rws::GET_TM): {
|
||||
*foundLen = rws::SIZE_GET_TELEMETRY_REPLY;
|
||||
*foundId = rws::GET_TM;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -221,7 +217,7 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize
|
||||
|
||||
ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||
/** Check result code */
|
||||
if (*(packet + 1) == RwDefinitions::STATE_ERROR) {
|
||||
if (*(packet + 1) == rws::STATE_ERROR) {
|
||||
sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id
|
||||
<< std::endl;
|
||||
return EXECUTION_FAILED;
|
||||
@ -236,24 +232,24 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_
|
||||
}
|
||||
|
||||
switch (id) {
|
||||
case (RwDefinitions::GET_LAST_RESET_STATUS): {
|
||||
case (rws::GET_LAST_RESET_STATUS): {
|
||||
handleResetStatusReply(packet);
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::GET_RW_STATUS): {
|
||||
case (rws::GET_RW_STATUS): {
|
||||
handleGetRwStatusReply(packet);
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::CLEAR_LAST_RESET_STATUS):
|
||||
case (RwDefinitions::INIT_RW_CONTROLLER):
|
||||
case (RwDefinitions::SET_SPEED):
|
||||
case (rws::CLEAR_LAST_RESET_STATUS):
|
||||
case (rws::INIT_RW_CONTROLLER):
|
||||
case (rws::SET_SPEED):
|
||||
// no reply data expected
|
||||
break;
|
||||
case (RwDefinitions::GET_TEMPERATURE): {
|
||||
case (rws::GET_TEMPERATURE): {
|
||||
handleTemperatureReply(packet);
|
||||
break;
|
||||
}
|
||||
case (RwDefinitions::GET_TM): {
|
||||
case (rws::GET_TM): {
|
||||
handleGetTelemetryReply(packet);
|
||||
break;
|
||||
}
|
||||
@ -270,43 +266,43 @@ uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { retur
|
||||
|
||||
ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
localDataPoolMap.emplace(RwDefinitions::RW_SPEED, &rwSpeed);
|
||||
localDataPoolMap.emplace(RwDefinitions::RAMP_TIME, &rampTime);
|
||||
localDataPoolMap.emplace(rws::RW_SPEED, &rwSpeed);
|
||||
localDataPoolMap.emplace(rws::RAMP_TIME, &rampTime);
|
||||
|
||||
localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::TEMPERATURE_C, new PoolEntry<int32_t>({0}));
|
||||
|
||||
localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::CURR_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::REFERENCE_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::STATE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::CLC_MODE, new PoolEntry<uint8_t>({0}));
|
||||
|
||||
localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::LAST_RESET_STATUS, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::CURRRENT_RESET_STATUS, new PoolEntry<uint8_t>({0}));
|
||||
|
||||
localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry<float>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry<float>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::TM_LAST_RESET_STATUS, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::TM_MCU_TEMPERATURE, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry<float>({0}));
|
||||
localDataPoolMap.emplace(rws::PRESSURE, new PoolEntry<float>({0}));
|
||||
localDataPoolMap.emplace(rws::TM_RW_STATE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::TM_CLC_MODE, new PoolEntry<uint8_t>({0}));
|
||||
localDataPoolMap.emplace(rws::TM_RW_CURR_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::TM_RW_REF_SPEED, new PoolEntry<int32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::INVALID_CRC_PACKETS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::INVALID_LEN_PACKETS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::INVALID_CMD_PACKETS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::EXECUTED_REPLIES, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::COMMAND_REPLIES, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_BYTES_WRITTEN, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_BYTES_READ, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_PARITY_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_NOISE_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_FRAME_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::UART_TOTAL_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::SPI_BYTES_WRITTEN, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::SPI_BYTES_READ, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::SPI_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
localDataPoolMap.emplace(rws::SPI_TOTAL_ERRORS, new PoolEntry<uint32_t>({0}));
|
||||
poolManager.subscribeForDiagPeriodicPacket(
|
||||
subdp::DiagnosticsHkPeriodicParams(statusSet.getSid(), false, 5.0));
|
||||
poolManager.subscribeForRegularPeriodicPacket(
|
||||
@ -343,7 +339,7 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime() {
|
||||
}
|
||||
|
||||
ReturnValue_t RwHandler::prepareSetSpeedCmd() {
|
||||
commandBuffer[0] = static_cast<uint8_t>(RwDefinitions::SET_SPEED);
|
||||
commandBuffer[0] = static_cast<uint8_t>(rws::SET_SPEED);
|
||||
uint8_t* serPtr = commandBuffer + 1;
|
||||
size_t serSize = 1;
|
||||
rwSpeedActuationSet.setValidityBufferGeneration(false);
|
||||
@ -369,7 +365,7 @@ void RwHandler::handleResetStatusReply(const uint8_t* packet) {
|
||||
if (resetStatus != 0) {
|
||||
internalState = InternalState::CLEAR_RESET_STATUS;
|
||||
lastResetStatusSet.lastNonClearedResetStatus = resetStatus;
|
||||
triggerEvent(RwDefinitions::RESET_OCCURED, resetStatus, 0);
|
||||
triggerEvent(rws::RESET_OCCURED, resetStatus, 0);
|
||||
}
|
||||
lastResetStatusSet.currentResetStatus = resetStatus;
|
||||
if (debugMode) {
|
||||
@ -408,10 +404,10 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) {
|
||||
|
||||
statusSet.setValidity(true, true);
|
||||
|
||||
if (statusSet.state == RwDefinitions::STATE_ERROR) {
|
||||
if (statusSet.state == rws::STATE_ERROR) {
|
||||
// This requires the commanding of the init reaction wheel controller command to recover
|
||||
// from error state which must be handled by the FDIR instance.
|
||||
triggerEvent(RwDefinitions::ERROR_STATE, statusSet.state.value, 0);
|
||||
triggerEvent(rws::ERROR_STATE, statusSet.state.value, 0);
|
||||
sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user