From b29a0cd0fb1c570b15ec2ef98c5ce77de6b320bf Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 31 Mar 2022 17:44:29 +0200 Subject: [PATCH 01/10] syrlinks temperature set and temperature protection --- bsp_q7s/core/ObjectFactory.cpp | 2 +- mission/devices/SyrlinksHkHandler.cpp | 383 ++++++++++-------- mission/devices/SyrlinksHkHandler.h | 23 +- .../devicedefinitions/SyrlinksDefinitions.h | 20 +- 4 files changed, 255 insertions(+), 173 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index f9f582e8..f5904969 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -793,7 +793,7 @@ void ObjectFactory::createSolarArrayDeploymentComponents() { void ObjectFactory::createSyrlinksComponents() { UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, UartModes::NON_CANONICAL, - uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE); + uart::SYRLINKS_BAUD, syrlinks::MAX_REPLY_SIZE); syrlinksUartCookie->setParityEven(); new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie, diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 017bd53c..4ee7ec5c 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -9,17 +9,27 @@ SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, Co : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this), + temperatureSet(this), powerSwitch(powerSwitch) { if (comCookie == NULL) { - sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; + sif::warning << "SyrlinksHkHandler: Invalid com cookie" << std::endl; } } SyrlinksHkHandler::~SyrlinksHkHandler() {} void SyrlinksHkHandler::doStartUp() { - if (mode == _MODE_START_UP) { - setMode(MODE_ON); + switch (startupState) { + case StartupState::OFF: { + startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION; + break; + } + case StartupState::DONE: { + setMode(_MODE_TO_ON); + break; + } + default: + break; } } @@ -27,41 +37,41 @@ void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { switch (nextCommand) { - case (SYRLINKS::READ_RX_STATUS_REGISTERS): - *id = SYRLINKS::READ_RX_STATUS_REGISTERS; - nextCommand = SYRLINKS::READ_TX_STATUS; + case (syrlinks::READ_RX_STATUS_REGISTERS): + *id = syrlinks::READ_RX_STATUS_REGISTERS; + nextCommand = syrlinks::READ_TX_STATUS; break; - case (SYRLINKS::READ_TX_STATUS): - *id = SYRLINKS::READ_TX_STATUS; - nextCommand = SYRLINKS::READ_TX_WAVEFORM; + case (syrlinks::READ_TX_STATUS): + *id = syrlinks::READ_TX_STATUS; + nextCommand = syrlinks::READ_TX_WAVEFORM; break; - case (SYRLINKS::READ_TX_WAVEFORM): - *id = SYRLINKS::READ_TX_WAVEFORM; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + case (syrlinks::READ_TX_WAVEFORM): + *id = syrlinks::READ_TX_WAVEFORM; + nextCommand = syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE; break; - case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; - nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + case (syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE): + *id = syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE; + nextCommand = syrlinks::READ_TX_AGC_VALUE_LOW_BYTE; break; - case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - *id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; - nextCommand = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; + case (syrlinks::READ_TX_AGC_VALUE_LOW_BYTE): + *id = syrlinks::READ_TX_AGC_VALUE_LOW_BYTE; + nextCommand = syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE; break; - case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): - *id = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; - nextCommand = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; + case (syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE): + *id = syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE; + nextCommand = syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE; break; - case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): - *id = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; - nextCommand = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; + case (syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE): + *id = syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE; + nextCommand = syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE; break; - case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): - *id = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; - nextCommand = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; + case (syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE): + *id = syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE; + nextCommand = syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE; break; - case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): - *id = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; - nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + case (syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE): + *id = syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE; + nextCommand = syrlinks::READ_RX_STATUS_REGISTERS; break; default: sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid" @@ -72,111 +82,123 @@ ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) } ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - return HasReturnvaluesIF::RETURN_OK; + switch (startupState) { + case StartupState::ENABLE_TEMPERATURE_PROTECTION: { + *id = syrlinks::WRITE_LCL_CONFIG; + return HasReturnvaluesIF::RETURN_OK; + } + default: + break; + } + return NOTHING_TO_SEND; } ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { switch (deviceCommand) { - case (SYRLINKS::RESET_UNIT): { + case (syrlinks::RESET_UNIT): { resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); rawPacketLen = resetCommand.size(); rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::SET_TX_MODE_STANDBY): { + case (syrlinks::SET_TX_MODE_STANDBY): { setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); rawPacketLen = setTxModeStandby.size(); rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::SET_TX_MODE_MODULATION): { + case (syrlinks::SET_TX_MODE_MODULATION): { setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), 0); rawPacketLen = setTxModeModulation.size(); rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::SET_TX_MODE_CW): { + case (syrlinks::SET_TX_MODE_CW): { setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); rawPacketLen = setTxModeCw.size(); rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::WRITE_LCL_CONFIG): { + case (syrlinks::WRITE_LCL_CONFIG): { writeLclConfig.copy(reinterpret_cast(commandBuffer), writeLclConfig.size(), 0); rawPacketLen = writeLclConfig.size(); rawPacket = commandBuffer; + rememberCommandId = syrlinks::WRITE_LCL_CONFIG; return RETURN_OK; } - case (SYRLINKS::READ_RX_STATUS_REGISTERS): { + case (syrlinks::READ_RX_STATUS_REGISTERS): { readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), readRxStatusRegCommand.size(), 0); rawPacketLen = readRxStatusRegCommand.size(); rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::READ_LCL_CONFIG): { + case (syrlinks::READ_LCL_CONFIG): { readLclConfig.copy(reinterpret_cast(commandBuffer), readLclConfig.size(), 0); rawPacketLen = readLclConfig.size(); rawPacket = commandBuffer; - rememberCommandId = SYRLINKS::READ_LCL_CONFIG; + rememberCommandId = syrlinks::READ_LCL_CONFIG; return RETURN_OK; } - case (SYRLINKS::READ_TX_STATUS): { + case (syrlinks::READ_TX_STATUS): { readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); rawPacketLen = readTxStatus.size(); - rememberCommandId = SYRLINKS::READ_TX_STATUS; + rememberCommandId = syrlinks::READ_TX_STATUS; rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::READ_TX_WAVEFORM): { + case (syrlinks::READ_TX_WAVEFORM): { readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxWaveform.size(), 0); rawPacketLen = readTxWaveform.size(); - rememberCommandId = SYRLINKS::READ_TX_WAVEFORM; + rememberCommandId = syrlinks::READ_TX_WAVEFORM; rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxAgcValueHighByte.size(), 0); + case (syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE): { + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), + readTxAgcValueHighByte.size(), 0); rawPacketLen = readTxAgcValueHighByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; + rememberCommandId = syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxAgcValueLowByte.size(), 0); + case (syrlinks::READ_TX_AGC_VALUE_LOW_BYTE): { + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), + readTxAgcValueLowByte.size(), 0); rawPacketLen = readTxAgcValueLowByte.size(); - rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; + rememberCommandId = syrlinks::READ_TX_AGC_VALUE_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; } - case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): - tempPowerAmpBoardHighByte.copy(reinterpret_cast(commandBuffer), tempPowerAmpBoardHighByte.size(), - 0); + case (syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE): + tempPowerAmpBoardHighByte.copy(reinterpret_cast(commandBuffer), + tempPowerAmpBoardHighByte.size(), 0); rawPacketLen = tempPowerAmpBoardHighByte.size(); - rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; + rememberCommandId = syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; - case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): - tempPowerAmpBoardLowByte.copy(reinterpret_cast(commandBuffer), tempPowerAmpBoardLowByte.size(), - 0); + case (syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE): + tempPowerAmpBoardLowByte.copy(reinterpret_cast(commandBuffer), + tempPowerAmpBoardLowByte.size(), 0); rawPacketLen = tempPowerAmpBoardLowByte.size(); - rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; + rememberCommandId = syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; - case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): - tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardHighByte.size(), - 0); + case (syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE): + tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), + tempBasebandBoardHighByte.size(), 0); rawPacketLen = tempBasebandBoardHighByte.size(); - rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; + rememberCommandId = syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; - case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): - tempBasebandBoardLowByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardLowByte.size(), 0); + case (syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE): + tempBasebandBoardLowByte.copy(reinterpret_cast(commandBuffer), + tempBasebandBoardLowByte.size(), 0); rawPacketLen = tempBasebandBoardLowByte.size(); - rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; + rememberCommandId = syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; default: @@ -186,36 +208,36 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic } void SyrlinksHkHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT, 1, nullptr, SYRLINKS::ACK_SIZE, false, - true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY, 1, nullptr, SYRLINKS::ACK_SIZE, - false, true, SYRLINKS::ACK_REPLY); - this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION, 1, nullptr, SYRLINKS::ACK_SIZE, - 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, 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, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE, 1, nullptr, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE, 1, nullptr, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE, 1, nullptr, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE, 1, nullptr, - SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); - this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxDataset, - SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + this->insertInCommandAndReplyMap(syrlinks::RESET_UNIT, 1, nullptr, syrlinks::ACK_SIZE, false, + true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_TX_MODE_STANDBY, 1, nullptr, syrlinks::ACK_SIZE, + false, true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_TX_MODE_MODULATION, 1, nullptr, syrlinks::ACK_SIZE, + 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, 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, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::READ_TX_AGC_VALUE_LOW_BYTE, 1, &txDataset, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE, 1, nullptr, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE, 1, nullptr, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE, 1, nullptr, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE, 1, nullptr, + syrlinks::READ_ONE_REGISTER_REPLY_SIE); + this->insertInCommandAndReplyMap(syrlinks::READ_RX_STATUS_REGISTERS, 1, &rxDataset, + syrlinks::RX_STATUS_REGISTERS_REPLY_SIZE); } ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize, @@ -223,25 +245,25 @@ ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remai ReturnValue_t result = RETURN_OK; if (*start != '<') { - sif::error << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; + sif::warning << "SyrlinksHkHandler::scanForReply: Missing start frame character" << std::endl; return MISSING_START_FRAME_CHARACTER; } switch (*(start + 1)) { case ('A'): - *foundLen = SYRLINKS::ACK_SIZE; - *foundId = SYRLINKS::ACK_REPLY; + *foundLen = syrlinks::ACK_SIZE; + *foundId = syrlinks::ACK_REPLY; break; case ('E'): - *foundLen = SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE; - *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; + *foundLen = syrlinks::RX_STATUS_REGISTERS_REPLY_SIZE; + *foundId = syrlinks::READ_RX_STATUS_REGISTERS; break; case ('R'): *foundId = rememberCommandId; - *foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE; + *foundLen = syrlinks::READ_ONE_REGISTER_REPLY_SIE; break; default: - sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; + sif::warning << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl; result = IGNORE_REPLY_DATA; break; } @@ -262,124 +284,142 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons ReturnValue_t result; switch (id) { - case (SYRLINKS::ACK_REPLY): - result = verifyReply(packet, SYRLINKS::ACK_SIZE); + case (syrlinks::ACK_REPLY): { + result = verifyReply(packet, syrlinks::ACK_SIZE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgment reply has " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgment reply has " "invalid crc" << std::endl; return CRC_FAILURE; } - result = - parseReplyStatus(reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + result = handleAckReply(packet); if (result != RETURN_OK) { return result; } break; - case (SYRLINKS::READ_RX_STATUS_REGISTERS): - result = verifyReply(packet, SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); + } + case (syrlinks::READ_RX_STATUS_REGISTERS): { + result = verifyReply(packet, syrlinks::RX_STATUS_REGISTERS_REPLY_SIZE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " << "has invalid crc" << std::endl; return CRC_FAILURE; } parseRxStatusRegistersReply(packet); break; - case (SYRLINKS::READ_LCL_CONFIG): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + 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 " + sif::warning << "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); + } + case (syrlinks::READ_TX_STATUS): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " << "has invalid crc" << std::endl; return CRC_FAILURE; } parseTxStatusReply(packet); break; - case (SYRLINKS::READ_TX_WAVEFORM): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::READ_TX_WAVEFORM): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " << "has invalid crc" << std::endl; return CRC_FAILURE; } parseTxWaveformReply(packet); break; - case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " << "has invalid crc" << std::endl; return CRC_FAILURE; } parseAgcHighByte(packet); break; - case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::READ_TX_AGC_VALUE_LOW_BYTE): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " << "has invalid crc" << std::endl; return CRC_FAILURE; } parseAgcLowByte(packet); break; - case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board " << "high byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast( - packet + SYRLINKS::MESSAGE_HEADER_SIZE)) + packet + syrlinks::MESSAGE_HEADER_SIZE)) << 8; break; - case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board" + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board" " low byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempBasebandBoard |= convertHexStringToUint8( - reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + reinterpret_cast(packet + syrlinks::MESSAGE_HEADER_SIZE)); tempBasebandBoard = calcTempVal(rawTempBasebandBoard); - sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" - << std::endl; + temperatureSet.temperatureBasebandBoard = tempBasebandBoard; + PoolReadGuard rg(&temperatureSet); + if (debug) { + sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" + << std::endl; + } break; - case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier " + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier " << "board high byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempPowerAmplifier = 0; rawTempPowerAmplifier = convertHexStringToUint8(reinterpret_cast( - packet + SYRLINKS::MESSAGE_HEADER_SIZE)) - << 8; + packet + syrlinks::MESSAGE_HEADER_SIZE)) + << 8; break; - case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): - result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); + } + case (syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE): { + result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { - sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier" + sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier" << " board low byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempPowerAmplifier |= convertHexStringToUint8( - reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); + reinterpret_cast(packet + syrlinks::MESSAGE_HEADER_SIZE)); tempPowerAmplifier = calcTempVal(rawTempPowerAmplifier); - sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C" - << std::endl; + PoolReadGuard rg(&temperatureSet); + temperatureSet.temperaturePowerAmplifier = tempPowerAmplifier; + if (debug) { + sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier + << " °C" << std::endl; + } break; + } default: { sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; @@ -394,8 +434,10 @@ LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { return &rxDataset; } else if (sid == txDataset.getSid()) { return &txDataset; + } else if (sid == temperatureSet.getSid()) { + return &temperatureSet; } else { - sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; + sif::warning << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl; return nullptr; } } @@ -479,11 +521,11 @@ ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size int result = 0; /* Calculate crc from received packet */ uint16_t crc = - CRC::crc16ccitt(packet, size - SYRLINKS::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE); + CRC::crc16ccitt(packet, size - syrlinks::SIZE_CRC_AND_TERMINATION, CRC_INITIAL_VALUE); std::string recalculatedCrc = convertUint16ToHexString(crc); const char* startOfCrc = - reinterpret_cast(packet + size - SYRLINKS::SIZE_CRC_AND_TERMINATION); + reinterpret_cast(packet + size - syrlinks::SIZE_CRC_AND_TERMINATION); const char* endOfCrc = reinterpret_cast(packet + size - 1); std::string replyCrc(startOfCrc, endOfCrc); @@ -497,7 +539,7 @@ ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { PoolReadGuard readHelper(&rxDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); offset += 2; rxDataset.rxSensitivity = @@ -531,7 +573,7 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { } void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) { - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + 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; @@ -539,7 +581,7 @@ void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) { void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value @@ -549,7 +591,7 @@ void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value @@ -559,7 +601,7 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 @@ -569,7 +611,7 @@ void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); - uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; + uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); } @@ -579,18 +621,18 @@ uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(SYRLINKS::RX_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_SENSITIVITY, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_FREQUENCY_SHIFT, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_IQ_POWER, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_AGC_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_EB, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_DEMOD_N0, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::RX_DATA_RATE, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_SENSITIVITY, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_FREQUENCY_SHIFT, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_IQ_POWER, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_DEMOD_EB, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_DEMOD_N0, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::RX_DATA_RATE, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_WAVEFORM, new PoolEntry({0})); - localDataPoolMap.emplace(SYRLINKS::TX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::TX_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::TX_WAVEFORM, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::TX_AGC_VALUE, new PoolEntry({0})); return HasReturnvaluesIF::RETURN_OK; } @@ -598,3 +640,14 @@ ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& lo void SyrlinksHkHandler::setModeNormal() { mode = MODE_NORMAL; } float SyrlinksHkHandler::calcTempVal(uint16_t raw) { return 0.126984 * raw - 67.87; } + +ReturnValue_t SyrlinksHkHandler::handleAckReply(const uint8_t* packet) { + ReturnValue_t result = + parseReplyStatus(reinterpret_cast(packet + syrlinks::MESSAGE_HEADER_SIZE)); + if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result != RETURN_OK) { + startupState = StartupState::OFF; + } else if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result == RETURN_OK) { + startupState = StartupState::DONE; + } + return result; +} diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 9b9e05c2..b330f151 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -80,10 +80,11 @@ class SyrlinksHkHandler : public DeviceHandlerBase { * In some cases it is not possible to extract from the received reply the information about * the associated command. This variable is thus used to remember the command id. */ - DeviceCommandId_t rememberCommandId = SYRLINKS::NONE; + DeviceCommandId_t rememberCommandId = syrlinks::NONE; - SYRLINKS::RxDataset rxDataset; - SYRLINKS::TxDataset txDataset; + syrlinks::RxDataset rxDataset; + syrlinks::TxDataset txDataset; + syrlinks::TemperatureSet temperatureSet; const power::Switch_t powerSwitch = power::NO_SWITCH; @@ -93,13 +94,23 @@ class SyrlinksHkHandler : public DeviceHandlerBase { float tempPowerAmplifier = 0; float tempBasebandBoard = 0; - uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE]; + uint8_t commandBuffer[syrlinks::MAX_COMMAND_SIZE]; + + enum class StartupState { + OFF, + ENABLE_TEMPERATURE_PROTECTION, + DONE + }; + + StartupState startupState = StartupState::OFF; + + bool debug = false; /** * This object is used to store the id of the next command to execute. This controls the * read out of multiple registers which can not be fetched with one single command. */ - DeviceCommandId_t nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS; + DeviceCommandId_t nextCommand = syrlinks::READ_RX_STATUS_REGISTERS; /** * @brief This function converts an uint16_t into its hexadecimal string representation. @@ -192,6 +203,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { * @brief Calculates temperature in degree celcius form raw value */ float calcTempVal(uint16_t); + + ReturnValue_t handleAckReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index affebff7..e8973621 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -1,7 +1,7 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ -namespace SYRLINKS { +namespace syrlinks { static const DeviceCommandId_t NONE = 0; static const DeviceCommandId_t RESET_UNIT = 1; @@ -36,6 +36,7 @@ static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13; static const uint8_t RX_DATASET_ID = 0x1; static const uint8_t TX_DATASET_ID = 0x2; +static const uint8_t TEMPERATURE_SET_ID = 0x3; static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE; static const size_t MAX_COMMAND_SIZE = 15; @@ -44,6 +45,7 @@ static const size_t CRC_FIELD_SIZE = 4; static const uint8_t RX_DATASET_SIZE = 8; static const uint8_t TX_DATASET_SIZE = 3; +static const uint8_t TEMPERATURE_SET_SIZE = 3; enum SyrlinksPoolIds : lp_id_t { RX_STATUS, @@ -60,6 +62,8 @@ enum SyrlinksPoolIds : lp_id_t { TX_WAVEFORM, TX_PCM_INDEX, TX_AGC_VALUE, + TEMP_POWER_AMPLIFIER, + TEMP_BASEBAND_BOARD }; class RxDataset : public StaticLocalDataSet { @@ -89,6 +93,18 @@ class TxDataset : public StaticLocalDataSet { lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); }; -} // namespace SYRLINKS +class TemperatureSet : public StaticLocalDataSet { + public: + TemperatureSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TEMPERATURE_SET_ID) {} + + TemperatureSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) {} + + lp_var_t temperaturePowerAmplifier = + lp_var_t(sid.objectId, TEMP_POWER_AMPLIFIER, this); + lp_var_t temperatureBasebandBoard = + lp_var_t(sid.objectId, TEMP_BASEBAND_BOARD, this); +}; + +} // namespace syrlinks #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */ -- 2.43.0 From ca1e8f3dc1fffca3802732fea7131dd68b3ea302 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 1 Apr 2022 09:20:35 +0200 Subject: [PATCH 02/10] syrlinks fault flag --- bsp_q7s/boardconfig/busConf.h | 1 + mission/devices/SyrlinksFaultFlagMonitoring.cpp | 16 ++++++++++++++++ mission/devices/SyrlinksFaultFlagMonitoring.h | 17 +++++++++++++++++ mission/devices/SyrlinksHkHandler.cpp | 9 +++++++-- mission/devices/SyrlinksHkHandler.h | 7 ++++++- 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 mission/devices/SyrlinksFaultFlagMonitoring.cpp create mode 100644 mission/devices/SyrlinksFaultFlagMonitoring.h diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 5c52693c..bc6efd7a 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -84,6 +84,7 @@ static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; static constexpr char RS485_EN_RX_CLOCK[] = "rx_clock_enable_ltc2872"; static constexpr char RS485_EN_RX_DATA[] = "rx_data_enable_ltc2872"; static constexpr char PDEC_RESET[] = "pdec_reset"; +static constexpr char SYRLINKS_FAULT[] = "syrlinks_fault"; static constexpr char PL_PCDU_ENABLE_VBAT0[] = "enable_plpcdu_vbat0"; static constexpr char PL_PCDU_ENABLE_VBAT1[] = "enable_plpcdu_vbat1"; diff --git a/mission/devices/SyrlinksFaultFlagMonitoring.cpp b/mission/devices/SyrlinksFaultFlagMonitoring.cpp new file mode 100644 index 00000000..f999a47c --- /dev/null +++ b/mission/devices/SyrlinksFaultFlagMonitoring.cpp @@ -0,0 +1,16 @@ +/* + * SyrlinksFaultFlagMonitoring.cpp + * + * Created on: 01.04.2022 + * Author: jakob + */ + +#include "SyrlinksFaultFlagMonitoring.h" + +SyrlinksFaultFlagMonitoring::SyrlinksFaultFlagMonitoring() { + // TODO Auto-generated constructor stub +} + +SyrlinksFaultFlagMonitoring::~SyrlinksFaultFlagMonitoring() { + // TODO Auto-generated destructor stub +} diff --git a/mission/devices/SyrlinksFaultFlagMonitoring.h b/mission/devices/SyrlinksFaultFlagMonitoring.h new file mode 100644 index 00000000..09869c44 --- /dev/null +++ b/mission/devices/SyrlinksFaultFlagMonitoring.h @@ -0,0 +1,17 @@ +/* + * SyrlinksFaultFlagMonitoring.h + * + * Created on: 01.04.2022 + * Author: jakob + */ + +#ifndef MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ +#define MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ + +class SyrlinksFaultFlagMonitoring : public ExecutableObjectIF { + public: + SyrlinksFaultFlagMonitoring(); + virtual ~SyrlinksFaultFlagMonitoring(); +}; + +#endif /* MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ */ diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 4ee7ec5c..e8680a74 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -5,12 +5,13 @@ #include "OBSWConfig.h" SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch) + power::Switch_t powerSwitch, Gpio fault) : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this), temperatureSet(this), - powerSwitch(powerSwitch) { + powerSwitch(powerSwitch), + fault(fault){ if (comCookie == NULL) { sif::warning << "SyrlinksHkHandler: Invalid com cookie" << std::endl; } @@ -442,6 +443,10 @@ LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { } } +void SyrlinksHkHandler::performOperationHook() { + +} + std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) { std::stringstream stream; stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index b330f151..9b8ac2c9 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -4,6 +4,8 @@ #include "devices/powerSwitcherList.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" +#include "fsfw_hal/linux/gpio/Gpio.h" +#include "fsfw/timemanager/Countdown.h" #include /** @@ -17,7 +19,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { public: SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch); + power::Switch_t powerSwitch, Gpio fault); virtual ~SyrlinksHkHandler(); /** @@ -42,6 +44,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + void performOperationHook(); private: static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; @@ -88,6 +91,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { const power::Switch_t powerSwitch = power::NO_SWITCH; + Gpio fault; + uint8_t agcValueHighByte = 0; uint16_t rawTempPowerAmplifier = 0; uint16_t rawTempBasebandBoard = 0; -- 2.43.0 From 07c242282d933c7f78dd7bc65bf086f07737cdc7 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 1 Apr 2022 14:15:42 +0200 Subject: [PATCH 03/10] syrlinks test --- linux/obc/AxiPtmeConfig.h | 5 +- mission/devices/SyrlinksHkHandler.cpp | 61 ++++++++++++++----- mission/devices/SyrlinksHkHandler.h | 10 +-- .../devicedefinitions/SyrlinksDefinitions.h | 4 ++ mission/tmtc/CCSDSHandler.h | 4 +- tmtc | 2 +- 6 files changed, 62 insertions(+), 24 deletions(-) diff --git a/linux/obc/AxiPtmeConfig.h b/linux/obc/AxiPtmeConfig.h index c86bb429..9a048308 100644 --- a/linux/obc/AxiPtmeConfig.h +++ b/linux/obc/AxiPtmeConfig.h @@ -37,6 +37,8 @@ class AxiPtmeConfig : public SystemObject { * The default implementation of the PTME generates a clock where the high level is * only one bit clock period long. This might be too short to match the setup and hold * times of the S-and transceiver. + * Default: Enables TX clock manipulator + * */ ReturnValue_t enableTxclockManipulator(); ReturnValue_t disableTxclockManipulator(); @@ -47,6 +49,7 @@ class AxiPtmeConfig : public SystemObject { * Enable inversion will update data on falling edge (not the configuration required by the * syrlinks) * Disable clock inversion. Data updated on rising edge. + * Default: Inversion is disabled */ ReturnValue_t enableTxclockInversion(); ReturnValue_t disableTxclockInversion(); @@ -54,7 +57,7 @@ class AxiPtmeConfig : public SystemObject { private: // Address of register storing the bitrate configuration parameter static const uint32_t CADU_BITRATE_REG = 0x0; - // Address to register storing common configuration parameters + // Address of register storing common configuration parameters static const uint32_t COMMON_CONFIG_REG = 0x4; static const uint32_t ADRESS_DIVIDER = 4; diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index e8680a74..31549af5 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -5,13 +5,12 @@ #include "OBSWConfig.h" SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch, Gpio fault) + power::Switch_t powerSwitch) : DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this), temperatureSet(this), - powerSwitch(powerSwitch), - fault(fault){ + powerSwitch(powerSwitch) { if (comCookie == NULL) { sif::warning << "SyrlinksHkHandler: Invalid com cookie" << std::endl; } @@ -20,18 +19,19 @@ SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, Co SyrlinksHkHandler::~SyrlinksHkHandler() {} void SyrlinksHkHandler::doStartUp() { - switch (startupState) { - case StartupState::OFF: { - startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION; - break; - } - case StartupState::DONE: { - setMode(_MODE_TO_ON); - break; - } - default: - break; - } +// switch (startupState) { +// case StartupState::OFF: { +// startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION; +// break; +// } +// case StartupState::DONE: { +// setMode(_MODE_TO_ON); +// break; +// } +// default: +// break; +// } + setMode(_MODE_TO_ON); } void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } @@ -202,6 +202,27 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic rememberCommandId = syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; + case (syrlinks::SET_WAVEFORM_OQPSK): + setWaveformOQPSK.copy(reinterpret_cast(commandBuffer), + setWaveformOQPSK.size(), 0); + rawPacketLen = setWaveformOQPSK.size(); + rememberCommandId = syrlinks::SET_WAVEFORM_OQPSK; + rawPacket = commandBuffer; + return RETURN_OK; + case (syrlinks::SET_WAVEFORM_BPSK): + setWaveformBPSK.copy(reinterpret_cast(commandBuffer), + setWaveformBPSK.size(), 0); + rawPacketLen = setWaveformBPSK.size(); + rememberCommandId = syrlinks::SET_WAVEFORM_BPSK; + rawPacket = commandBuffer; + return RETURN_OK; + case (syrlinks::SET_SECOND_CONFIG): + setSecondConfiguration.copy(reinterpret_cast(commandBuffer), + setSecondConfiguration.size(), 0); + rawPacketLen = setSecondConfiguration.size(); + rememberCommandId = syrlinks::SET_SECOND_CONFIG; + rawPacket = commandBuffer; + return RETURN_OK; default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -219,6 +240,12 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { true, syrlinks::ACK_REPLY); this->insertInCommandAndReplyMap(syrlinks::WRITE_LCL_CONFIG, 1, nullptr, syrlinks::ACK_SIZE, false, true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_OQPSK, 1, nullptr, syrlinks::ACK_SIZE, + false, true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_BPSK, 1, nullptr, syrlinks::ACK_SIZE, + false, true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_SECOND_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, @@ -622,7 +649,7 @@ void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {} -uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } +uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { @@ -638,6 +665,8 @@ ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& lo localDataPoolMap.emplace(syrlinks::TX_STATUS, new PoolEntry({0})); localDataPoolMap.emplace(syrlinks::TX_WAVEFORM, new PoolEntry({0})); localDataPoolMap.emplace(syrlinks::TX_AGC_VALUE, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::TEMP_BASEBAND_BOARD, new PoolEntry({0})); + localDataPoolMap.emplace(syrlinks::TEMP_POWER_AMPLIFIER, new PoolEntry({0})); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 9b8ac2c9..739db450 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -19,7 +19,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { public: SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch, Gpio fault); + power::Switch_t powerSwitch); virtual ~SyrlinksHkHandler(); /** @@ -67,8 +67,12 @@ class SyrlinksHkHandler : public DeviceHandlerBase { std::string setTxModeStandby = ""; /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ std::string setTxModeModulation = ""; +// std::string setSecondConfiguration = ""; + std::string setSecondConfiguration = ""; std::string setTxModeCw = ""; std::string writeLclConfig = ""; + std::string setWaveformOQPSK = ""; + std::string setWaveformBPSK = ""; std::string readTxStatus = ""; std::string readTxWaveform = ""; std::string readTxAgcValueHighByte = ""; @@ -91,8 +95,6 @@ class SyrlinksHkHandler : public DeviceHandlerBase { const power::Switch_t powerSwitch = power::NO_SWITCH; - Gpio fault; - uint8_t agcValueHighByte = 0; uint16_t rawTempPowerAmplifier = 0; uint16_t rawTempBasebandBoard = 0; @@ -109,7 +111,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { StartupState startupState = StartupState::OFF; - bool debug = false; + bool debug = true; /** * This object is used to store the id of the next command to execute. This controls the diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index e8973621..bf964063 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -24,6 +24,10 @@ static const DeviceCommandId_t TEMP_POWER_AMPLIFIER_HIGH_BYTE = 13; static const DeviceCommandId_t TEMP_POWER_AMPLIFIER_LOW_BYTE = 14; static const DeviceCommandId_t TEMP_BASEBAND_BOARD_HIGH_BYTE = 15; static const DeviceCommandId_t TEMP_BASEBAND_BOARD_LOW_BYTE = 16; +static const DeviceCommandId_t SET_WAVEFORM_OQPSK = 17; +static const DeviceCommandId_t SET_WAVEFORM_BPSK = 18; +static const DeviceCommandId_t SET_SECOND_CONFIG = 19; +static const DeviceCommandId_t ENABLE_DEBUG = 20; /** Size of a simple transmission success response */ static const uint8_t ACK_SIZE = 12; diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index a916361b..1c4fde09 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -91,9 +91,9 @@ class CCSDSHandler : public SystemObject, static const ActionId_t ARBITRARY_RATE = 4; static const ActionId_t ENABLE_TX_CLK_MANIPULATOR = 5; static const ActionId_t DISABLE_TX_CLK_MANIPULATOR = 6; - // Will update data with respect to tx clock signal of cadu bitsream on rising edge + // Will update data with respect to tx clock signal of cadu bitstream on rising edge static const ActionId_t UPDATE_ON_RISING_EDGE = 7; - // Will update data with respect to tx clock signal of cadu bitsream on falling edge + // Will update data with respect to tx clock signal of cadu bitstream on falling edge static const ActionId_t UPDATE_ON_FALLING_EDGE = 8; // Syrlinks supports two bitrates (200 kbps and 1000 kbps) diff --git a/tmtc b/tmtc index 5ac8912d..811aedce 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5ac8912dd2b47f01f66093187f15a9f9824ffd66 +Subproject commit 811aedce9762daa87e268b8832f23b0d28f8a714 -- 2.43.0 From d2f54f033f977a63ba1e358373cf8320d0203b68 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 4 Apr 2022 14:58:35 +0200 Subject: [PATCH 04/10] syrlinks --- bsp_hosted/acsDummies/GpsDummy.cpp | 7 + bsp_hosted/acsDummies/GpsDummy.h | 13 + bsp_q7s/core/obsw.cpp | 4 - mission/controller/AcsController.cpp | 48 ++++ mission/controller/AcsController.h | 18 ++ .../devices/SyrlinksFaultFlagMonitoring.cpp | 9 - mission/devices/SyrlinksFaultFlagMonitoring.h | 7 - mission/devices/SyrlinksHkHandler.cpp | 225 +++++++----------- mission/devices/SyrlinksHkHandler.h | 9 +- .../devicedefinitions/SyrlinksDefinitions.h | 7 +- 10 files changed, 185 insertions(+), 162 deletions(-) create mode 100644 bsp_hosted/acsDummies/GpsDummy.cpp create mode 100644 bsp_hosted/acsDummies/GpsDummy.h create mode 100644 mission/controller/AcsController.cpp create mode 100644 mission/controller/AcsController.h diff --git a/bsp_hosted/acsDummies/GpsDummy.cpp b/bsp_hosted/acsDummies/GpsDummy.cpp new file mode 100644 index 00000000..b4331798 --- /dev/null +++ b/bsp_hosted/acsDummies/GpsDummy.cpp @@ -0,0 +1,7 @@ +#include "GpsDummy.h" + +GpsDummy::GpsDummy() { +} + +GpsDummy::~GpsDummy() { +} diff --git a/bsp_hosted/acsDummies/GpsDummy.h b/bsp_hosted/acsDummies/GpsDummy.h new file mode 100644 index 00000000..f25bf1f2 --- /dev/null +++ b/bsp_hosted/acsDummies/GpsDummy.h @@ -0,0 +1,13 @@ +#ifndef BSP_HOSTED_ACSDUMMIES_GPSDUMMY_H_ +#define BSP_HOSTED_ACSDUMMIES_GPSDUMMY_H_ + +/** + * @brief Dummy class to simulate sending of GPS data to ACS controller. + */ +class GpsDummy : public ExtendedControllerBase { + public: + GpsDummy(); + virtual ~GpsDummy(); +}; + +#endif /* BSP_HOSTED_ACSDUMMIES_GPSDUMMY_H_ */ diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index aede1698..27d1484e 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -15,11 +15,7 @@ static int OBSW_ALREADY_RUNNING = -2; int obsw::obsw() { using namespace fsfw; std::cout << "-- EIVE OBSW --" << std::endl; -#ifdef TE0720_1CFA std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; -#else - std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; -#endif std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "--" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp new file mode 100644 index 00000000..28f7032b --- /dev/null +++ b/mission/controller/AcsController.cpp @@ -0,0 +1,48 @@ +#include "AcsController.h" + +AcsController::AcsController() { +} + +AcsController::~AcsController() { +} + +ReturnValue_t AcsController::initialize() { + + ControllerBase::initialize(); +} + +ReturnValue_t AcsController::handleCommandMessage(CommandMessage * message) { + ReturnValue_t result = actionHelper.handleActionMessage(message); + if (result == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } + return result; +} + +void AcsController::performControlOperation() { + if (mode != MODE_OFF) { + monitoring.monitor(&acsParameters); + switch (submode) { + case SUBMODE_SAFE: + performSafe(SAFE_CONTROLLER); + break; + case SUBMODE_IDLE: + performPointing(IDLE_CONTROLLER); + break; + case SUBMODE_NADIR: + performPointing(NADIR_CONTROLLER); + break; + case SUBMODE_TARGET: + performPointing(TARGET_CONTROLLER); + break; + case SUBMODE_INERTIAL: + performPointing(INERTIAL_CONTROLLER); + break; + case SUBMODE_ROTATION: + performPointing(ROTATION_CONTROLLER); + break; + default: + break; + } + } +} diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h new file mode 100644 index 00000000..20f19c15 --- /dev/null +++ b/mission/controller/AcsController.h @@ -0,0 +1,18 @@ +#ifndef MISSION_CONTROLLER_ACSCONTROLLER_H_ +#define MISSION_CONTROLLER_ACSCONTROLLER_H_ + +#include "fsfw/controller/ControllerBase.h" + +class AcsController : public ControllerBase { + public: + AcsController(); + virtual ~AcsController(); + + ReturnValue_t initialize() override; + + protected: + ReturnValue_t handleCommandMessage(CommandMessage *message); + void performControlOperation(); +}; + +#endif /* MISSION_CONTROLLER_ACSCONTROLLER_H_ */ diff --git a/mission/devices/SyrlinksFaultFlagMonitoring.cpp b/mission/devices/SyrlinksFaultFlagMonitoring.cpp index f999a47c..79b752d7 100644 --- a/mission/devices/SyrlinksFaultFlagMonitoring.cpp +++ b/mission/devices/SyrlinksFaultFlagMonitoring.cpp @@ -1,16 +1,7 @@ -/* - * SyrlinksFaultFlagMonitoring.cpp - * - * Created on: 01.04.2022 - * Author: jakob - */ - #include "SyrlinksFaultFlagMonitoring.h" SyrlinksFaultFlagMonitoring::SyrlinksFaultFlagMonitoring() { - // TODO Auto-generated constructor stub } SyrlinksFaultFlagMonitoring::~SyrlinksFaultFlagMonitoring() { - // TODO Auto-generated destructor stub } diff --git a/mission/devices/SyrlinksFaultFlagMonitoring.h b/mission/devices/SyrlinksFaultFlagMonitoring.h index 09869c44..7959ca55 100644 --- a/mission/devices/SyrlinksFaultFlagMonitoring.h +++ b/mission/devices/SyrlinksFaultFlagMonitoring.h @@ -1,10 +1,3 @@ -/* - * SyrlinksFaultFlagMonitoring.h - * - * Created on: 01.04.2022 - * Author: jakob - */ - #ifndef MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ #define MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 31549af5..c64ac747 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -19,19 +19,18 @@ SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, Co SyrlinksHkHandler::~SyrlinksHkHandler() {} void SyrlinksHkHandler::doStartUp() { -// switch (startupState) { -// case StartupState::OFF: { -// startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION; -// break; -// } -// case StartupState::DONE: { -// setMode(_MODE_TO_ON); -// break; -// } -// default: -// break; -// } - setMode(_MODE_TO_ON); + switch (startupState) { + case StartupState::OFF: { + startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION; + break; + } + case StartupState::DONE: { + setMode(_MODE_TO_ON); + break; + } + default: + break; + } } void SyrlinksHkHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } @@ -99,130 +98,81 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic size_t commandDataLen) { switch (deviceCommand) { case (syrlinks::RESET_UNIT): { - resetCommand.copy(reinterpret_cast(commandBuffer), resetCommand.size(), 0); - rawPacketLen = resetCommand.size(); - rawPacket = commandBuffer; + prepareCommand(resetCommand, deviceCommand); return RETURN_OK; } case (syrlinks::SET_TX_MODE_STANDBY): { - setTxModeStandby.copy(reinterpret_cast(commandBuffer), setTxModeStandby.size(), 0); - rawPacketLen = setTxModeStandby.size(); - rawPacket = commandBuffer; + prepareCommand(setTxModeStandby, deviceCommand); return RETURN_OK; } case (syrlinks::SET_TX_MODE_MODULATION): { - setTxModeModulation.copy(reinterpret_cast(commandBuffer), setTxModeModulation.size(), - 0); - rawPacketLen = setTxModeModulation.size(); - rawPacket = commandBuffer; + prepareCommand(setTxModeModulation, deviceCommand); return RETURN_OK; } case (syrlinks::SET_TX_MODE_CW): { - setTxModeCw.copy(reinterpret_cast(commandBuffer), setTxModeCw.size(), 0); - rawPacketLen = setTxModeCw.size(); - rawPacket = commandBuffer; + prepareCommand(setTxModeCw, deviceCommand); return RETURN_OK; } case (syrlinks::WRITE_LCL_CONFIG): { - writeLclConfig.copy(reinterpret_cast(commandBuffer), writeLclConfig.size(), 0); - rawPacketLen = writeLclConfig.size(); - rawPacket = commandBuffer; - rememberCommandId = syrlinks::WRITE_LCL_CONFIG; + prepareCommand(writeLclConfig, deviceCommand); return RETURN_OK; } case (syrlinks::READ_RX_STATUS_REGISTERS): { - readRxStatusRegCommand.copy(reinterpret_cast(commandBuffer), - readRxStatusRegCommand.size(), 0); - rawPacketLen = readRxStatusRegCommand.size(); - rawPacket = commandBuffer; + prepareCommand(readRxStatusRegCommand, deviceCommand); 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; + prepareCommand(readLclConfig, deviceCommand); return RETURN_OK; } case (syrlinks::READ_TX_STATUS): { - readTxStatus.copy(reinterpret_cast(commandBuffer), readTxStatus.size(), 0); - rawPacketLen = readTxStatus.size(); - rememberCommandId = syrlinks::READ_TX_STATUS; - rawPacket = commandBuffer; + prepareCommand(readTxStatus, deviceCommand); return RETURN_OK; } case (syrlinks::READ_TX_WAVEFORM): { - readTxWaveform.copy(reinterpret_cast(commandBuffer), readTxWaveform.size(), 0); - rawPacketLen = readTxWaveform.size(); - rememberCommandId = syrlinks::READ_TX_WAVEFORM; - rawPacket = commandBuffer; + prepareCommand(readTxWaveform, deviceCommand); return RETURN_OK; } case (syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), - readTxAgcValueHighByte.size(), 0); - rawPacketLen = readTxAgcValueHighByte.size(); - rememberCommandId = syrlinks::READ_TX_AGC_VALUE_HIGH_BYTE; - rawPacket = commandBuffer; + prepareCommand(readTxAgcValueHighByte, deviceCommand); return RETURN_OK; } case (syrlinks::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), - readTxAgcValueLowByte.size(), 0); - rawPacketLen = readTxAgcValueLowByte.size(); - rememberCommandId = syrlinks::READ_TX_AGC_VALUE_LOW_BYTE; - rawPacket = commandBuffer; + prepareCommand(readTxAgcValueLowByte, deviceCommand); return RETURN_OK; } - case (syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE): - tempPowerAmpBoardHighByte.copy(reinterpret_cast(commandBuffer), - tempPowerAmpBoardHighByte.size(), 0); - rawPacketLen = tempPowerAmpBoardHighByte.size(); - rememberCommandId = syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE; - rawPacket = commandBuffer; + case (syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE): { + prepareCommand(tempPowerAmpBoardHighByte, deviceCommand); return RETURN_OK; - case (syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE): - tempPowerAmpBoardLowByte.copy(reinterpret_cast(commandBuffer), - tempPowerAmpBoardLowByte.size(), 0); - rawPacketLen = tempPowerAmpBoardLowByte.size(); - rememberCommandId = syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE; - rawPacket = commandBuffer; + } + case (syrlinks::TEMP_POWER_AMPLIFIER_LOW_BYTE): { + prepareCommand(tempPowerAmpBoardLowByte, deviceCommand); return RETURN_OK; - case (syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE): - tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), - tempBasebandBoardHighByte.size(), 0); - rawPacketLen = tempBasebandBoardHighByte.size(); - rememberCommandId = syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE; - rawPacket = commandBuffer; + } + case (syrlinks::TEMP_BASEBAND_BOARD_HIGH_BYTE): { + prepareCommand(tempBasebandBoardHighByte, deviceCommand); return RETURN_OK; - case (syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE): - tempBasebandBoardLowByte.copy(reinterpret_cast(commandBuffer), - tempBasebandBoardLowByte.size(), 0); - rawPacketLen = tempBasebandBoardLowByte.size(); - rememberCommandId = syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE; - rawPacket = commandBuffer; + } + case (syrlinks::TEMP_BASEBAND_BOARD_LOW_BYTE): { + prepareCommand(tempBasebandBoardLowByte, deviceCommand); return RETURN_OK; - case (syrlinks::SET_WAVEFORM_OQPSK): - setWaveformOQPSK.copy(reinterpret_cast(commandBuffer), - setWaveformOQPSK.size(), 0); - rawPacketLen = setWaveformOQPSK.size(); - rememberCommandId = syrlinks::SET_WAVEFORM_OQPSK; - rawPacket = commandBuffer; + } + case (syrlinks::CONFIG_BPSK): { + prepareCommand(configBPSK, deviceCommand); return RETURN_OK; - case (syrlinks::SET_WAVEFORM_BPSK): - setWaveformBPSK.copy(reinterpret_cast(commandBuffer), - setWaveformBPSK.size(), 0); - rawPacketLen = setWaveformBPSK.size(); - rememberCommandId = syrlinks::SET_WAVEFORM_BPSK; - rawPacket = commandBuffer; + } + case (syrlinks::CONFIG_OQPSK): { + prepareCommand(configOQPSK, deviceCommand); return RETURN_OK; - case (syrlinks::SET_SECOND_CONFIG): - setSecondConfiguration.copy(reinterpret_cast(commandBuffer), - setSecondConfiguration.size(), 0); - rawPacketLen = setSecondConfiguration.size(); - rememberCommandId = syrlinks::SET_SECOND_CONFIG; - rawPacket = commandBuffer; + } + case (syrlinks::ENABLE_DEBUG): { + debug = true; return RETURN_OK; + } + case (syrlinks::DISABLE_DEBUG): { + debug = false; + return RETURN_OK; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -240,12 +190,12 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { true, syrlinks::ACK_REPLY); this->insertInCommandAndReplyMap(syrlinks::WRITE_LCL_CONFIG, 1, nullptr, syrlinks::ACK_SIZE, false, true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_OQPSK, 1, nullptr, syrlinks::ACK_SIZE, + this->insertInCommandAndReplyMap(syrlinks::CONFIG_BPSK, 1, nullptr, syrlinks::ACK_SIZE, false, true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_BPSK, 1, nullptr, syrlinks::ACK_SIZE, - false, true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::SET_SECOND_CONFIG, 1, nullptr, syrlinks::ACK_SIZE, + this->insertInCommandAndReplyMap(syrlinks::CONFIG_OQPSK, 1, nullptr, syrlinks::ACK_SIZE, false, true, syrlinks::ACK_REPLY); + this->insertInCommandMap(syrlinks::ENABLE_DEBUG); + this->insertInCommandMap(syrlinks::DISABLE_DEBUG); this->insertInCommandAndReplyMap(syrlinks::READ_LCL_CONFIG, 1, nullptr, syrlinks::READ_ONE_REGISTER_REPLY_SIE); this->insertInCommandAndReplyMap(syrlinks::READ_TX_STATUS, 1, &txDataset, @@ -316,8 +266,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::ACK_SIZE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgment reply has " - "invalid crc" - << std::endl; + "invalid crc" + << std::endl; return CRC_FAILURE; } result = handleAckReply(packet); @@ -330,7 +280,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::RX_STATUS_REGISTERS_REPLY_SIZE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read rx status registers reply " - << "has invalid crc" << std::endl; + << "has invalid crc" << std::endl; return CRC_FAILURE; } parseRxStatusRegistersReply(packet); @@ -340,7 +290,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read config lcl reply " - << "has invalid crc" << std::endl; + << "has invalid crc" << std::endl; return CRC_FAILURE; } parseLclConfigReply(packet); @@ -350,7 +300,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply " - << "has invalid crc" << std::endl; + << "has invalid crc" << std::endl; return CRC_FAILURE; } parseTxStatusReply(packet); @@ -360,7 +310,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply " - << "has invalid crc" << std::endl; + << "has invalid crc" << std::endl; return CRC_FAILURE; } parseTxWaveformReply(packet); @@ -370,7 +320,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply " - << "has invalid crc" << std::endl; + << "has invalid crc" << std::endl; return CRC_FAILURE; } parseAgcHighByte(packet); @@ -380,7 +330,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply " - << "has invalid crc" << std::endl; + << "has invalid crc" << std::endl; return CRC_FAILURE; } parseAgcLowByte(packet); @@ -390,7 +340,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board " - << "high byte reply has invalid crc" << std::endl; + << "high byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast( @@ -402,8 +352,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature baseband board" - " low byte reply has invalid crc" - << std::endl; + " low byte reply has invalid crc" + << std::endl; return CRC_FAILURE; } rawTempBasebandBoard |= convertHexStringToUint8( @@ -412,8 +362,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons temperatureSet.temperatureBasebandBoard = tempBasebandBoard; PoolReadGuard rg(&temperatureSet); if (debug) { - sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" - << std::endl; + sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" + << std::endl; } break; } @@ -421,7 +371,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier " - << "board high byte reply has invalid crc" << std::endl; + << "board high byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempPowerAmplifier = 0; @@ -434,7 +384,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons result = verifyReply(packet, syrlinks::READ_ONE_REGISTER_REPLY_SIE); if (result != RETURN_OK) { sif::warning << "SyrlinksHkHandler::interpretDeviceReply: Read temperature power amplifier" - << " board low byte reply has invalid crc" << std::endl; + << " board low byte reply has invalid crc" << std::endl; return CRC_FAILURE; } rawTempPowerAmplifier |= convertHexStringToUint8( @@ -443,8 +393,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons PoolReadGuard rg(&temperatureSet); temperatureSet.temperaturePowerAmplifier = tempPowerAmplifier; if (debug) { - sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier - << " °C" << std::endl; + sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C" + << std::endl; } break; } @@ -470,10 +420,6 @@ LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) { } } -void SyrlinksHkHandler::performOperationHook() { - -} - std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) { std::stringstream stream; stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue; @@ -592,15 +538,17 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value - << std::endl; - sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; - sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; - sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; - sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; - sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; - sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; - sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + if (debug) { + sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value + << std::endl; + sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; + sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; + sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; + sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; + sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; + sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; + sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + } #endif } @@ -615,7 +563,7 @@ void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 +#if OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value << std::endl; #endif @@ -625,7 +573,7 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 +#if OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value << std::endl; #endif @@ -636,7 +584,7 @@ void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 +#if OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; #endif } @@ -685,3 +633,10 @@ ReturnValue_t SyrlinksHkHandler::handleAckReply(const uint8_t* packet) { } return result; } + +void SyrlinksHkHandler::prepareCommand(std::string command, DeviceCommandId_t commandId) { + command.copy(reinterpret_cast(commandBuffer), readTxWaveform.size(), 0); + rawPacketLen = command.size(); + rememberCommandId = commandId; + rawPacket = commandBuffer; +} diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 739db450..7eab1b01 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -44,7 +44,6 @@ class SyrlinksHkHandler : public DeviceHandlerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - void performOperationHook(); private: static const uint8_t INTERFACE_ID = CLASS_ID::SYRLINKS_HANDLER; @@ -67,8 +66,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { std::string setTxModeStandby = ""; /** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */ std::string setTxModeModulation = ""; -// std::string setSecondConfiguration = ""; - std::string setSecondConfiguration = ""; + std::string configBPSK = ""; + std::string configOQPSK = ""; std::string setTxModeCw = ""; std::string writeLclConfig = ""; std::string setWaveformOQPSK = ""; @@ -111,7 +110,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { StartupState startupState = StartupState::OFF; - bool debug = true; + bool debug = false; /** * This object is used to store the id of the next command to execute. This controls the @@ -212,6 +211,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase { float calcTempVal(uint16_t); ReturnValue_t handleAckReply(const uint8_t* packet); + + void prepareCommand(std::string command, DeviceCommandId_t commandId); }; #endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index bf964063..a816dc29 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -24,10 +24,11 @@ static const DeviceCommandId_t TEMP_POWER_AMPLIFIER_HIGH_BYTE = 13; static const DeviceCommandId_t TEMP_POWER_AMPLIFIER_LOW_BYTE = 14; static const DeviceCommandId_t TEMP_BASEBAND_BOARD_HIGH_BYTE = 15; static const DeviceCommandId_t TEMP_BASEBAND_BOARD_LOW_BYTE = 16; -static const DeviceCommandId_t SET_WAVEFORM_OQPSK = 17; -static const DeviceCommandId_t SET_WAVEFORM_BPSK = 18; -static const DeviceCommandId_t SET_SECOND_CONFIG = 19; +static const DeviceCommandId_t CONFIG_OQPSK = 17; +// After startup syrlinks always in BSPK configuration +static const DeviceCommandId_t CONFIG_BPSK = 18; static const DeviceCommandId_t ENABLE_DEBUG = 20; +static const DeviceCommandId_t DISABLE_DEBUG = 21; /** Size of a simple transmission success response */ static const uint8_t ACK_SIZE = 12; -- 2.43.0 From a30e57142a6480b14ee38cdeca9681fb2acdd667 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 4 Apr 2022 15:05:56 +0200 Subject: [PATCH 05/10] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 811aedce..592f3754 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 811aedce9762daa87e268b8832f23b0d28f8a714 +Subproject commit 592f37544f252466f702502ffb0140840ab75d8c -- 2.43.0 From 40403b81c3396ae5ca6be3f39bf7b35be53de901 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 5 Apr 2022 08:38:36 +0200 Subject: [PATCH 06/10] debug flag --- mission/devices/SyrlinksHkHandler.cpp | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index c64ac747..24d17a86 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -11,7 +11,7 @@ SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, Co txDataset(this), temperatureSet(this), powerSwitch(powerSwitch) { - if (comCookie == NULL) { + if (comCookie == nullptr) { sif::warning << "SyrlinksHkHandler: Invalid com cookie" << std::endl; } } @@ -78,14 +78,14 @@ ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) << "command id" << std::endl; break; } - return buildCommandFromCommand(*id, NULL, 0); + return buildCommandFromCommand(*id, nullptr, 0); } ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { switch (startupState) { case StartupState::ENABLE_TEMPERATURE_PROTECTION: { *id = syrlinks::WRITE_LCL_CONFIG; - return HasReturnvaluesIF::RETURN_OK; + return buildCommandFromCommand(*id, nullptr, 0); } default: break; @@ -167,10 +167,12 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic } case (syrlinks::ENABLE_DEBUG): { debug = true; + rawPacketLen = 0; return RETURN_OK; } case (syrlinks::DISABLE_DEBUG): { debug = false; + rawPacketLen = 0; return RETURN_OK; } default: @@ -469,7 +471,7 @@ ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) { case '0': return RETURN_OK; case '1': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart faming or parity error" << std::endl; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart framing or parity error" << std::endl; return UART_FRAMIN_OR_PARITY_ERROR_ACK; case '2': sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; @@ -555,8 +557,10 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { 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; + if (debug) { + sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " + << static_cast(lclConfig) << std::endl; + } } void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { @@ -564,8 +568,10 @@ void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_DEBUG_SYRLINKS == 1 + if (debug) { sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value << std::endl; + } #endif } @@ -574,8 +580,10 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_DEBUG_SYRLINKS == 1 + if (debug) { sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value << std::endl; + } #endif } @@ -585,7 +593,9 @@ void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_DEBUG_SYRLINKS == 1 - sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + if (debug) { + sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + } #endif } @@ -597,7 +607,7 @@ void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) { void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {} -uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } +uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { @@ -635,7 +645,7 @@ ReturnValue_t SyrlinksHkHandler::handleAckReply(const uint8_t* packet) { } void SyrlinksHkHandler::prepareCommand(std::string command, DeviceCommandId_t commandId) { - command.copy(reinterpret_cast(commandBuffer), readTxWaveform.size(), 0); + command.copy(reinterpret_cast(commandBuffer), command.size(), 0); rawPacketLen = command.size(); rememberCommandId = commandId; rawPacket = commandBuffer; -- 2.43.0 From f91efd8c1ea1da0292903da49b70456c6d487f9c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 5 Apr 2022 11:50:45 +0200 Subject: [PATCH 07/10] prepared pr --- bsp_hosted/acsDummies/GpsDummy.cpp | 7 ---- bsp_hosted/acsDummies/GpsDummy.h | 13 -------- mission/controller/AcsController.cpp | 48 ---------------------------- mission/controller/AcsController.h | 18 ----------- tmtc | 2 +- 5 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 bsp_hosted/acsDummies/GpsDummy.cpp delete mode 100644 bsp_hosted/acsDummies/GpsDummy.h delete mode 100644 mission/controller/AcsController.cpp delete mode 100644 mission/controller/AcsController.h diff --git a/bsp_hosted/acsDummies/GpsDummy.cpp b/bsp_hosted/acsDummies/GpsDummy.cpp deleted file mode 100644 index b4331798..00000000 --- a/bsp_hosted/acsDummies/GpsDummy.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "GpsDummy.h" - -GpsDummy::GpsDummy() { -} - -GpsDummy::~GpsDummy() { -} diff --git a/bsp_hosted/acsDummies/GpsDummy.h b/bsp_hosted/acsDummies/GpsDummy.h deleted file mode 100644 index f25bf1f2..00000000 --- a/bsp_hosted/acsDummies/GpsDummy.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef BSP_HOSTED_ACSDUMMIES_GPSDUMMY_H_ -#define BSP_HOSTED_ACSDUMMIES_GPSDUMMY_H_ - -/** - * @brief Dummy class to simulate sending of GPS data to ACS controller. - */ -class GpsDummy : public ExtendedControllerBase { - public: - GpsDummy(); - virtual ~GpsDummy(); -}; - -#endif /* BSP_HOSTED_ACSDUMMIES_GPSDUMMY_H_ */ diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp deleted file mode 100644 index 28f7032b..00000000 --- a/mission/controller/AcsController.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "AcsController.h" - -AcsController::AcsController() { -} - -AcsController::~AcsController() { -} - -ReturnValue_t AcsController::initialize() { - - ControllerBase::initialize(); -} - -ReturnValue_t AcsController::handleCommandMessage(CommandMessage * message) { - ReturnValue_t result = actionHelper.handleActionMessage(message); - if (result == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; - } - return result; -} - -void AcsController::performControlOperation() { - if (mode != MODE_OFF) { - monitoring.monitor(&acsParameters); - switch (submode) { - case SUBMODE_SAFE: - performSafe(SAFE_CONTROLLER); - break; - case SUBMODE_IDLE: - performPointing(IDLE_CONTROLLER); - break; - case SUBMODE_NADIR: - performPointing(NADIR_CONTROLLER); - break; - case SUBMODE_TARGET: - performPointing(TARGET_CONTROLLER); - break; - case SUBMODE_INERTIAL: - performPointing(INERTIAL_CONTROLLER); - break; - case SUBMODE_ROTATION: - performPointing(ROTATION_CONTROLLER); - break; - default: - break; - } - } -} diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h deleted file mode 100644 index 20f19c15..00000000 --- a/mission/controller/AcsController.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef MISSION_CONTROLLER_ACSCONTROLLER_H_ -#define MISSION_CONTROLLER_ACSCONTROLLER_H_ - -#include "fsfw/controller/ControllerBase.h" - -class AcsController : public ControllerBase { - public: - AcsController(); - virtual ~AcsController(); - - ReturnValue_t initialize() override; - - protected: - ReturnValue_t handleCommandMessage(CommandMessage *message); - void performControlOperation(); -}; - -#endif /* MISSION_CONTROLLER_ACSCONTROLLER_H_ */ diff --git a/tmtc b/tmtc index 592f3754..f8d6fc4c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 592f37544f252466f702502ffb0140840ab75d8c +Subproject commit f8d6fc4c2b2276c58247d626df3a461131027d2b -- 2.43.0 From 1f4328d9a0bc0aaf67a90304d66f9059378d6bde Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 5 Apr 2022 11:52:01 +0200 Subject: [PATCH 08/10] prepared pr --- mission/devices/SyrlinksFaultFlagMonitoring.cpp | 7 ------- mission/devices/SyrlinksFaultFlagMonitoring.h | 10 ---------- 2 files changed, 17 deletions(-) delete mode 100644 mission/devices/SyrlinksFaultFlagMonitoring.cpp delete mode 100644 mission/devices/SyrlinksFaultFlagMonitoring.h diff --git a/mission/devices/SyrlinksFaultFlagMonitoring.cpp b/mission/devices/SyrlinksFaultFlagMonitoring.cpp deleted file mode 100644 index 79b752d7..00000000 --- a/mission/devices/SyrlinksFaultFlagMonitoring.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "SyrlinksFaultFlagMonitoring.h" - -SyrlinksFaultFlagMonitoring::SyrlinksFaultFlagMonitoring() { -} - -SyrlinksFaultFlagMonitoring::~SyrlinksFaultFlagMonitoring() { -} diff --git a/mission/devices/SyrlinksFaultFlagMonitoring.h b/mission/devices/SyrlinksFaultFlagMonitoring.h deleted file mode 100644 index 7959ca55..00000000 --- a/mission/devices/SyrlinksFaultFlagMonitoring.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ -#define MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ - -class SyrlinksFaultFlagMonitoring : public ExecutableObjectIF { - public: - SyrlinksFaultFlagMonitoring(); - virtual ~SyrlinksFaultFlagMonitoring(); -}; - -#endif /* MISSION_DEVICES_SYRLINKSFAULTFLAGMONITORING_H_ */ -- 2.43.0 From 29b7c97892f5f3ab3df50cf4c14de235ecb93503 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 5 Apr 2022 12:00:12 +0200 Subject: [PATCH 09/10] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index f8d6fc4c..28ca0aa3 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f8d6fc4c2b2276c58247d626df3a461131027d2b +Subproject commit 28ca0aa36313798c16ffe1e4424c2b1a6409a4a6 -- 2.43.0 From 146868da214262db3aa131e94ecb610e8b762c7b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 5 Apr 2022 14:43:20 +0200 Subject: [PATCH 10/10] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index fbf9626f..7df51f72 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit fbf9626fde2961cf08bd88bf87f5c1bca900e287 +Subproject commit 7df51f72029d7b0f1571a74cd2a71ca74bbaa086 -- 2.43.0