syrlinks handler wip

This commit is contained in:
Jakob Meier 2021-02-19 11:02:27 +01:00
parent 89d0427437
commit a5ef1d5853
3 changed files with 103 additions and 77 deletions

View File

@ -1,10 +1,8 @@
#include <mission/devices/SyrlinksHkHandler.h>
#include <fsfwconfig/OBSWConfig.h>
SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie), dataset(
this) {
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;
}
@ -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,22 +73,42 @@ 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<float>(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;
}

View File

@ -2,6 +2,7 @@
#define MISSION_DEVICES_SYRLINKSHKHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/SyrlinksDefinitions.h>
#include <cstring.h>
/**
@ -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 = "<C04:5A5A:FF41>";
std::string readRxStatusRegCommand = "<E00::825B>";
std::string setTxModeStandby = "<W04:0040:2B9E>";
@ -60,21 +46,7 @@ private:
std::string setTxModeModulation = "<W04:0140:5D2A>";
std::string setTxModeCw = "<W04:1040:81CF>";
/**
* @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;

View File

@ -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<sizeof(float)> {
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<uint8_t> fpgaVersion = lp_var_t<uint8_t>(sid.objectId, FPGA_VERSION, this);
lp_var_t<uint8_t> fpgaBuild = lp_var_t<uint8_t>(sid.objectId, FPGA_BUILD, this);
lp_var_t<uint32_t> hardwareId = lp_var_t<uint32_t>(sid.objectId, HARDWARE_ID, this);
lp_var_t<uint8_t> fpgaType = lp_var_t<uint8_t>(sid.objectId, FPGA_TYPE, this);
lp_var_t<uint8_t> lclStatus = lp_var_t<uint8_t>(sid.objectId, LCL_STATUS, this);
lp_var_t<uint8_t> fpgaOption = lp_var_t<uint8_t>(sid.objectId, FPGA_OPTION, this);
lp_var_t<uint8_t> rxStatus = lp_var_t<uint8_t>(sid.objectId, RX_STATUS, this);
lp_var_t<uint32_t> rxSensitivity = lp_var_t<uint32_t>(sid.objectId, RX_SENSITIVITY, this);
lp_var_t<uint32_t> rxFrequencyShift = lp_var_t<uint32_t>(sid.objectId, RX_FREQUENCY_SHIFT, this);
lp_var_t<uint16_t> rxIqPower = lp_var_t<uint16_t>(sid.objectId, RX_IQ_POWER, this);
lp_var_t<uint16_t> rxAgcValue = lp_var_t<uint16_t>(sid.objectId, RX_AGC_VALUE, this);
lp_var_t<uint32_t> rxDemodEb = lp_var_t<uint32_t>(sid.objectId, RX_DEMOD_EB, this);
lp_var_t<uint32_t> rxDemodN0 = lp_var_t<uint32_t>(sid.objectId, RX_DEMOD_N0, this);
lp_var_t<uint8_t> rxDataRate = lp_var_t<uint8_t>(sid.objectId, RX_DEMOD_N0, this);
lp_var_t<uint8_t> txStatus = lp_var_t<uint8_t>(sid.objectId, TX_STATUS, this);
lp_var_t<uint8_t> txConvDiff = lp_var_t<uint8_t>(sid.objectId, TX_CONV_DIFF, this);
lp_var_t<uint16_t> txConvFilter = lp_var_t<uint16_t>(sid.objectId, TX_CONV_FILTER, this);
lp_var_t<uint8_t> txWaveform = lp_var_t<uint8_t>(sid.objectId, TX_WAVEFORM, this);
lp_var_t<uint8_t> txPcmIndex = lp_var_t<uint8_t>(sid.objectId, TX_PCM_INDEX, this);
lp_var_t<uint16_t> txAgcValue = lp_var_t<uint16_t>(sid.objectId, TX_AGC_VALUE, this);
};
}
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ */