|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
#include <fsfw/datapool/PoolReadGuard.h>
|
|
|
|
|
#include <fsfw/globalfunctions/CRC.h>
|
|
|
|
|
#include <mission/devices/SyrlinksHkHandler.h>
|
|
|
|
|
|
|
|
|
|
#include <mission/devices/SyrlinksHandler.h>
|
|
|
|
|
#include "OBSWConfig.h"
|
|
|
|
|
|
|
|
|
|
SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
|
|
|
|
SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
|
|
|
|
power::Switch_t powerSwitch, FailureIsolationBase* customFdir)
|
|
|
|
|
: DeviceHandlerBase(objectId, comIF, comCookie, customFdir),
|
|
|
|
|
rxDataset(this),
|
|
|
|
@ -16,9 +15,9 @@ SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, Co
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SyrlinksHkHandler::~SyrlinksHkHandler() {}
|
|
|
|
|
SyrlinksHandler::~SyrlinksHandler() {}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::doStartUp() {
|
|
|
|
|
void SyrlinksHandler::doStartUp() {
|
|
|
|
|
switch (startupState) {
|
|
|
|
|
case StartupState::OFF: {
|
|
|
|
|
startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION;
|
|
|
|
@ -33,12 +32,12 @@ void SyrlinksHkHandler::doStartUp() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::doShutDown() {
|
|
|
|
|
void SyrlinksHandler::doShutDown() {
|
|
|
|
|
setMode(_MODE_POWER_DOWN);
|
|
|
|
|
temperatureSet.setValidity(false, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
|
|
|
|
switch (nextCommand) {
|
|
|
|
|
case (syrlinks::READ_RX_STATUS_REGISTERS):
|
|
|
|
|
*id = syrlinks::READ_RX_STATUS_REGISTERS;
|
|
|
|
@ -84,7 +83,7 @@ ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id)
|
|
|
|
|
return buildCommandFromCommand(*id, nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
|
|
|
|
switch (startupState) {
|
|
|
|
|
case StartupState::ENABLE_TEMPERATURE_PROTECTION: {
|
|
|
|
|
*id = syrlinks::WRITE_LCL_CONFIG;
|
|
|
|
@ -96,7 +95,7 @@ ReturnValue_t SyrlinksHkHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
|
|
|
|
|
return NOTHING_TO_SEND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
|
|
|
|
ReturnValue_t SyrlinksHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
|
|
|
|
const uint8_t* commandData,
|
|
|
|
|
size_t commandDataLen) {
|
|
|
|
|
switch (deviceCommand) {
|
|
|
|
@ -184,7 +183,7 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic
|
|
|
|
|
return returnvalue::FAILED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::fillCommandAndReplyMap() {
|
|
|
|
|
void SyrlinksHandler::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,
|
|
|
|
@ -223,7 +222,7 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() {
|
|
|
|
|
syrlinks::RX_STATUS_REGISTERS_REPLY_SIZE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
|
|
|
|
ReturnValue_t SyrlinksHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
|
|
|
|
DeviceCommandId_t* foundId, size_t* foundLen) {
|
|
|
|
|
ReturnValue_t result = returnvalue::OK;
|
|
|
|
|
|
|
|
|
@ -254,7 +253,7 @@ ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remai
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
|
|
|
|
|
if (powerSwitch == power::NO_SWITCH) {
|
|
|
|
|
return DeviceHandlerBase::NO_SWITCH;
|
|
|
|
|
}
|
|
|
|
@ -263,7 +262,7 @@ ReturnValue_t SyrlinksHkHandler::getSwitches(const uint8_t** switches, uint8_t*
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
|
|
|
|
ReturnValue_t result;
|
|
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
@ -414,7 +413,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) {
|
|
|
|
|
LocalPoolDataSetBase* SyrlinksHandler::getDataSetHandle(sid_t sid) {
|
|
|
|
|
if (sid == rxDataset.getSid()) {
|
|
|
|
|
return &rxDataset;
|
|
|
|
|
} else if (sid == txDataset.getSid()) {
|
|
|
|
@ -427,13 +426,13 @@ LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) {
|
|
|
|
|
std::string SyrlinksHandler::convertUint16ToHexString(uint16_t intValue) {
|
|
|
|
|
std::stringstream stream;
|
|
|
|
|
stream << std::setfill('0') << std::setw(4) << std::hex << std::uppercase << intValue;
|
|
|
|
|
return stream.str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) {
|
|
|
|
|
uint8_t SyrlinksHandler::convertHexStringToUint8(const char* twoChars) {
|
|
|
|
|
uint32_t value;
|
|
|
|
|
std::string hexString(twoChars, 2);
|
|
|
|
|
std::stringstream stream;
|
|
|
|
@ -442,13 +441,13 @@ uint8_t SyrlinksHkHandler::convertHexStringToUint8(const char* twoChars) {
|
|
|
|
|
return static_cast<uint8_t>(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint16_t SyrlinksHkHandler::convertHexStringToUint16(const char* fourChars) {
|
|
|
|
|
uint16_t SyrlinksHandler::convertHexStringToUint16(const char* fourChars) {
|
|
|
|
|
uint16_t value = 0;
|
|
|
|
|
value = convertHexStringToUint8(fourChars) << 8 | convertHexStringToUint8(fourChars + 2);
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::parseReplyStatus(const char* status) {
|
|
|
|
|
switch (*status) {
|
|
|
|
|
case '0':
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
@ -480,7 +479,7 @@ ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::verifyReply(const uint8_t* packet, uint8_t size) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
/* Calculate crc from received packet */
|
|
|
|
|
uint16_t crc =
|
|
|
|
@ -500,7 +499,7 @@ ReturnValue_t SyrlinksHkHandler::verifyReply(const uint8_t* packet, uint8_t size
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) {
|
|
|
|
|
void SyrlinksHandler::parseRxStatusRegistersReply(const uint8_t* packet) {
|
|
|
|
|
PoolReadGuard readHelper(&rxDataset);
|
|
|
|
|
uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE;
|
|
|
|
|
rxDataset.rxStatus = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
|
|
|
|
@ -540,7 +539,7 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) {
|
|
|
|
|
void SyrlinksHandler::parseLclConfigReply(const uint8_t* packet) {
|
|
|
|
|
uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE;
|
|
|
|
|
uint8_t lclConfig = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
|
|
|
|
|
if (debugMode) {
|
|
|
|
@ -549,7 +548,7 @@ void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) {
|
|
|
|
|
void SyrlinksHandler::parseTxStatusReply(const uint8_t* packet) {
|
|
|
|
|
PoolReadGuard readHelper(&txDataset);
|
|
|
|
|
uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE;
|
|
|
|
|
txDataset.txStatus = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
|
|
|
|
@ -560,7 +559,7 @@ void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) {
|
|
|
|
|
void SyrlinksHandler::parseTxWaveformReply(const uint8_t* packet) {
|
|
|
|
|
PoolReadGuard readHelper(&txDataset);
|
|
|
|
|
uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE;
|
|
|
|
|
txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
|
|
|
|
@ -571,7 +570,7 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) {
|
|
|
|
|
void SyrlinksHandler::parseAgcLowByte(const uint8_t* packet) {
|
|
|
|
|
PoolReadGuard readHelper(&txDataset);
|
|
|
|
|
uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE;
|
|
|
|
|
txDataset.txAgcValue = agcValueHighByte << 8 |
|
|
|
|
@ -582,17 +581,17 @@ void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) {
|
|
|
|
|
void SyrlinksHandler::parseAgcHighByte(const uint8_t* packet) {
|
|
|
|
|
PoolReadGuard readHelper(&txDataset);
|
|
|
|
|
uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE;
|
|
|
|
|
agcValueHighByte = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid() {}
|
|
|
|
|
void SyrlinksHandler::setNormalDatapoolEntriesInvalid() {}
|
|
|
|
|
|
|
|
|
|
uint32_t SyrlinksHkHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
|
|
|
|
uint32_t SyrlinksHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
|
|
|
ReturnValue_t SyrlinksHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
|
|
|
LocalDataPoolManager& poolManager) {
|
|
|
|
|
localDataPoolMap.emplace(syrlinks::RX_STATUS, new PoolEntry<uint8_t>({0}));
|
|
|
|
|
localDataPoolMap.emplace(syrlinks::RX_SENSITIVITY, new PoolEntry<uint32_t>({0}));
|
|
|
|
@ -618,11 +617,11 @@ ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& lo
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::setModeNormal() { setMode(MODE_NORMAL); }
|
|
|
|
|
void SyrlinksHandler::setModeNormal() { setMode(MODE_NORMAL); }
|
|
|
|
|
|
|
|
|
|
float SyrlinksHkHandler::calcTempVal(uint16_t raw) { return 0.126984 * raw - 67.87; }
|
|
|
|
|
float SyrlinksHandler::calcTempVal(uint16_t raw) { return 0.126984 * raw - 67.87; }
|
|
|
|
|
|
|
|
|
|
ReturnValue_t SyrlinksHkHandler::handleAckReply(const uint8_t* packet) {
|
|
|
|
|
ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) {
|
|
|
|
|
ReturnValue_t result =
|
|
|
|
|
parseReplyStatus(reinterpret_cast<const char*>(packet + syrlinks::MESSAGE_HEADER_SIZE));
|
|
|
|
|
if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result != returnvalue::OK) {
|
|
|
|
@ -633,11 +632,11 @@ ReturnValue_t SyrlinksHkHandler::handleAckReply(const uint8_t* packet) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::prepareCommand(std::string command, DeviceCommandId_t commandId) {
|
|
|
|
|
void SyrlinksHandler::prepareCommand(std::string command, DeviceCommandId_t commandId) {
|
|
|
|
|
command.copy(reinterpret_cast<char*>(commandBuffer), command.size(), 0);
|
|
|
|
|
rawPacketLen = command.size();
|
|
|
|
|
rememberCommandId = commandId;
|
|
|
|
|
rawPacket = commandBuffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SyrlinksHkHandler::setDebugMode(bool enable) { this->debugMode = enable; }
|
|
|
|
|
void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; }
|