add start method for uart man
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Robin Müller 2022-11-15 17:40:19 +01:00
parent 38e74e6eaf
commit 2b4ec6d274
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 28 additions and 21 deletions

View File

@ -95,13 +95,13 @@ void ObjectFactory::produce(void* args) {
#if OBSW_ADD_PLOC_SUPERVISOR == 1
std::string plocSupvString = "/dev/ploc_supv";
auto supervisorCookie =
new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, plocSupvString, uart::PLOC_SUPV_BAUD,
supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL);
new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, plocSupvString, uart::PLOC_SUPV_BAUD,
supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL);
supervisorCookie->setNoFixedSizeReply();
auto supvHelper = new PlocSupvUartManager(objects::PLOC_SUPERVISOR_HELPER);
new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, objects::PLOC_SUPERVISOR_HELPER,
supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, dummyGpioIF),
pcdu::PDU1_CH6_PLOC_12V, supvHelper);
pcdu::PDU1_CH6_PLOC_12V, *supvHelper);
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
#endif

View File

@ -20,7 +20,7 @@ using namespace returnvalue;
PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, Gpio uartIsolatorSwitch,
power::Switch_t powerSwitch,
PlocSupvUartManager* supvHelper)
PlocSupvUartManager& supvHelper)
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
uartIsolatorSwitch(uartIsolatorSwitch),
hkset(this),
@ -33,9 +33,6 @@ PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t u
if (comCookie == nullptr) {
sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl;
}
if (supvHelper == nullptr) {
sif::error << "PlocSupervisorHandler: Invalid PlocSupvHelper object" << std::endl;
}
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
@ -52,10 +49,6 @@ ReturnValue_t PlocSupervisorHandler::initialize() {
#ifdef XIPHOS_Q7S
sdcMan = SdCardManager::instance();
#endif /* TE0720_1CFA */
if (supvHelper == nullptr) {
sif::warning << "PlocSupervisorHandler::initialize: Invalid supervisor helper" << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = eventSubscription();
if (result != returnvalue::OK) {
@ -87,10 +80,6 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
ReturnValue_t result = returnvalue::OK;
switch (actionId) {
case TERMINATE_SUPV_HELPER: {
supvHelper->stop();
return EXECUTION_FINISHED;
}
default:
break;
}
@ -114,7 +103,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
if (result != returnvalue::OK) {
return result;
}
result = supvHelper->performUpdate(params);
result = supvHelper.performUpdate(params);
if (result != returnvalue::OK) {
return result;
}
@ -122,7 +111,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
return EXECUTION_FINISHED;
}
case CONTINUE_UPDATE: {
supvHelper->initiateUpdateContinuation();
supvHelper.initiateUpdateContinuation();
plocSupvHelperExecuting = true;
return EXECUTION_FINISHED;
}
@ -135,7 +124,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
if (not std::filesystem::exists(params.file)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
}
supvHelper->performMemCheck(params.file, params.memId, params.startAddr);
supvHelper.performMemCheck(params.file, params.memId, params.startAddr);
plocSupvHelperExecuting = true;
return EXECUTION_FINISHED;
}
@ -150,6 +139,7 @@ void PlocSupervisorHandler::doStartUp() {
switch (startupState) {
case StartupState::OFF: {
bootTimeout.resetTimer();
supvHelper.start();
startupState = StartupState::BOOTING;
break;
}
@ -177,6 +167,7 @@ void PlocSupervisorHandler::doStartUp() {
void PlocSupervisorHandler::doShutDown() {
setMode(_MODE_POWER_DOWN);
supvHelper.stop();
uartIsolatorSwitch.pullLow();
startupState = StartupState::OFF;
}

View File

@ -34,7 +34,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
public:
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
Gpio uartIsolatorSwitch, power::Switch_t powerSwitch,
PlocSupvUartManager* supvHelper);
PlocSupvUartManager& supvHelper);
virtual ~PlocSupervisorHandler();
virtual ReturnValue_t initialize() override;
@ -130,7 +130,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
const power::Switch_t powerSwitch = power::NO_SWITCH;
supv::TmBase tmReader;
PlocSupvUartManager* supvHelper = nullptr;
PlocSupvUartManager& supvHelper;
MessageQueueIF* eventQueue = nullptr;
/** Number of expected replies following the MRAM dump command */

View File

@ -94,6 +94,9 @@ ReturnValue_t PlocSupvUartManager::initialize() {
ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
bool putTaskToSleep = false;
while (true) {
lock->lockMutex();
state = InternalState::SLEEPING;
lock->unlockMutex();
semaphore->acquire();
while (true) {
putTaskToSleep = handleUartReception();
@ -289,6 +292,14 @@ void PlocSupvUartManager::stop() {
state = InternalState::GO_TO_SLEEP;
}
void PlocSupvUartManager::start() {
MutexGuard mg(lock);
if (state == InternalState::SLEEPING or state == InternalState::GO_TO_SLEEP) {
return;
}
semaphore->release();
}
void PlocSupvUartManager::executeFullCheckMemoryCommand() {
ReturnValue_t result;
if (update.crcShouldBeChecked) {

View File

@ -148,10 +148,15 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
// ReturnValue_t startEventBufferRequest(std::string path);
/**
* @brief Can be used to interrupt a running data transfer.
* @brief Can be used to stop the UART reception and put the task to sleep
*/
void stop();
/**
* @brief Can be used to start the UART reception
*/
void start();
static uint32_t buildProgParams1(uint8_t percent, uint16_t seqCount);
static uint32_t buildApidServiceParam1(uint8_t apid, uint8_t serviceId);