v1.10.0 #220

Merged
meierj merged 592 commits from develop into main 2022-04-22 07:42:20 +02:00
3 changed files with 121 additions and 42 deletions
Showing only changes of commit 387595495e - Show all commits

View File

@ -102,8 +102,7 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic
return RETURN_OK;
}
case (SYRLINKS::READ_LCL_CONFIG): {
readLclConfig.copy(reinterpret_cast<char*>(commandBuffer),
readLclConfig.size(), 0);
readLclConfig.copy(reinterpret_cast<char*>(commandBuffer), readLclConfig.size(), 0);
rawPacketLen = readLclConfig.size();
rawPacket = commandBuffer;
rememberCommandId = SYRLINKS::READ_LCL_CONFIG;
@ -117,26 +116,53 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic
return RETURN_OK;
}
case (SYRLINKS::READ_TX_WAVEFORM): {
readTxWaveform.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
readTxWaveform.copy(reinterpret_cast<char*>(commandBuffer), readTxWaveform.size(), 0);
rawPacketLen = readTxWaveform.size();
rememberCommandId = SYRLINKS::READ_TX_WAVEFORM;
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): {
readTxAgcValueHighByte.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
readTxAgcValueHighByte.copy(reinterpret_cast<char*>(commandBuffer), readTxAgcValueHighByte.size(), 0);
rawPacketLen = readTxAgcValueHighByte.size();
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<char*>(commandBuffer), readTxStatus.size(), 0);
readTxAgcValueLowByte.copy(reinterpret_cast<char*>(commandBuffer), readTxAgcValueLowByte.size(), 0);
rawPacketLen = readTxAgcValueLowByte.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE):
tempPowerAmpBoardHighByte.copy(reinterpret_cast<char*>(commandBuffer), tempPowerAmpBoardHighByte.size(),
0);
rawPacketLen = tempPowerAmpBoardHighByte.size();
rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE):
tempBasebandBoardHighByte.copy(reinterpret_cast<char*>(commandBuffer), tempBasebandBoardHighByte.size(),
0);
rawPacketLen = tempBasebandBoardHighByte.size();
rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE):
tempBasebandBoardHighByte.copy(reinterpret_cast<char*>(commandBuffer), tempBasebandBoardHighByte.size(),
0);
rawPacketLen = tempBasebandBoardHighByte.size();
rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE):
tempBasebandBoardLowByte.copy(reinterpret_cast<char*>(commandBuffer), tempBasebandBoardLowByte.size(), 0);
rawPacketLen = tempBasebandBoardLowByte.size();
rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
@ -152,10 +178,10 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() {
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::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,
@ -164,26 +190,18 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() {
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::enableReplyInReplyMap(DeviceCommandMap::iterator command,
// uint8_t expectedReplies, bool useAlternateId,
// DeviceCommandId_t alternateReplyID) {
// switch (command->first) {
// case SYRLINKS::RESET_UNIT: {
// case SYRLINKS::SET_TX_MODE_STANDBY:
// case SYRLINKS::SET_TX_MODE_MODULATION:
// case SYRLINKS::SET_TX_MODE_CW:
// return DeviceHandlerBase::enableReplyInReplyMap(command, 1, true, SYRLINKS::ACK_REPLY);
// }
// default:
// break;
// }
// return DeviceHandlerBase::enableReplyInReplyMap(command);
//}
ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = RETURN_OK;
@ -296,6 +314,51 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons
}
parseAgcLowByte(packet);
break;
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 "
<< "high byte reply has invalid crc" << std::endl;
return CRC_FAILURE;
}
rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast<const char*>(
packet + SYRLINKS::MESSAGE_HEADER_SIZE))
<< 8;
break;
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"
" low byte reply has invalid crc"
<< std::endl;
return CRC_FAILURE;
}
rawTempBasebandBoard |= convertHexStringToUint8(
reinterpret_cast<const char*>(packet + SYRLINKS::MESSAGE_HEADER_SIZE));
tempBasebandBoard = calcTempVal(rawTempBasebandBoard);
break;
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 "
<< "board high byte reply has invalid crc" << std::endl;
return CRC_FAILURE;
}
rawTempBasebandBoard = convertHexStringToUint8(reinterpret_cast<const char*>(
packet + SYRLINKS::MESSAGE_HEADER_SIZE))
<< 8;
break;
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"
<< " board low byte reply has invalid crc" << std::endl;
return CRC_FAILURE;
}
rawTempBasebandBoard |= convertHexStringToUint8(
reinterpret_cast<const char*>(packet + SYRLINKS::MESSAGE_HEADER_SIZE));
rawTempPowerAmplifier = calcTempVal(rawTempPowerAmplifier);
break;
default: {
sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
@ -449,8 +512,8 @@ 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<const char*>(packet + offset));
sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: "
<< static_cast<unsigned int>(lclConfig) << std::endl;
sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: "
<< static_cast<unsigned int>(lclConfig) << std::endl;
}
void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) {
@ -512,3 +575,5 @@ 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; }

View File

@ -33,9 +33,6 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
void fillCommandAndReplyMap() override;
// ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
// uint8_t expectedReplies = 1, bool useAlternateId = false,
// DeviceCommandId_t alternateReplyID = 0) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
@ -74,6 +71,10 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
std::string readTxAgcValueHighByte = "<R02:46:DFF3>";
std::string readTxAgcValueLowByte = "<R02:47:ECC2>";
std::string readLclConfig = "<R02:07:3002>";
std::string tempPowerAmpBoardHighByte = "<R02:C0:28CD>";
std::string tempPowerAmpBoardLowByte = "<R02:C1:1BFC>";
std::string tempBasebandBoardHighByte = "<R02:C2:4EAF>";
std::string tempBasebandBoardLowByte = "<R02:C3:7D9E>";
/**
* In some cases it is not possible to extract from the received reply the information about
@ -86,7 +87,11 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
const power::Switch_t powerSwitch = power::NO_SWITCH;
uint8_t agcValueHighByte;
uint8_t agcValueHighByte = 0;
uint16_t rawTempPowerAmplifier = 0;
uint16_t rawTempBasebandBoard = 0;
float tempPowerAmplifier = 0;
float tempBasebandBoard = 0;
uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE];
@ -182,6 +187,11 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
*/
void parseAgcLowByte(const uint8_t* packet);
void parseAgcHighByte(const uint8_t* packet);
/**
* @brief Calculates temperature in degree celcius form raw value
*/
float calcTempVal(uint16_t);
};
#endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */

View File

@ -3,23 +3,27 @@
namespace SYRLINKS {
static const DeviceCommandId_t NONE = 0x0;
static const DeviceCommandId_t RESET_UNIT = 0x01;
static const DeviceCommandId_t NONE = 0;
static const DeviceCommandId_t RESET_UNIT = 1;
/** Reads out all status registers */
static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 0x02;
static const DeviceCommandId_t READ_RX_STATUS_REGISTERS = 2;
/** Sets Tx mode to standby */
static const DeviceCommandId_t SET_TX_MODE_STANDBY = 0x03;
static const DeviceCommandId_t SET_TX_MODE_STANDBY = 3;
/** Starts transmission mode. Only reached when clock signal is applying to the data tx input */
static const DeviceCommandId_t SET_TX_MODE_MODULATION = 0x04;
static const DeviceCommandId_t SET_TX_MODE_MODULATION = 4;
/** Sends out a single carrier wave for testing purpose */
static const DeviceCommandId_t SET_TX_MODE_CW = 0x05;
static const DeviceCommandId_t ACK_REPLY = 0x06;
static const DeviceCommandId_t READ_TX_STATUS = 0x07;
static const DeviceCommandId_t READ_TX_WAVEFORM = 0x08;
static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09;
static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A;
static const DeviceCommandId_t SET_TX_MODE_CW = 5;
static const DeviceCommandId_t ACK_REPLY = 6;
static const DeviceCommandId_t READ_TX_STATUS = 7;
static const DeviceCommandId_t READ_TX_WAVEFORM = 8;
static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 9;
static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 10;
static const DeviceCommandId_t WRITE_LCL_CONFIG = 11;
static const DeviceCommandId_t READ_LCL_CONFIG = 12;
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;
/** Size of a simple transmission success response */
static const uint8_t ACK_SIZE = 12;