From e89719e398d506aecf3d2c61c3e3f1e3eaa47268 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Wed, 30 Jun 2021 08:21:14 +0200 Subject: [PATCH] save before using prepareDataLessCmd --- mission/devices/RwHandler.cpp | 56 ++++++++++-- mission/devices/RwHandler.h | 1 + .../devices/devicedefinitions/RwDefinitions.h | 91 ++++++++++++++++++- tmtc | 2 +- 4 files changed, 138 insertions(+), 12 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index a5f6dbef..b637cbba 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -7,7 +7,7 @@ RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this), lastResetStatusSet(this) { + temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) { if (comCookie == NULL) { sif::error << "RwHandler: Invalid com cookie" << std::endl; } @@ -113,6 +113,10 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand prepareGetTemperatureCmd(); return RETURN_OK; } + case (RwDefinitions::GET_TM): { + prepareGetTelemetryCmd(); + return RETURN_OK; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -246,6 +250,29 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry( { 0 })); + return RETURN_OK; } @@ -312,15 +339,6 @@ void RwHandler::prepareInitRwCommand() { rawPacketLen = 3; } -void RwHandler::prepareGetTemperatureCmd() { - commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); @@ -340,6 +358,24 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa rawPacketLen = 9; } +void RwHandler::prepareGetTemperatureCmd() { + commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + +void RwHandler::prepareGetTelemetryCmd() { + commandBuffer[0] = static_cast(RwDefinitions::GET_TM); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + void RwHandler::handleResetStatusReply(const uint8_t* packet) { PoolReadGuard rg(&lastResetStatusSet); uint8_t offset = 2; diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 11fb4a30..e447932d 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -88,6 +88,7 @@ private: RwDefinitions::TemperatureSet temperatureSet; RwDefinitions::StatusSet statusSet; RwDefinitions::LastResetSatus lastResetStatusSet; + RwDefinitions::TmDataset tmDataset; uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index fbdbd5cf..a477f47c 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -17,7 +17,30 @@ enum PoolIds: lp_id_t { STATE, CLC_MODE, LAST_RESET_STATUS, - CURRRENT_RESET_STATUS + CURRRENT_RESET_STATUS, + TM_LAST_RESET_STATUS, + TM_MCU_TEMPERATURE, + TM_RW_STATE, + TM_CLC_MODE, + TM_RW_CURR_SPEED, + TM_RW_REF_SPEED, + INVALID_CRC_PACKETS, + INVALID_LEN_PACKETS, + INVALID_CMD_PACKETS, + EXECUTED_REPLIES, + COMMAND_REPLIES, + UART_BYTES_WRITTEN, + UART_BYTES_READ, + UART_PARITY_ERRORS, + UART_NOISE_ERRORS, + UART_FRAME_ERRORS, + UART_REG_OVERRUN_ERRORS, + UART_TOTAL_ERRORS, + TOTAL_ERRORS, + SPI_BYTES_WRITTEN, + SPI_BYTES_READ, + SPI_REG_OVERRUN_ERRORS, + SPI_TOTAL_ERRORS }; enum States: uint8_t { @@ -46,10 +69,12 @@ static const DeviceCommandId_t GET_RW_STATUS = 4; static const DeviceCommandId_t INIT_RW_CONTROLLER = 5; static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; +static const DeviceCommandId_t GET_TM = 9; static const uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; static const uint32_t STATUS_SET_ID = GET_RW_STATUS; static const uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS; +static const uint32_t TM_SET_ID = GET_TM; static const size_t SIZE_GET_RESET_STATUS = 5; static const size_t SIZE_CLEAR_RESET_STATUS = 4; @@ -67,6 +92,7 @@ static const size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; static const uint8_t LAST_RESET_ENTRIES = 2; static const uint8_t TEMPERATURE_SET_ENTRIES = 1; static const uint8_t STATUS_SET_ENTRIES = 4; +static const uint8_t TM_SET_ENTRIES = 22; /** * @brief This dataset can be used to store the temperature of a reaction wheel. @@ -133,6 +159,69 @@ public: PoolIds::CURRRENT_RESET_STATUS, this); }; +/** + * @brief This dataset stores telemetry data as specified in the datasheet of the nano avionics + * reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/ + * EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 + */ +class TmDataset: + public StaticLocalDataSet { +public: + + TmDataset(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, TM_SET_ID) { + } + + TmDataset(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) { + } + + lp_var_t lastResetStatus = lp_var_t(sid.objectId, + PoolIds::TM_LAST_RESET_STATUS, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, + PoolIds::TM_MCU_TEMPERATURE, this); + lp_var_t rwState = lp_var_t(sid.objectId, + PoolIds::TM_RW_STATE, this); + lp_var_t rwClcMode = lp_var_t(sid.objectId, + PoolIds::TM_CLC_MODE, this); + lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, + PoolIds::TM_RW_CURR_SPEED, this); + lp_var_t rwRefSpeed = lp_var_t(sid.objectId, + PoolIds::TM_RW_REF_SPEED, this); + lp_var_t numOfInvalidCrcPackets = lp_var_t(sid.objectId, + PoolIds::INVALID_CRC_PACKETS, this); + lp_var_t numOfInvalidLenPackets = lp_var_t(sid.objectId, + PoolIds::INVALID_LEN_PACKETS, this); + lp_var_t numOfInvalidCmdPackets = lp_var_t(sid.objectId, + PoolIds::INVALID_CMD_PACKETS, this); + lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, + PoolIds::EXECUTED_REPLIES, this); + lp_var_t numOfCmdeplies = lp_var_t(sid.objectId, + PoolIds::COMMAND_REPLIES, this); + lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, + PoolIds::UART_BYTES_WRITTEN, this); + lp_var_t uartNumOfBytesRead = lp_var_t(sid.objectId, + PoolIds::UART_BYTES_READ, this); + lp_var_t uartNumOfParityErrors = lp_var_t(sid.objectId, + PoolIds::UART_PARITY_ERRORS, this); + lp_var_t uartNumOfNoiseErrors = lp_var_t(sid.objectId, + PoolIds::UART_NOISE_ERRORS, this); + lp_var_t uartNumOfFrameErrors = lp_var_t(sid.objectId, + PoolIds::UART_FRAME_ERRORS, this); + lp_var_t uartNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, + PoolIds::UART_REG_OVERRUN_ERRORS, this); + lp_var_t uartTotalNumOfErrors = lp_var_t(sid.objectId, + PoolIds::UART_TOTAL_ERRORS, this); + lp_var_t spiNumOfBytesWritten = lp_var_t(sid.objectId, + PoolIds::SPI_BYTES_WRITTEN, this); + lp_var_t spiNumOfBytesRead = lp_var_t(sid.objectId, + PoolIds::SPI_BYTES_READ, this); + lp_var_t spiNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, + PoolIds::SPI_REG_OVERRUN_ERRORS, this); + lp_var_t spiTotalNumOfErrors = lp_var_t(sid.objectId, + PoolIds::SPI_TOTAL_ERRORS, this); +}; + } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ diff --git a/tmtc b/tmtc index 09cab194..78b68307 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 09cab1941fad0bbe8fa54234f7513c61e22038ca +Subproject commit 78b68307825754b468404ee4ff006ee87e0bdd5f