added uart flush in ploc supervisor handler
This commit is contained in:
parent
009139ae50
commit
90b31f5ee7
@ -5,8 +5,8 @@
|
|||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
#include <fsfw/timemanager/Clock.h>
|
#include <fsfw/timemanager/Clock.h>
|
||||||
|
|
||||||
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) :
|
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie) :
|
||||||
DeviceHandlerBase(objectId, comIF, comCookie), hkset(this) {
|
DeviceHandlerBase(objectId, uartComIFid, comCookie), hkset(this) {
|
||||||
if (comCookie == NULL) {
|
if (comCookie == NULL) {
|
||||||
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
|
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
|
||||||
}
|
}
|
||||||
@ -15,6 +15,20 @@ PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t c
|
|||||||
PlocSupervisorHandler::~PlocSupervisorHandler() {
|
PlocSupervisorHandler::~PlocSupervisorHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t PlocSupervisorHandler::initialize() {
|
||||||
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
result = DeviceHandlerBase::initialize();
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
uartComIf = dynamic_cast<UartComIF*>(communicationInterface);
|
||||||
|
if (uartComIf == nullptr) {
|
||||||
|
sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl;
|
||||||
|
return INVALID_UART_COM_IF;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PlocSupervisorHandler::doStartUp(){
|
void PlocSupervisorHandler::doStartUp(){
|
||||||
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
||||||
@ -41,52 +55,72 @@ ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(
|
|||||||
ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||||
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
|
ReturnValue_t result = RETURN_FAILED;
|
||||||
switch(deviceCommand) {
|
switch(deviceCommand) {
|
||||||
case(PLOC_SPV::GET_HK_REPORT): {
|
case(PLOC_SPV::GET_HK_REPORT): {
|
||||||
prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT);
|
prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::RESTART_MPSOC): {
|
case(PLOC_SPV::RESTART_MPSOC): {
|
||||||
prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC);
|
prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::START_MPSOC): {
|
case(PLOC_SPV::START_MPSOC): {
|
||||||
prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC);
|
prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::SHUTDOWN_MPSOC): {
|
case(PLOC_SPV::SHUTDOWN_MPSOC): {
|
||||||
prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC);
|
prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): {
|
case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): {
|
||||||
prepareSelBootImageCmd(commandData);
|
prepareSelBootImageCmd(commandData);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::RESET_MPSOC): {
|
case(PLOC_SPV::RESET_MPSOC): {
|
||||||
prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC);
|
prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::SET_TIME_REF): {
|
case(PLOC_SPV::SET_TIME_REF): {
|
||||||
return prepareSetTimeRefCmd();
|
result = prepareSetTimeRefCmd();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::SET_BOOT_TIMEOUT): {
|
case(PLOC_SPV::SET_BOOT_TIMEOUT): {
|
||||||
prepareSetBootTimeoutCmd(commandData);
|
prepareSetBootTimeoutCmd(commandData);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::SET_MAX_RESTART_TRIES): {
|
case(PLOC_SPV::SET_MAX_RESTART_TRIES): {
|
||||||
prepareRestartTriesCmd(commandData);
|
prepareRestartTriesCmd(commandData);
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): {
|
case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): {
|
||||||
prepareDisableHk();
|
prepareDisableHk();
|
||||||
return RETURN_OK;
|
result = RETURN_OK;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
|
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
/**
|
||||||
|
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
|
||||||
|
*/
|
||||||
|
uartComIf->flushUartRxBuffer(comCookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||||
@ -222,7 +256,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
|||||||
triggerEvent(SUPV_CRC_FAILURE_EVENT);
|
triggerEvent(SUPV_CRC_FAILURE_EVENT);
|
||||||
sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE);
|
sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE);
|
||||||
disableAllReplies();
|
disableAllReplies();
|
||||||
return IGNORE_REPLY_DATA;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
||||||
@ -564,8 +598,8 @@ void PlocSupervisorHandler::disableAllReplies() {
|
|||||||
|
|
||||||
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
|
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
|
||||||
switch (commandId) {
|
switch (commandId) {
|
||||||
case PLOC_SPV::HK_REPORT: {
|
case PLOC_SPV::GET_HK_REPORT: {
|
||||||
iter = deviceReplyMap.find(PLOC_SPV::HK_REPORT);
|
iter = deviceReplyMap.find(PLOC_SPV::GET_HK_REPORT);
|
||||||
info = &(iter->second);
|
info = &(iter->second);
|
||||||
info->delayCycles = 0;
|
info->delayCycles = 0;
|
||||||
info->command = deviceCommandMap.end();
|
info->command = deviceCommandMap.end();
|
||||||
@ -608,5 +642,5 @@ void PlocSupervisorHandler::disableExeReportReply() {
|
|||||||
info->delayCycles = 0;
|
info->delayCycles = 0;
|
||||||
info->command = deviceCommandMap.end();
|
info->command = deviceCommandMap.end();
|
||||||
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
|
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
|
||||||
info->command->second.expectedReplies = 0;
|
info->command->second.expectedReplies = 1;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
#include <mission/devices/devicedefinitions/PlocSupervisorDefinitions.h>
|
#include <mission/devices/devicedefinitions/PlocSupervisorDefinitions.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <fsfw_hal/linux/uart/UartComIF.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
|
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
|
||||||
@ -20,9 +21,11 @@
|
|||||||
class PlocSupervisorHandler: public DeviceHandlerBase {
|
class PlocSupervisorHandler: public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PlocSupervisorHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
|
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie);
|
||||||
virtual ~PlocSupervisorHandler();
|
virtual ~PlocSupervisorHandler();
|
||||||
|
|
||||||
|
virtual ReturnValue_t initialize() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
@ -58,6 +61,8 @@ private:
|
|||||||
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
||||||
//! [EXPORT] : [COMMENT] Failed to read current system time
|
//! [EXPORT] : [COMMENT] Failed to read current system time
|
||||||
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4);
|
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4);
|
||||||
|
//! [EXPORT] : [COMMENT] Invalid communication interface specified
|
||||||
|
static const ReturnValue_t INVALID_UART_COM_IF = MAKE_RETURN_CODE(0xA5);
|
||||||
|
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
||||||
|
|
||||||
@ -96,6 +101,8 @@ private:
|
|||||||
|
|
||||||
PLOC_SPV::HkSet hkset;
|
PLOC_SPV::HkSet hkset;
|
||||||
|
|
||||||
|
UartComIF* uartComIf = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function checks the crc of the received PLOC reply.
|
* @brief This function checks the crc of the received PLOC reply.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user