From d8c1ad7f71752db5d24fbf764886303a961ae88b Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 19 Feb 2021 11:02:27 +0100 Subject: [PATCH] syrlinks handler wip --- mission/devices/SyrlinksHkHandler.cpp | 95 ++++++++++--------- mission/devices/SyrlinksHkHandler.h | 32 +------ .../devicedefinitions/SyrlinksDefinitions.h | 53 +++++++++++ 3 files changed, 103 insertions(+), 77 deletions(-) diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index cedb015f..8c1feff9 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -1,13 +1,11 @@ #include #include -SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, - CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), dataset( - this) { - if (comCookie == NULL) { - sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; - } +SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : + DeviceHandlerBase(objectId, comIF, comCookie), rxStatusRegistersSet(this) { + if (comCookie == NULL) { + sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl; + } } SyrlinksHkHandler::~SyrlinksHkHandler() { @@ -39,29 +37,34 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand( DeviceCommandId_t deviceCommand, const uint8_t * commandData, size_t commandDataLen) { switch(deviceCommand) { - case(RESET_UNIT): { + case(SYRLINKS::RESET_UNIT): { resetCommand.copy(rawPacket, resetCommand.size(), 0); rawPacketLen = resetCommand.size(); + rememberCommandId = SYRLINKS::RESET_UNIT; return RETURN_OK; } - case(SET_TX_MODE_STANDBY): { + case(SYRLINKS::SET_TX_MODE_STANDBY): { setTxModeStandby.copy(rawPacket, setTxModeStandby.size(), 0); rawPacketLen = setTxModeStandby.size(); + rememberCommandId = SYRLINKS::SET_TX_MODE_STANDBY; return RETURN_OK; } - case(SET_TX_MODE_MODULATION): { + case(SYRLINKS::SET_TX_MODE_MODULATION): { setTxModeModulation.copy(rawPacket, setTxModeModulation.size(), 0); rawPacketLen = setTxModeModulation.size(); + rememberCommandId = SYRLINKS::SET_TX_MODE_MODULATION; return RETURN_OK; } - case(SET_TX_MODE_CW): { + case(SYRLINKS::SET_TX_MODE_CW): { setTxModeCw.copy(rawPacket, setTxModeCw.size(), 0); rawPacketLen = setTxModeCw.size(); + rememberCommandId = SYRLINKS::SET_TX_MODE_CW; return RETURN_OK; } - case(READ_RX_STATUS_REGISTERS): { + case(SYRLINKS::READ_RX_STATUS_REGISTERS): { readRxStatusRegCommand.copy(rawPacket, readRxStatusRegCommand.size(), 0); rawPacketLen = readRxStatusRegCommand.size(); + rememberCommandId = SYRLINKS::READ_RX_STATUS_REGISTERS; return RETURN_OK; } default: @@ -70,23 +73,43 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand( return HasReturnvaluesIF::RETURN_FAILED; } -void SyrlinksHkHandler::fillCommandAndReplyMap(){ - this->insertInCommandAndReplyMap(RESET_UNIT); - this->insertInCommandAndReplyMap(SET_TX_MODE_STANDBY); - this->insertInCommandAndReplyMap(SET_TX_MODE_MODULATION); - this->insertInCommandAndReplyMap(SET_TX_MODE_CW); - this->insertInCommandAndReplyMap(READ_RX_STATUS_REGISTERS, 1, &rxStatusRegiserSet, - TMP1075::GET_TEMP_REPLY_SIZE); +void SyrlinksHkHandler::fillCommandAndReplyMap() { + this->insertInCommandAndReplyMap(SYRLINKS::RESET_UNIT); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_STANDBY); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_MODULATION); + this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW); + this->insertInCommandAndReplyMap(SYRLINKS::READ_RX_STATUS_REGISTERS, 1, &rxStatusRegistersSet, + SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE); } ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { switch(rememberCommandId) { - case(TMP1075::GET_TEMP): - *foundId = TMP1075::GET_TEMP; - *foundLen = TMP1075::GET_TEMP_REPLY_SIZE; - rememberCommandId = TMP1075::NONE; + case(SYRLINKS::RESET_UNIT): + *foundId = SYRLINKS::RESET_UNIT; + *foundLen = SYRLINKS::REQUEST_STATUS_REPLY_SIZE; + rememberCommandId = SYRLINKS::NONE; break; + case(SYRLINKS::SET_TX_MODE_STANDBY): + *foundId = SYRLINKS::SET_TX_MODE_STANDBY; + *foundLen = SYRLINKS::REQUEST_STATUS_REPLY_SIZE; + rememberCommandId = SYRLINKS::NONE; + break; + case(SYRLINKS::SET_TX_MODE_MODULATION): + *foundId = SYRLINKS::SET_TX_MODE_MODULATION; + *foundLen = SYRLINKS::REQUEST_STATUS_REPLY_SIZE; + rememberCommandId = SYRLINKS::NONE; + break; + case(SYRLINKS::SET_TX_MODE_CW): + *foundId = SYRLINKS::SET_TX_MODE_CW; + *foundLen = SYRLINKS::REQUEST_STATUS_REPLY_SIZE; + rememberCommandId = SYRLINKS::NONE; + break; + case(SYRLINKS::READ_RX_STATUS_REGISTERS): + *foundId = SYRLINKS::READ_RX_STATUS_REGISTERS; + *foundLen = SYRLINKS::REQUEST_STATUS_REPLY_SIZE; + rememberCommandId = SYRLINKS::NONE; + break; default: return IGNORE_REPLY_DATA; } @@ -96,20 +119,8 @@ ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start, ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch (id) { - case TMP1075::GET_TEMP: { - int16_t tempValueRaw = 0; - tempValueRaw = packet[0] << 4 | packet[1] >> 4; - float tempValue = ((static_cast(tempValueRaw)) * 0.0625); -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Tmp1075 with object id: 0x" << std::hex << getObjectId() - << ": Temperature: " << tempValue<< " °C" - << std::endl; -#endif - ReturnValue_t result = dataset.read(); - if(result == HasReturnvaluesIF::RETURN_OK) { - dataset.temperatureCelcius = tempValue; - dataset.commit(); - } + case (SYRLINKS::RESET_UNIT): { + break; } @@ -125,16 +136,6 @@ void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){ } -void SyrlinksHkHandler::prepareAdcConversionCommand(){ - cmdBuffer[0] = TMP1075::CFGR_ADDR; - cmdBuffer[1] = TMP1075::ONE_SHOT_MODE >> 8; - cmdBuffer[2] = TMP1075::ONE_SHOT_MODE & 0xFF; -} - -void SyrlinksHkHandler::prepareGetTempCommand(){ - cmdBuffer[0] = TMP1075::TEMP_REG_ADDR; -} - uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ return 500; } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 1a30ff4a..55beec65 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_SYRLINKSHKHANDLER_H_ #include +#include #include /** @@ -38,21 +39,6 @@ protected: private: - static const DeviceCommandId_t RESET_UNIT = 0x01; - /** Reads out all status registers */ - static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; - /** Sets Tx mode to standby */ - static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; - /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ - static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; - /** Sends out a single carrier wave for testing purpose */ - static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; - - /** Size of a simple transmission success response */ - static const uint8_t REQUEST_STATUS_REPLY_SIZE = 11; - /** Size of reply to an rx status registers request */ - static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 39; - std::string resetCommand = ""; std::string readRxStatusRegCommand = ""; std::string setTxModeStandby = ""; @@ -60,21 +46,7 @@ private: std::string setTxModeModulation = ""; std::string setTxModeCw = ""; - - /** - * @brief Function fills cmdBuffer with command to start the adc - * conversion for a new temperature value. - */ - void prepareAdcConversionCommand(); - - void prepareGetTempCommand(); - - enum class CommunicationStep { - START_ADC_CONVERSION, - GET_TEMPERATURE - }; - - TMP1075::Tmp1075Dataset dataset; + SYRLINKS::RxStatusRegistersDataset rxStatusRegistersSet; static const uint8_t MAX_CMD_LEN = 3; diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 47e802c5..3e50238b 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -9,7 +9,60 @@ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ +namespace SYRLINKS { + static const DeviceCommandId_t NONE = 0x0; + static const DeviceCommandId_t RESET_UNIT = 0x01; + /** Reads out all status registers */ + static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02; + /** Sets Tx mode to standby */ + static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03; + /** Starts transmission mode. Only reached when clock signal is applying to the data tx input */ + static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04; + /** Sends out a single carrier wave for testing purpose */ + static const DeviceCommandId_t SET_TX_MODE_CW = 0x05; + + /** Size of a simple transmission success response */ + static const uint8_t REQUEST_STATUS_REPLY_SIZE = 11; + /** Size of reply to an rx status registers request */ + static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 39; + + static const uint8_t RX_STATUS_REGISTERS_SET_ID = READ_RX_STATUS_REGISTERS; + +class RxStatusRegistersDataset: public StaticLocalDataSet { +public: + + RxStatusRegistersDataset(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, RX_STATUS_REGISTERS_SET_ID) { + } + + RxStatusRegistersDataset(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, RX_STATUS_REGISTERS_SET_ID)) { + } + + lp_var_t fpgaVersion = lp_var_t(sid.objectId, FPGA_VERSION, this); + lp_var_t fpgaBuild = lp_var_t(sid.objectId, FPGA_BUILD, this); + lp_var_t hardwareId = lp_var_t(sid.objectId, HARDWARE_ID, this); + lp_var_t fpgaType = lp_var_t(sid.objectId, FPGA_TYPE, this); + lp_var_t lclStatus = lp_var_t(sid.objectId, LCL_STATUS, this); + lp_var_t fpgaOption = lp_var_t(sid.objectId, FPGA_OPTION, this); + lp_var_t rxStatus = lp_var_t(sid.objectId, RX_STATUS, this); + lp_var_t rxSensitivity = lp_var_t(sid.objectId, RX_SENSITIVITY, this); + lp_var_t rxFrequencyShift = lp_var_t(sid.objectId, RX_FREQUENCY_SHIFT, this); + lp_var_t rxIqPower = lp_var_t(sid.objectId, RX_IQ_POWER, this); + lp_var_t rxAgcValue = lp_var_t(sid.objectId, RX_AGC_VALUE, this); + lp_var_t rxDemodEb = lp_var_t(sid.objectId, RX_DEMOD_EB, this); + lp_var_t rxDemodN0 = lp_var_t(sid.objectId, RX_DEMOD_N0, this); + lp_var_t rxDataRate = lp_var_t(sid.objectId, RX_DEMOD_N0, this); + lp_var_t txStatus = lp_var_t(sid.objectId, TX_STATUS, this); + lp_var_t txConvDiff = lp_var_t(sid.objectId, TX_CONV_DIFF, this); + lp_var_t txConvFilter = lp_var_t(sid.objectId, TX_CONV_FILTER, this); + lp_var_t txWaveform = lp_var_t(sid.objectId, TX_WAVEFORM, this); + lp_var_t txPcmIndex = lp_var_t(sid.objectId, TX_PCM_INDEX, this); + lp_var_t txAgcValue = lp_var_t(sid.objectId, TX_AGC_VALUE, this); +}; + +} #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */