v1.10.0 #220

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

View File

@ -191,9 +191,8 @@ void ObjectFactory::produce(void* args) {
uart::STAR_TRACKER_BAUD, startracker::MAX_FRAME_SIZE * 2 + 2);
starTrackerCookie->setNoFixedSizeReply();
StrHelper* strHelper = new StrHelper(objects::STR_HELPER);
StarTrackerHandler* starTrackerHandler = new StarTrackerHandler(
objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper);
starTrackerHandler->setStartUpImmediately();
new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie, strHelper,
pcduSwitches::PDU1_CH2_STAR_TRACKER_5V);
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
@ -643,7 +642,8 @@ void ObjectFactory::createSyrlinksComponents() {
uart::SYRLINKS_BAUD, SYRLINKS::MAX_REPLY_SIZE);
syrlinksUartCookie->setParityEven();
new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie);
new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie,
pcduSwitches::PDU1_CH1_SYRLINKS_12V);
}
void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) {
@ -661,10 +661,9 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) {
UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE);
mpsocCookie->setNoFixedSizeReply();
auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
auto plocMPSoC =
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie,
plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF));
plocMPSoC->setStartUpImmediately();
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie,
plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF),
objects::PLOC_SUPERVISOR_HANDLER);
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1
@ -676,10 +675,11 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) {
gpioComIF->addGpios(supvGpioCookie);
auto supervisorCookie = new UartCookie(
objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL,
uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20);
uart::PLOC_SUPERVISOR_BAUD, supv::MAX_PACKET_SIZE * 20);
supervisorCookie->setNoFixedSizeReply();
new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF,
supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF));
supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF),
pcduSwitches::PDU1_CH6_PLOC_12V);
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
static_cast<void>(consumer);
}

2
fsfw

@ -1 +1 @@
Subproject commit 127fbeb98020e091f9b5a385fd2a2ca47ccbc02f
Subproject commit fbf9626fde2961cf08bd88bf87f5c1bca900e287

View File

@ -25,6 +25,8 @@ class MPSoCReturnValuesIF {
static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Command has invalid parameter
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8);
//! [EXPORT] : [COMMENT] Received command has file string with invalid length
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xA9);
};
#endif /* MPSOC_RETURN_VALUES_IF_H_ */

View File

@ -8,7 +8,7 @@
#include <fsfw/timemanager/Clock.h>
#include <fsfw/tmtcpacket/SpacePacket.h>
namespace PLOC_SPV {
namespace supv {
/** Command IDs */
static const DeviceCommandId_t NONE = 0;

View File

@ -1,4 +1,5 @@
#include "PlocMPSoCHandler.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
#include "OBSWConfig.h"
#include "fsfw/datapool/PoolReadGuard.h"
@ -6,14 +7,18 @@
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
Gpio uartIsolatorSwitch)
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
plocMPSoCHelper(plocMPSoCHelper),
uartIsolatorSwitch(uartIsolatorSwitch) {
uartIsolatorSwitch(uartIsolatorSwitch),
supervisorHandler(supervisorHandler),
commandActionHelper(this) {
if (comCookie == nullptr) {
sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl;
}
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
commandActionHelperQueue =
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
}
PlocMPSoCHandler::~PlocMPSoCHandler() {}
@ -60,6 +65,10 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
}
plocMPSoCHelper->setComCookie(comCookie);
plocMPSoCHelper->setSequenceCount(&sequenceCount);
result = commandActionHelper.initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return result;
}
@ -77,6 +86,14 @@ void PlocMPSoCHandler::performOperationHook() {
break;
}
}
CommandMessage message;
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message); result == RETURN_OK;
result = commandActionHelperQueue->receiveMessage(&message)) {
result = commandActionHelper.handleReply(&message);
if (result == RETURN_OK) {
continue;
}
}
}
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
@ -116,17 +133,33 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
}
void PlocMPSoCHandler::doStartUp() {
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
#else
setMode(_MODE_TO_ON);
#endif
uartIsolatorSwitch.pullHigh();
switch(powerState) {
case PowerState::OFF:
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
powerState = PowerState::BOOTING;
break;
case PowerState::ON:
setMode(_MODE_TO_ON);
uartIsolatorSwitch.pullHigh();
break;
default:
break;
}
}
void PlocMPSoCHandler::doShutDown() {
uartIsolatorSwitch.pullLow();
setMode(_MODE_POWER_DOWN);
switch(powerState) {
case PowerState::ON:
uartIsolatorSwitch.pullLow();
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
powerState = PowerState::SHUTDOWN;
break;
case PowerState::OFF:
setMode(_MODE_POWER_DOWN);
break;
default:
break;
}
}
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
@ -134,7 +167,7 @@ ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id)
}
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
return HasReturnvaluesIF::RETURN_OK;
return NOTHING_TO_SEND;
}
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
@ -279,7 +312,7 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {}
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; }
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
@ -331,7 +364,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return NAME_TOO_LONG;
return MPSoCReturnValuesIF::NAME_TOO_LONG;
}
ReturnValue_t result = RETURN_OK;
sequenceCount++;
@ -670,6 +703,66 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
return replyLen;
}
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() {
return commandActionHelperQueue;
}
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {
return;
}
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
ReturnValue_t returnCode) {
switch (actionId) {
case supv::START_MPSOC:
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC"
<< std::endl;
powerState = PowerState::OFF;
break;
case supv::SHUTDOWN_MPSOC:
triggerEvent(MPSOC_SHUTDOWN_FAILED);
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC"
<< std::endl;
// TODO: Setting state to on or off here?
powerState = PowerState::ON;
break;
default:
sif::debug
<< "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply"
<< std::endl;
break;
}
}
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
return;
}
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
if (actionId != supv::EXE_REPORT) {
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
<< "ID" << std::endl;
return;
}
switch(powerState) {
case PowerState::BOOTING: {
powerState = PowerState::ON;
break;
}
case PowerState::SHUTDOWN: {
powerState = PowerState::OFF;
break;
}
default: {
break;
}
}
}
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
handleActionCommandFailure(actionId);
}
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
DeviceCommandId_t replyId) {
ReturnValue_t result = RETURN_OK;
@ -725,7 +818,7 @@ void PlocMPSoCHandler::disableAllReplies() {
}
}
/* We must always disable the execution report reply here */
/* We always need to disable the execution report reply here */
disableExeReportReply();
nextReplyId = mpsoc::NONE;
}
@ -764,3 +857,32 @@ void PlocMPSoCHandler::printStatus(const uint8_t* data) {
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) {
return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1);
}
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
switch (actionId) {
case supv::ACK_REPORT:
case supv::EXE_REPORT:
break;
default:
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID "
<< std::endl;
return;
}
switch(powerState) {
case PowerState::BOOTING: {
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC"
<< std::endl;
powerState = PowerState::OFF;
break;
}
case PowerState::SHUTDOWN: {
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC"
<< std::endl;
powerState = PowerState::ON;
break;
}
default:
break;
}
return;
}

View File

@ -4,6 +4,8 @@
#include <string>
#include "PlocMPSoCHelper.h"
#include "fsfw/action/CommandActionHelper.h"
#include "fsfw/action/CommandsActionsIF.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
@ -26,15 +28,33 @@
*
* @author J. Meier
*/
class PlocMPSoCHandler : public DeviceHandlerBase {
class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
public:
/**
* @brief Constructor
*
* @param ojectId Object ID of the MPSoC handler
* @param uartcomIFid Object ID of the UART communication interface
* @param comCookie UART communication cookie
* @param plocMPSoCHelper Pointer to MPSoC helper object
* @param uartIsolatorSwitch Gpio object representing the GPIO connected to the UART isolator
* module in the programmable logic
* @param supervisorHandler Object ID of the supervisor handler
*/
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch);
PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch,
object_id_t supervisorHandler);
virtual ~PlocMPSoCHandler();
virtual ReturnValue_t initialize() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
void performOperationHook() override;
MessageQueueIF* getCommandQueuePtr() override;
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override;
void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override;
void completionSuccessfulReceived(ActionId_t actionId) override;
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
protected:
void doStartUp() override;
@ -74,15 +94,16 @@ class PlocMPSoCHandler : public DeviceHandlerBase {
//! [EXPORT] : [COMMENT] Packet sequence count in received space packet does not match expected
//! count P1: Expected sequence count P2: Received sequence count
static const Event MPSOC_HANDLER_SEQ_CNT_MISMATCH = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Received command has file string with invalid length
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xD0);
//! [EXPORT] : [COMMENT] Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and
//! thus also to shutdown the supervisor.
static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH);
static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
static const uint8_t STATUS_OFFSET = 10;
MessageQueueIF* eventQueue = nullptr;
MessageQueueIF* commandActionHelperQueue = nullptr;
SourceSequenceCounter sequenceCount;
@ -99,6 +120,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase {
PlocMPSoCHelper* plocMPSoCHelper = nullptr;
Gpio uartIsolatorSwitch;
object_id_t supervisorHandler = 0;
CommandActionHelper commandActionHelper;
// Used to block incoming commands when MPSoC helper class is currently executing a command
bool plocMPSoCHelperExecuting = false;
@ -111,6 +134,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase {
TmMemReadReport tmMemReadReport;
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON };
PowerState powerState = PowerState::OFF;
/**
* @brief Handles events received from the PLOC MPSoC helper
*/
@ -212,6 +239,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase {
ReturnValue_t prepareTcModeReplay();
uint16_t getStatus(const uint8_t* data);
void handleActionCommandFailure(ActionId_t actionId);
};
#endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */

View File

@ -105,10 +105,10 @@ void PlocMemoryDumper::doStateMachine() {
case State::IDLE:
break;
case State::COMMAND_FIRST_MRAM_DUMP:
commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP);
commandNextMramDump(supv::FIRST_MRAM_DUMP);
break;
case State::COMMAND_CONSECUTIVE_MRAM_DUMP:
commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP);
commandNextMramDump(supv::CONSECUTIVE_MRAM_DUMP);
break;
case State::EXECUTING_MRAM_DUMP:
break;
@ -127,8 +127,8 @@ void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, ui
void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) {
switch (pendingCommand) {
case (PLOC_SPV::FIRST_MRAM_DUMP):
case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP):
case (supv::FIRST_MRAM_DUMP):
case (supv::CONSECUTIVE_MRAM_DUMP):
if (mram.endAddress == mram.startAddress) {
triggerEvent(MRAM_DUMP_FINISHED);
state = State::IDLE;
@ -146,8 +146,8 @@ void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) {
void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
switch (pendingCommand) {
case (PLOC_SPV::FIRST_MRAM_DUMP):
case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP):
case (supv::FIRST_MRAM_DUMP):
case (supv::CONSECUTIVE_MRAM_DUMP):
triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress);
break;
default:

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@
class PlocSupervisorHandler : public DeviceHandlerBase {
public:
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
Gpio uartIsolatorSwitch);
Gpio uartIsolatorSwitch, power::Switch_t powerSwitch);
virtual ~PlocSupervisorHandler();
virtual ReturnValue_t initialize() override;
@ -105,24 +105,24 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE];
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
/**
* This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = PLOC_SPV::NONE;
DeviceCommandId_t nextReplyId = supv::NONE;
UartComIF* uartComIf = nullptr;
LinuxLibgpioIF* gpioComIF = nullptr;
Gpio uartIsolatorSwitch;
PLOC_SPV::HkSet hkset;
PLOC_SPV::BootStatusReport bootStatusReport;
PLOC_SPV::LatchupStatusReport latchupStatusReport;
supv::HkSet hkset;
supv::BootStatusReport bootStatusReport;
supv::LatchupStatusReport latchupStatusReport;
const power::Switch_t powerSwitch = pcduSwitches::PDU1_CH6_PLOC_12V;
const power::Switch_t powerSwitch = power::NO_SWITCH;
/** Number of expected replies following the MRAM dump command */
uint32_t expectedMramDumpPackets = 0;
@ -133,7 +133,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
uint16_t bufferTop = 0;
/** This buffer is used to concatenate space packets received in two different read steps */
uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE];
uint8_t spacePacketBuffer[supv::MAX_PACKET_SIZE];
#ifdef TE0720_1CFA
SdCardManager* sdcMan = nullptr;

View File

@ -123,9 +123,6 @@ void PlocUpdater::readCommandQueue() {
if (result == HasReturnvaluesIF::RETURN_OK) {
continue;
}
sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format"
<< std::endl;
}
}
@ -145,7 +142,6 @@ void PlocUpdater::doStateMachine() {
case State::COMMAND_EXECUTING:
break;
default:
sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl;
break;
}
}
@ -199,10 +195,10 @@ void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_
void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
switch (pendingCommand) {
case (PLOC_SPV::UPDATE_AVAILABLE):
case (supv::UPDATE_AVAILABLE):
state = State::UPDATE_TRANSFER;
break;
case (PLOC_SPV::UPDATE_IMAGE_DATA):
case (supv::UPDATE_IMAGE_DATA):
if (remainingPackets == 0) {
packetsSent = 0; // Reset packets sent variable for next update sequence
state = State::UPDATE_VERIFY;
@ -210,14 +206,12 @@ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
state = State::UPDATE_TRANSFER;
}
break;
case (PLOC_SPV::UPDATE_VERIFY):
case (supv::UPDATE_VERIFY):
triggerEvent(UPDATE_FINISHED);
state = State::IDLE;
pendingCommand = PLOC_SPV::NONE;
pendingCommand = supv::NONE;
break;
default:
sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command"
<< std::endl;
state = State::IDLE;
break;
}
@ -225,20 +219,19 @@ void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
void PlocUpdater::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
switch (pendingCommand) {
case (PLOC_SPV::UPDATE_AVAILABLE): {
case (supv::UPDATE_AVAILABLE): {
triggerEvent(UPDATE_AVAILABLE_FAILED);
break;
}
case (PLOC_SPV::UPDATE_IMAGE_DATA): {
case (supv::UPDATE_IMAGE_DATA): {
triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent);
break;
}
case (PLOC_SPV::UPDATE_VERIFY): {
case (supv::UPDATE_VERIFY): {
triggerEvent(UPDATE_VERIFY_FAILED);
break;
}
default:
sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command " << std::endl;
break;
}
state = State::IDLE;
@ -268,23 +261,23 @@ void PlocUpdater::commandUpdateAvailable() {
calcImageCrc();
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(image),
supv::UpdateInfo packet(supv::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(image),
static_cast<uint8_t>(partition), imageSize, imageCrc,
numOfUpdatePackets);
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(),
supv::UPDATE_AVAILABLE, packet.getWholeData(),
packet.getFullSize());
if (result != RETURN_OK) {
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
<< " packet to supervisor handler" << std::endl;
triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE);
triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_AVAILABLE);
state = State::IDLE;
pendingCommand = PLOC_SPV::NONE;
pendingCommand = supv::NONE;
return;
}
pendingCommand = PLOC_SPV::UPDATE_AVAILABLE;
pendingCommand = supv::UPDATE_AVAILABLE;
state = State::COMMAND_EXECUTING;
return;
}
@ -308,56 +301,56 @@ void PlocUpdater::commandUpdatePacket() {
payloadLength = MAX_SP_DATA;
}
PLOC_SPV::UpdatePacket packet(payloadLength);
supv::UpdatePacket packet(payloadLength);
file.read(reinterpret_cast<char*>(packet.getDataFieldPointer()), payloadLength);
file.close();
// sequence count of first packet is 1
packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK);
packet.setPacketSequenceCount((packetsSent + 1) & supv::SEQUENCE_COUNT_MASK);
if (numOfUpdatePackets > 1) {
adjustSequenceFlags(packet);
}
packet.makeCrc();
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(),
supv::UPDATE_IMAGE_DATA, packet.getWholeData(),
packet.getFullSize());
if (result != RETURN_OK) {
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update"
<< " packet to supervisor handler" << std::endl;
triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA);
triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_IMAGE_DATA);
state = State::IDLE;
pendingCommand = PLOC_SPV::NONE;
pendingCommand = supv::NONE;
return;
}
remainingPackets--;
packetsSent++;
pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA;
pendingCommand = supv::UPDATE_IMAGE_DATA;
state = State::COMMAND_EXECUTING;
}
void PlocUpdater::commandUpdateVerify() {
ReturnValue_t result = RETURN_OK;
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast<uint8_t>(image),
supv::UpdateInfo packet(supv::APID_UPDATE_VERIFY, static_cast<uint8_t>(image),
static_cast<uint8_t>(partition), imageSize, imageCrc,
numOfUpdatePackets);
result =
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY,
commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY,
packet.getWholeData(), packet.getFullSize());
if (result != RETURN_OK) {
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
<< " packet to supervisor handler" << std::endl;
triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY);
triggerEvent(ACTION_COMMANDING_FAILED, result, supv::UPDATE_VERIFY);
state = State::IDLE;
pendingCommand = PLOC_SPV::NONE;
pendingCommand = supv::NONE;
return;
}
state = State::COMMAND_EXECUTING;
pendingCommand = PLOC_SPV::UPDATE_VERIFY;
pendingCommand = supv::UPDATE_VERIFY;
return;
}
@ -384,12 +377,12 @@ void PlocUpdater::calcImageCrc() {
imageCrc = (remainder ^ FINAL_XOR_VALUE_32);
}
void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) {
void PlocUpdater::adjustSequenceFlags(supv::UpdatePacket& packet) {
if (packetsSent == 0) {
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::FIRST_PKT));
packet.setSequenceFlags(static_cast<uint8_t>(supv::SequenceFlags::FIRST_PKT));
} else if (remainingPackets == 1) {
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::LAST_PKT));
packet.setSequenceFlags(static_cast<uint8_t>(supv::SequenceFlags::LAST_PKT));
} else {
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::CONTINUED_PKT));
packet.setSequenceFlags(static_cast<uint8_t>(supv::SequenceFlags::CONTINUED_PKT));
}
}

View File

@ -23,7 +23,7 @@
* packets and sent to the PlocSupervisorHandler.
*
* @details The MPSoC has two boot memories (NVM0 and NVM1) where each stores two images (Partition
* A and Partition B)
* A and Partition B)
*
* @author J. Meier
*/
@ -122,7 +122,7 @@ class PlocUpdater : public SystemObject,
State state = State::IDLE;
ActionId_t pendingCommand = PLOC_SPV::NONE;
ActionId_t pendingCommand = supv::NONE;
enum class Image : uint8_t { NONE, A, B };
@ -168,7 +168,7 @@ class PlocUpdater : public SystemObject,
void calcImageCrc();
void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet);
void adjustSequenceFlags(supv::UpdatePacket& packet);
};
#endif /* MISSION_DEVICES_PLOCUPDATER_H_ */

View File

@ -15,7 +15,7 @@ extern "C" {
}
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
StrHelper* strHelper)
StrHelper* strHelper, power::Switch_t powerSwitch)
: DeviceHandlerBase(objectId, comIF, comCookie),
temperatureSet(this),
versionSet(this),
@ -39,7 +39,8 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
subscriptionSet(this),
logSubscriptionSet(this),
debugCameraSet(this),
strHelper(strHelper) {
strHelper(strHelper),
powerSwitch(powerSwitch) {
if (comCookie == nullptr) {
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
}
@ -1223,6 +1224,15 @@ ReturnValue_t StarTrackerHandler::doSendReadHook() {
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
if (powerSwitch == power::NO_SWITCH) {
return DeviceHandlerBase::NO_SWITCH;
}
*numberOfSwitches = 1;
*switches = &powerSwitch;
return RETURN_OK;
}
ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) {
switch (actionId) {
case startracker::UPLOAD_IMAGE:

View File

@ -12,6 +12,7 @@
#include "fsfw/timemanager/Countdown.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
#include "thirdparty/arcsec_star_tracker/common/SLIP.h"
#include "devices/powerSwitcherList.h"
/**
* @brief This is the device handler for the star tracker from arcsec.
@ -34,7 +35,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
* to high to enable the device.
*/
StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
StrHelper* strHelper);
StrHelper* strHelper, power::Switch_t powerSwitch);
virtual ~StarTrackerHandler();
ReturnValue_t initialize() override;
@ -75,6 +76,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
*/
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
virtual ReturnValue_t doSendReadHook() override;
ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override;
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
private:
@ -161,14 +163,12 @@ class StarTrackerHandler : public DeviceHandlerBase {
static const uint32_t BOOT_TIMEOUT = 1000;
static const uint32_t DEFAULT_TRANSITION_DELAY = 15000;
class FlashReadCmd {
public:
struct FlashReadCmd {
// Minimum length of a read command (region, length and filename)
static const size_t MIN_LENGTH = 7;
};
class ChecksumCmd {
public:
struct ChecksumCmd {
static const uint8_t ADDRESS_OFFSET = 1;
static const uint8_t LENGTH_OFFSET = 5;
// Length of checksum command
@ -268,6 +268,8 @@ class StarTrackerHandler : public DeviceHandlerBase {
bool strHelperExecuting = false;
const power::Switch_t powerSwitch = power::NO_SWITCH;
/**
* @brief Handles internal state
*/

View File

@ -326,6 +326,7 @@ void PdecHandler::handleNewTc() {
printTC(tcLength);
#endif /* OBSW_DEBUG_PDEC_HANDLER */
#if OBSW_TC_FROM_PDEC == 1
store_address_t storeId;
result = tcStore->addData(&storeId, tcSegment + 1, tcLength - 1);
if (result != RETURN_OK) {
@ -343,6 +344,7 @@ void PdecHandler::handleNewTc() {
tcStore->deleteData(storeId);
return;
}
#endif /* OBSW_TC_FROM_PDEC == 1 */
return;
}

View File

@ -91,6 +91,16 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
rawPacketLen = RAD_SENSOR::READ_SIZE;
return RETURN_OK;
}
case RAD_SENSOR::ENABLE_DEBUG_OUTPUT: {
printPeriodicData = true;
rawPacketLen = 0;
return RETURN_OK;
}
case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: {
rawPacketLen = 0;
printPeriodicData = false;
return RETURN_OK;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
@ -100,6 +110,8 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t
void RadiationSensorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(RAD_SENSOR::WRITE_SETUP);
this->insertInCommandMap(RAD_SENSOR::START_CONVERSION);
this->insertInCommandMap(RAD_SENSOR::ENABLE_DEBUG_OUTPUT);
this->insertInCommandMap(RAD_SENSOR::DISABLE_DEBUG_OUTPUT);
this->insertInCommandAndReplyMap(RAD_SENSOR::READ_CONVERSIONS, 1, &dataset,
RAD_SENSOR::READ_SIZE);
}
@ -111,18 +123,23 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t
switch (*foundId) {
case RAD_SENSOR::START_CONVERSION:
case RAD_SENSOR::WRITE_SETUP:
*foundLen = remainingSize;
return IGNORE_REPLY_DATA;
case RAD_SENSOR::READ_CONVERSIONS: {
ReturnValue_t result = gpioIF->pullLow(gpioIds::ENABLE_RADFET);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << "RadiationSensorHandler::buildCommandFromCommand; Pulling RADFET Enale pin "
sif::warning << "RadiationSensorHandler::scanForReply; Pulling RADFET Enale pin "
"low failed"
<< std::endl;
#endif
}
break;
}
case RAD_SENSOR::ENABLE_DEBUG_OUTPUT:
case RAD_SENSOR::DISABLE_DEBUG_OUTPUT:
sif::info << "RadiationSensorHandler::scanForReply: " << remainingSize << std::endl;
break;
default:
break;
}

View File

@ -4,8 +4,12 @@
#include "OBSWConfig.h"
SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie)
: DeviceHandlerBase(objectId, comIF, comCookie), rxDataset(this), txDataset(this) {
SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
power::Switch_t powerSwitch)
: DeviceHandlerBase(objectId, comIF, comCookie),
rxDataset(this),
txDataset(this),
powerSwitch(powerSwitch) {
if (comCookie == NULL) {
sif::error << "SyrlinksHkHandler: Invalid com cookie" << std::endl;
}
@ -41,6 +45,22 @@ ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand(DeviceCommandId_t* id)
break;
case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE):
*id = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE;
nextCommand = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE;
break;
case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE):
*id = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE;
nextCommand = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE;
break;
case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE):
*id = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE;
nextCommand = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE;
break;
case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE):
*id = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE;
nextCommand = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE;
break;
case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE):
*id = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE;
nextCommand = SYRLINKS::READ_RX_STATUS_REGISTERS;
break;
default:
@ -84,6 +104,12 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::WRITE_LCL_CONFIG): {
writeLclConfig.copy(reinterpret_cast<char*>(commandBuffer), writeLclConfig.size(), 0);
rawPacketLen = writeLclConfig.size();
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_RX_STATUS_REGISTERS): {
readRxStatusRegCommand.copy(reinterpret_cast<char*>(commandBuffer),
readRxStatusRegCommand.size(), 0);
@ -91,6 +117,13 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic
rawPacket = commandBuffer;
return RETURN_OK;
}
case (SYRLINKS::READ_LCL_CONFIG): {
readLclConfig.copy(reinterpret_cast<char*>(commandBuffer), readLclConfig.size(), 0);
rawPacketLen = readLclConfig.size();
rawPacket = commandBuffer;
rememberCommandId = SYRLINKS::READ_LCL_CONFIG;
return RETURN_OK;
}
case (SYRLINKS::READ_TX_STATUS): {
readTxStatus.copy(reinterpret_cast<char*>(commandBuffer), readTxStatus.size(), 0);
rawPacketLen = readTxStatus.size();
@ -99,26 +132,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):
tempPowerAmpBoardLowByte.copy(reinterpret_cast<char*>(commandBuffer), tempPowerAmpBoardLowByte.size(),
0);
rawPacketLen = tempPowerAmpBoardLowByte.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;
}
@ -134,6 +194,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::READ_TX_STATUS, 1, &txDataset,
SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
this->insertInCommandAndReplyMap(SYRLINKS::READ_TX_WAVEFORM, 1, &txDataset,
@ -142,6 +206,14 @@ 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);
}
@ -177,6 +249,15 @@ ReturnValue_t SyrlinksHkHandler::scanForReply(const uint8_t* start, size_t remai
return result;
}
ReturnValue_t SyrlinksHkHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
if (powerSwitch == power::NO_SWITCH) {
return DeviceHandlerBase::NO_SWITCH;
}
*numberOfSwitches = 1;
*switches = &powerSwitch;
return RETURN_OK;
}
ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
ReturnValue_t result;
@ -184,7 +265,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons
case (SYRLINKS::ACK_REPLY):
result = verifyReply(packet, SYRLINKS::ACK_SIZE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgement reply has "
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Acknowledgment reply has "
"invalid crc"
<< std::endl;
return CRC_FAILURE;
@ -204,6 +285,15 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons
}
parseRxStatusRegistersReply(packet);
break;
case (SYRLINKS::READ_LCL_CONFIG):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
sif::error << "SyrlinksHkHandler::interpretDeviceReply: Read config lcl reply "
<< "has invalid crc" << std::endl;
return CRC_FAILURE;
}
parseLclConfigReply(packet);
break;
case (SYRLINKS::READ_TX_STATUS):
result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE);
if (result != RETURN_OK) {
@ -240,6 +330,56 @@ 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);
sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C"
<< std::endl;
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;
}
rawTempPowerAmplifier = 0;
rawTempPowerAmplifier = 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;
}
rawTempPowerAmplifier |= convertHexStringToUint8(
reinterpret_cast<const char*>(packet + SYRLINKS::MESSAGE_HEADER_SIZE));
tempPowerAmplifier = calcTempVal(rawTempPowerAmplifier);
sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C"
<< std::endl;
break;
default: {
sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
@ -390,6 +530,13 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) {
#endif
}
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;
}
void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) {
PoolReadGuard readHelper(&txDataset);
uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE;
@ -449,3 +596,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

@ -1,8 +1,9 @@
#ifndef MISSION_DEVICES_SYRLINKSHKHANDLER_H_
#define MISSION_DEVICES_SYRLINKSHKHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/SyrlinksDefinitions.h>
#include "devices/powerSwitcherList.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
#include <string.h>
/**
@ -15,7 +16,8 @@
*/
class SyrlinksHkHandler : public DeviceHandlerBase {
public:
SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
power::Switch_t powerSwitch);
virtual ~SyrlinksHkHandler();
/**
@ -28,12 +30,13 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
void fillCommandAndReplyMap() 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;
ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
@ -55,16 +58,23 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
static const uint8_t CRC_INITIAL_VALUE = 0x0;
// Uses CRC-16/XMODEM
std::string resetCommand = "<C04:5A5A:FF41>";
std::string readRxStatusRegCommand = "<E00::825B>";
std::string setTxModeStandby = "<W04:4000:7E58>";
/** W - write, 04 - 4 bytes in data field, 01 - value, 40 register to write value */
std::string setTxModeModulation = "<W04:4001:4D69>";
std::string setTxModeCw = "<W04:4010:4968>";
std::string writeLclConfig = "<W04:0707:3FE4>";
std::string readTxStatus = "<R02:40:7555>";
std::string readTxWaveform = "<R02:44:B991>";
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
@ -75,7 +85,13 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
SYRLINKS::RxDataset rxDataset;
SYRLINKS::TxDataset txDataset;
uint8_t agcValueHighByte;
const power::Switch_t powerSwitch = power::NO_SWITCH;
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];
@ -152,6 +168,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
*/
void parseRxStatusRegistersReply(const uint8_t* packet);
void parseLclConfigReply(const uint8_t* packet);
/**
* @brief This function writes the read tx status register to the txStatusDataset.
* @param packet Pointer to the received packet.
@ -169,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

@ -9,9 +9,11 @@ static const DeviceCommandId_t NONE = 0x0; // Set when no command is pending
* This command initiates the ADC conversion for all channels including the internal
* temperature sensor.
*/
static const DeviceCommandId_t WRITE_SETUP = 0x1;
static const DeviceCommandId_t START_CONVERSION = 0x2;
static const DeviceCommandId_t READ_CONVERSIONS = 0x3;
static const DeviceCommandId_t WRITE_SETUP = 1;
static const DeviceCommandId_t START_CONVERSION = 2;
static const DeviceCommandId_t READ_CONVERSIONS = 3;
static const DeviceCommandId_t ENABLE_DEBUG_OUTPUT = 4;
static const DeviceCommandId_t DISABLE_DEBUG_OUTPUT = 5;
/**
* @brief This is the configuration byte which will be written to the setup register after

View File

@ -3,21 +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;

View File

@ -313,7 +313,7 @@ void CCSDSHandler::enableTransmit() {
return;
}
transmitterCountdown.setTimeout(TRANSMITTER_TIMEOUT);
#ifdef TE0720_1CFA
#ifndef TE0720_1CFA
gpioIF->pullHigh(enTxClock);
gpioIF->pullHigh(enTxData);
#endif /* BOARD_TE0720 == 0 */