From 53aca633b8249822198274f05cf0c58e7f7e5d3e Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 30 Mar 2022 16:29:58 +0200 Subject: [PATCH] write lcl config register --- linux/obc/PdecHandler.cpp | 2 ++ mission/devices/SyrlinksHkHandler.cpp | 28 ++++++++++++++++++- mission/devices/SyrlinksHkHandler.h | 5 +++- .../devicedefinitions/SyrlinksDefinitions.h | 3 +- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index b302d99e..48816512 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -326,6 +326,7 @@ void PdecHandler::handleNewTc() { printTC(tcLength); #endif /* OBSW_DEBUG_PDEC_HANDLER */ +#if OBSW_TC_FROM_PDEC == 1 store_address_t storeId; result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1); if (result != RETURN_OK) { @@ -343,6 +344,7 @@ void PdecHandler::handleNewTc() { tcStore->deleteData(storeId); return; } +#endif /* OBSW_TC_FROM_PDEC == 1 */ return; } diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 15011c55..34b27f42 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -101,6 +101,14 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; return RETURN_OK; } + case (SYRLINKS::READ_LCL_CONFIG): { + readLclConfig.copy(reinterpret_cast(commandBuffer), + readLclConfig.size(), 0); + rawPacketLen = readLclConfig.size(); + rawPacket = commandBuffer; + rememberCommandId = SYRLINKS::READ_LCL_CONFIG; + return RETURN_OK; + } case (SYRLINKS::READ_TX_STATUS): { readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); rawPacketLen = readTxStatus.size(); @@ -144,8 +152,10 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { false, true, SYRLINKS::ACK_REPLY); this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 2, nullptr, SYRLINKS::ACK_SIZE, false, + this->insertInCommandAndReplyMap(SYRLINKS::WRITE_LCL_CONFIG, 1, nullptr, SYRLINKS::ACK_SIZE, false, true, SYRLINKS::ACK_REPLY); + this->insertInCommandAndReplyMap(SYRLINKS::READ_LCL_CONFIG, 1, nullptr, + SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset, @@ -241,6 +251,15 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons } parseRxStatusRegistersReply(packet); break; + case (SYRLINKS::READ_LCL_CONFIG): + result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + if (result != RETURN_OK) { + sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read config lcl reply " + << "has invalid crc" << std::endl; + return CRC_FAILURE; + } + parseLclConfigReply(packet); + break; case (SYRLINKS::READ_TX_STATUS): result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { @@ -427,6 +446,13 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { #endif } +void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) { + uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint8_t lclConfig = convertHexStringToUint8(reinterpret_cast(packet + offset)); + sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " + << static_cast(lclConfig) << std::endl; +} + void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 922cf0d1..5f9e461b 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -68,11 +68,12 @@ class SyrlinksHkHandler : public DeviceHandlerBase { /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ std::string setTxModeModulation = ""; std::string setTxModeCw = ""; - std::string writeLclConfig = ""; + std::string writeLclConfig = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; std::string readTxAgcValueHighByte = ""; std::string readTxAgcValueLowByte = ""; + std::string readLclConfig = ""; /** * In some cases it is not possible to extract from the received reply the information about @@ -162,6 +163,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { */ void parseRxStatusRegistersReply(const uint8_t* packet); + void parseLclConfigReply(const uint8_t* packet); + /** * @brief This function writes the read tx status register to the txStatusDataset. * @param packet Pointer to the received packet. diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 268cb9ea..7399f2ac 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -18,7 +18,8 @@ static const DeviceCommandId_t READ_TX_STATUS = 0x07; static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08; static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09; static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A; -static const DeviceCommandId_t WRITE_LCL_CONFIG = 0x0B; +static const DeviceCommandId_t WRITE_LCL_CONFIG = 11; +static const DeviceCommandId_t READ_LCL_CONFIG = 12; /** Size of a simple transmission success response */ static const uint8_t ACK_SIZE = 12;