mpsoc startup command
This commit is contained in:
parent
25c3f39c82
commit
2dca9d598d
@ -190,9 +190,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 */
|
||||
|
||||
@ -797,7 +796,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::createRtdComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher) {
|
||||
@ -925,10 +925,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
|
||||
@ -940,10 +939,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);
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
@ -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;
|
||||
|
@ -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(&event); result == RETURN_OK;
|
||||
result = commandActionHelperQueue->receiveMessage(&event)) {
|
||||
result = commandActionHelper.handleReply(&message);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
@ -116,17 +133,34 @@ 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:
|
||||
sif::debug << "PlocMPSoCHandler::doShutDown: This should never happen" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
@ -331,7 +365,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 +704,45 @@ 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) {
|
||||
handleActionCommandFailure(actionId);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
switch(actionId) {
|
||||
case supv::START_MPSOC: {
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
case supv::SHUTDOWN_MPSOC: {
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
default:
|
||||
sif::debug
|
||||
<< "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action reply"
|
||||
<< std::endl;
|
||||
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;
|
||||
@ -764,3 +837,20 @@ 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::START_MPSOC:
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
case supv::SHUTDOWN_MPSOC:
|
||||
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
||||
// TODO: Setting state to on or off here?
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Received unexpected action reply"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
@ -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
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
@ -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,8 +1224,10 @@ ReturnValue_t StarTrackerHandler::doSendReadHook() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches,
|
||||
uint8_t* numberOfSwitches) {
|
||||
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;
|
||||
|
@ -35,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;
|
||||
@ -163,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
|
||||
@ -270,7 +268,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
|
||||
bool strHelperExecuting = false;
|
||||
|
||||
const power::Switch_t powerSwitch = pcduSwitches::PDU1_CH2_STAR_TRACKER_5V;
|
||||
const power::Switch_t powerSwitch = power::NO_SWITCH;
|
||||
|
||||
/**
|
||||
* @brief Handles internal state
|
||||
|
@ -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;
|
||||
}
|
||||
@ -146,6 +150,22 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() {
|
||||
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;
|
||||
@ -177,6 +197,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 +213,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;
|
||||
|
@ -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,16 @@ 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 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;
|
||||
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,
|
||||
@ -75,6 +81,8 @@ class SyrlinksHkHandler : public DeviceHandlerBase {
|
||||
SYRLINKS::RxDataset rxDataset;
|
||||
SYRLINKS::TxDataset txDataset;
|
||||
|
||||
const power::Switch_t powerSwitch = power::NO_SWITCH;
|
||||
|
||||
uint8_t agcValueHighByte;
|
||||
|
||||
uint8_t commandBuffer[SYRLINKS::MAX_COMMAND_SIZE];
|
||||
|
Loading…
Reference in New Issue
Block a user