2021-02-17 15:54:48 +01:00
|
|
|
#include <mission/devices/SyrlinksHkHandler.h>
|
|
|
|
#include <fsfwconfig/OBSWConfig.h>
|
|
|
|
|
2021-02-19 11:02:27 +01:00
|
|
|
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;
|
|
|
|
}
|
2021-02-17 15:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SyrlinksHkHandler::~SyrlinksHkHandler() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::doStartUp(){
|
|
|
|
if(mode == _MODE_START_UP){
|
|
|
|
setMode(MODE_ON);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::doShutDown(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(
|
|
|
|
DeviceCommandId_t * id) {
|
2021-02-18 16:16:38 +01:00
|
|
|
*id = READ_RX_STATUS_REGISTERS;
|
|
|
|
return buildCommandFromCommand(*id, NULL, 0);
|
2021-02-17 15:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(
|
|
|
|
DeviceCommandId_t * id){
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(
|
|
|
|
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
|
|
|
size_t commandDataLen) {
|
|
|
|
switch(deviceCommand) {
|
2021-02-19 11:02:27 +01:00
|
|
|
case(SYRLINKS::RESET_UNIT): {
|
2021-02-18 16:16:38 +01:00
|
|
|
resetCommand.copy(rawPacket, resetCommand.size(), 0);
|
|
|
|
rawPacketLen = resetCommand.size();
|
2021-02-19 11:02:27 +01:00
|
|
|
rememberCommandId = SYRLINKS::RESET_UNIT;
|
2021-02-18 16:16:38 +01:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
2021-02-19 11:02:27 +01:00
|
|
|
case(SYRLINKS::SET_TX_MODE_STANDBY): {
|
2021-02-18 16:16:38 +01:00
|
|
|
setTxModeStandby.copy(rawPacket, setTxModeStandby.size(), 0);
|
|
|
|
rawPacketLen = setTxModeStandby.size();
|
2021-02-19 11:02:27 +01:00
|
|
|
rememberCommandId = SYRLINKS::SET_TX_MODE_STANDBY;
|
2021-02-18 16:16:38 +01:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
2021-02-19 11:02:27 +01:00
|
|
|
case(SYRLINKS::SET_TX_MODE_MODULATION): {
|
2021-02-18 16:16:38 +01:00
|
|
|
setTxModeModulation.copy(rawPacket, setTxModeModulation.size(), 0);
|
|
|
|
rawPacketLen = setTxModeModulation.size();
|
2021-02-19 11:02:27 +01:00
|
|
|
rememberCommandId = SYRLINKS::SET_TX_MODE_MODULATION;
|
2021-02-18 16:16:38 +01:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
2021-02-19 11:02:27 +01:00
|
|
|
case(SYRLINKS::SET_TX_MODE_CW): {
|
2021-02-18 16:16:38 +01:00
|
|
|
setTxModeCw.copy(rawPacket, setTxModeCw.size(), 0);
|
|
|
|
rawPacketLen = setTxModeCw.size();
|
2021-02-19 11:02:27 +01:00
|
|
|
rememberCommandId = SYRLINKS::SET_TX_MODE_CW;
|
2021-02-17 15:54:48 +01:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
2021-02-19 11:02:27 +01:00
|
|
|
case(SYRLINKS::READ_RX_STATUS_REGISTERS): {
|
2021-02-18 16:16:38 +01:00
|
|
|
readRxStatusRegCommand.copy(rawPacket, readRxStatusRegCommand.size(), 0);
|
|
|
|
rawPacketLen = readRxStatusRegCommand.size();
|
2021-02-19 11:02:27 +01:00
|
|
|
rememberCommandId = SYRLINKS::READ_RX_STATUS_REGISTERS;
|
2021-02-17 15:54:48 +01:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_FAILED;
|
|
|
|
}
|
|
|
|
|
2021-02-19 11:02:27 +01:00
|
|
|
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);
|
2021-02-17 15:54:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start,
|
|
|
|
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
|
|
|
switch(rememberCommandId) {
|
2021-02-19 11:02:27 +01:00
|
|
|
case(SYRLINKS::RESET_UNIT):
|
|
|
|
*foundId = SYRLINKS::RESET_UNIT;
|
|
|
|
*foundLen = SYRLINKS::REQUEST_STATUS_REPLY_SIZE;
|
|
|
|
rememberCommandId = SYRLINKS::NONE;
|
2021-02-17 15:54:48 +01:00
|
|
|
break;
|
2021-02-19 11:02:27 +01:00
|
|
|
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;
|
2021-02-17 15:54:48 +01:00
|
|
|
default:
|
|
|
|
return IGNORE_REPLY_DATA;
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|
|
|
const uint8_t *packet) {
|
|
|
|
switch (id) {
|
2021-02-19 11:02:27 +01:00
|
|
|
case (SYRLINKS::RESET_UNIT): {
|
|
|
|
|
2021-02-17 15:54:48 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
|
|
LocalDataPoolManager& poolManager) {
|
|
|
|
localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry<float>( { 0.0 }));
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|