Update v1.1.0 - MGT - RTD - PUSC #28

Merged
meierj merged 88 commits from mueller/mgt-rtd-pusc into develop 2021-04-25 12:40:38 +02:00
7 changed files with 106 additions and 65 deletions
Showing only changes of commit be4977df68 - Show all commits

View File

@ -105,13 +105,17 @@ void InitMission::initTasks(){
}
PeriodicTaskIF* PusMedPrio = TaskFactory::instance()->
createPeriodicTask("PUS_HIGH_PRIO", 40,
createPeriodicTask("PUS_MED_PRIO", 40,
PeriodicTaskIF::MINIMUM_STACK_SIZE,
0.8, nullptr);
result = PusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT);
if(result!=HasReturnvaluesIF::RETURN_OK){
sif::error << "Object add component failed" << std::endl;
}
result = PusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING);
if(result!=HasReturnvaluesIF::RETURN_OK){
sif::error << "Object add component failed" << std::endl;
}
result = PusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT);
if(result!=HasReturnvaluesIF::RETURN_OK){
sif::error << "Object add component failed" << std::endl;

View File

@ -53,7 +53,7 @@ void Factory::setStaticFrameworkObjectIds() {
// No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT;
LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT;
LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketStored::timeStamperId = objects::TIME_STAMPER;
@ -175,13 +175,12 @@ void ObjectFactory::produce(){
solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM,
gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000);
// UartCookie* syrlinksUartCookie = new UartCookie(
// std::string("/dev/ttyPS1"), 38400, SYRLINKS::MAX_REPLY_SIZE);
UartCookie* syrlinksUartCookie = new UartCookie(
std::string("/dev/ttyUL0"), 38400, SYRLINKS::MAX_REPLY_SIZE);
syrlinksUartCookie->setParityEven();
SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie);
SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER,
objects::UART_COM_IF, syrlinksUartCookie);
syrlinksHkHandler->setModeNormal();
#endif

View File

@ -14,6 +14,8 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION);

View File

@ -27,7 +27,32 @@ void SyrlinksHkHandler::doShutDown(){
ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
*id = SYRLINKS::READ_RX_STATUS_REGISTERS;
switch (nextCommand) {
case(SYRLINKS::READ_RX_STATUS_REGISTERS):
*id = SYRLINKS::READ_RX_STATUS_REGISTERS;
nextCommand = SYRLINKS::READ_TX_STATUS;
break;
case(SYRLINKS::READ_TX_STATUS):
*id = SYRLINKS::READ_TX_STATUS;
nextCommand = SYRLINKS::READ_TX_WAVEFORM;
break;
case(SYRLINKS::READ_TX_WAVEFORM):
*id = SYRLINKS::READ_TX_WAVEFORM;
nextCommand = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
break;
case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE;
nextCommand = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
break;
case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
default:
sif::debug << "SyrlinksHkHandler::buildNormalDeviceCommand: rememberCommandId has invalid"
<< "command id" << std::endl;
break;
}
return buildCommandFromCommand(*id, NULL, 0);
}
@ -84,10 +109,17 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(
rawPacket = commandBuffer;
return RETURN_OK;
}
case(SYRLINKS::READ_TX_AGC_VALUE): {
readTxAgcValue.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxAgcValue.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE;
case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): {
readTxAgcValueHighByte.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.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);
rawPacketLen = readTxAgcValueLowByte.size();
rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
rawPacket = commandBuffer;
return RETURN_OK;
}
@ -107,7 +139,13 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() {
this->insertInCommandAndReplyMap(SYRLINKS::SET_TX_MODE_CW, 1, nullptr, SYRLINKS::ACK_SIZE,
false, true, SYRLINKS::ACK_REPLY);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_STATUS, 1, &txDataset,
SYRLINKS::READ_TX_STATUS);
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE, 1, &txDataset,
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::READ_RX_STATUS_REGISTERS, 1, &rxDataset,
SYRLINKS::RX_STATUS_REGISTERS_REPLY_SIZE);
}
@ -132,12 +170,8 @@ ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t *start,
*foundId = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
case('R'):
getIdAndLenForReadResponse(foundId, foundLen);
if (rememberCommandId == SYRLINKS::READ_TX_STATUS) {
*foundLen = SYRLINKS::READ_TX_STATUS_REPLY_SIZE;
*foundId = SYRLINKS::READ_TX_STATUS;
rememberCommandId = SYRLINKS::NONE;
}
*foundId = rememberCommandId;
*foundLen = SYRLINKS::READ_ONE_REGISTER_REPLY_SIE;
break;
default:
sif::error << "SyrlinksHkHandler::scanForReply: Unknown reply identifier" << std::endl;
@ -176,7 +210,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id,
parseRxStatusRegistersReply(packet);
break;
case(SYRLINKS::READ_TX_STATUS):
result = verifyReply(packet, SYRLINKS::READ_TX_STATUS_REPLY_SIZE);
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx status reply "
<< "has invalid crc" << std::endl;
@ -185,7 +219,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id,
parseTxStatusReply(packet);
break;
case(SYRLINKS::READ_TX_WAVEFORM):
result = verifyReply(packet, SYRLINKS::READ_TX_WAVEFORM_REPLY_SIZE);
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx waveform reply "
<< "has invalid crc" << std::endl;
@ -193,14 +227,23 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id,
}
parseTxWaveformReply(packet);
break;
case(SYRLINKS::READ_TX_AGC_VALUE):
result = verifyReply(packet, SYRLINKS::READ_TX_AGC_VALUE_REPLY_SIZE);
case(SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC reply "
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC high byte reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseTxAgcValueReply(packet);
parseAgcHighByte(packet);
break;
case(SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read tx AGC low byte reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseAgcLowByte(packet);
break;
default: {
sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id"
@ -212,26 +255,17 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id,
return RETURN_OK;
}
void SyrlinksHkHandler::getIdAndLenForReadResponse(DeviceCommandId_t *foundId, size_t *foundLen) {
switch (rememberCommandId) {
case(SYRLINKS::READ_TX_STATUS):
*foundLen = SYRLINKS::READ_TX_STATUS_REPLY_SIZE;
*foundId = SYRLINKS::READ_TX_STATUS;
break;
case(SYRLINKS::READ_TX_WAVEFORM):
*foundLen = SYRLINKS::READ_TX_WAVEFORM_REPLY_SIZE;
*foundId = SYRLINKS::READ_TX_WAVEFORM;
break;
case(SYRLINKS::READ_TX_AGC_VALUE):
*foundLen = SYRLINKS::READ_TX_AGC_VALUE_REPLY_SIZE;
*foundId = SYRLINKS::READ_TX_AGC_VALUE;
break;
default:
sif::debug << "SyrlinksHkHandler::getIdAndLenForReadResponse: No command id remembered"
<< std::endl;
break;
LocalPoolDataSetBase* SyrlinksHkHandler::getDataSetHandle(sid_t sid) {
if (sid == rxDataset.getSid()) {
return &rxDataset;
}
else if (sid== txDataset.getSid()) {
return &txDataset;
}
else {
sif::error << "SyrlinksHkHandler::getDataSetHandle: Invalid sid" << std::endl;
return nullptr;
}
rememberCommandId = SYRLINKS::NONE;
}
std::string SyrlinksHkHandler::convertUint16ToHexString(uint16_t intValue) {
@ -351,7 +385,7 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) {
#if OBSW_VERBOSE_LEVEL >= 1 && SYRLINKS_DEBUG == 1
sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value << std::endl;
sif::info << "Syrlinks RX Sensitivity: " << rxDataset.rxSensitivity << std::endl;
sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl;
sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl;
sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl;
sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl;
@ -381,15 +415,21 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) {
#endif
}
void SyrlinksHkHandler::parseTxAgcValueReply(const uint8_t* packet) {
void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) {
PoolReadHelper readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
txDataset.txAgcValue = convertHexStringToUint16(reinterpret_cast<const char*>(packet + offset));
txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
#if OBSW_VERBOSE_LEVEL >= 1 && SYRLINKS_DEBUG == 1
sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl;
#endif
}
void SyrlinksHkHandler::parseAgcHighByte(const uint8_t* packet) {
PoolReadHelper readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
agcValueHighByte = convertHexStringToUint8(reinterpret_cast<const char*>(packet + offset));
}
void SyrlinksHkHandler::setNormalDatapoolEntriesInvalid(){
}

View File

@ -41,6 +41,7 @@ protected:
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
private:
@ -66,7 +67,8 @@ private:
std::string setTxModeCw = "<W04:1040:81CF>";
std::string readTxStatus = "<R02:40:7555>";
std::string readTxWaveform = "<R02:44:B991>";
std::string readTxAgcValue = "<R02:46:DFF3>";
std::string readTxAgcValueHighByte = "<R02:46:DFF3>";
std::string readTxAgcValueLowByte = "<R02:47:ECC2>";
/**
* In some cases it is not possible to extract from the received reply the information about
@ -77,16 +79,9 @@ private:
SYRLINKS::RxDataset rxDataset;
SYRLINKS::TxDataset txDataset;
uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE];
uint8_t agcValueHighByte;
/**
* @brief This function gets the command id relating to a received read response 'R'.
*
* @param foundId Pointer to object where found id will be stored.
* @param foundLen Pointer to objet where reply length of the received response will be
* stored.
*/
void getIdAndLenForReadResponse(DeviceCommandId_t *foundId, size_t *foundLen);
uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE];
/**
* This object is used to store the id of the next command to execute. This controls the
@ -173,9 +168,11 @@ private:
void parseTxWaveformReply(const uint8_t* packet);
/**
* @brief This function writes the received AGC value to the txDataset.
* @brief The agc value is split over two registers. The parse agc functions are used to get
* the values from the received reply and write them into the txDataset.
*/
void parseTxAgcValueReply(const uint8_t* packet);
void parseAgcLowByte(const uint8_t* packet);
void parseAgcHighByte(const uint8_t* packet);
};
#endif /* MISSION_DEVICES_SYRLINKSHKHANDLER_H_ */

View File

@ -17,7 +17,8 @@ namespace SYRLINKS {
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 = 0x09;
static const DeviceCommandId_t READ_TX_AGC_VALUE_HIGH_BYTE = 0x09;
static const DeviceCommandId_t READ_TX_AGC_VALUE_LOW_BYTE = 0x0A;
/** Size of a simple transmission success response */
static const uint8_t ACK_SIZE = 11;
@ -26,12 +27,10 @@ namespace SYRLINKS {
static const uint8_t MESSAGE_HEADER_SIZE = 5;
/** Size of reply to an rx status registers request */
static const uint8_t RX_STATUS_REGISTERS_REPLY_SIZE = 49;
static const uint8_t READ_TX_STATUS_REPLY_SIZE = 13;
static const uint8_t READ_TX_WAVEFORM_REPLY_SIZE = 13;
static const uint8_t READ_TX_AGC_VALUE_REPLY_SIZE = 15;
static const uint8_t READ_ONE_REGISTER_REPLY_SIE = 13;
static const uint8_t RX_DATASET_ID = READ_RX_STATUS_REGISTERS;
static const uint8_t TX_DATASET_ID = READ_TX_STATUS;
static const uint8_t RX_DATASET_ID = 0x1;
static const uint8_t TX_DATASET_ID = 0x2;
static const size_t MAX_REPLY_SIZE = RX_STATUS_REGISTERS_REPLY_SIZE;
static const size_t MAX_COMMAND_SIZE = 15;
@ -39,7 +38,7 @@ namespace SYRLINKS {
static const size_t CRC_FIELD_SIZE = 4;
static const uint8_t RX_DATASET_SIZE = 8;
static const uint8_t TX_DATASET_SIZE = 1;
static const uint8_t TX_DATASET_SIZE = 3;
enum SyrlinksPoolIds: lp_id_t {
RX_STATUS,

2
tmtc

@ -1 +1 @@
Subproject commit 1d5fe4ebc7165c2a4979c5f9be9cfa0324e366fb
Subproject commit 81cd88f5211e0d9853ba3d9dd7611a9c2149cd55