v1.17.0 #327

Merged
muellerr merged 131 commits from develop into main 2022-11-28 18:29:31 +01:00
5 changed files with 66 additions and 81 deletions
Showing only changes of commit 32865d1834 - Show all commits

View File

@ -15,8 +15,7 @@
namespace supv {
typedef struct
{
typedef struct {
// The most significant bit of msec value is set to 0x80 to indicate that full
// time and data information is transmitted, when the time has been synced with
// the reference. If the time has not been synced with reference, then the most
@ -171,9 +170,7 @@ enum class LatchupMonServiceIds: uint8_t {
// keep the enum here in case some are added
enum class AdcMonServiceIds : uint8_t {};
enum class DataLoggerServiceIds: uint8_t {
FACTORY_RESET = 0x07
};
enum class DataLoggerServiceIds : uint8_t { FACTORY_RESET = 0x07 };
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
@ -378,9 +375,7 @@ class SupvTcBase : public ploc::SpTcBase {
SupvTcBase(SupvTcParams params) : ploc::SpTcBase(params) {}
SupvTcBase(SupvTcParams params, uint16_t apid, uint16_t seqCount)
: ploc::SpTcBase(params, apid, seqCount) {
}
: ploc::SpTcBase(params, apid, seqCount) {}
private:
};

View File

@ -1,4 +1,4 @@
target_sources(
${OBSW_NAME}
PRIVATE PlocSupervisorHandler.cpp PlocMemoryDumper.cpp PlocMPSoCHandler.cpp
PlocMPSoCHelper.cpp PlocSupvHelper.cpp)
PlocMPSoCHelper.cpp PlocSupvUartMan.cpp)

View File

@ -1,8 +1,9 @@
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
#include <linux/devices/ploc/PlocSupvUartMan.h>
#include "OBSWConfig.h"
#include "PlocSupvHelper.h"
#include "bsp_q7s/fs/SdCardManager.h"
#include "devices/powerSwitcherList.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h"

View File

@ -1,9 +1,8 @@
#include "PlocSupvHelper.h"
#include <etl/crc16_ccitt.h>
#include <fcntl.h> // Contains file controls like O_RDWR
#include <fsfw/filesystem/HasFileSystemIF.h>
#include <fsfw/tasks/SemaphoreFactory.h>
#include <linux/devices/ploc/PlocSupvUartMan.h>
#include <unistd.h>
#include <cmath>
@ -90,36 +89,37 @@ ReturnValue_t PlocSupvHelper::initialize() {
}
ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
lock->lockMutex();
state = InternalState::IDLE;
lock->unlockMutex();
bool putTaskToSleep = false;
while (true) {
semaphore->acquire();
while (true) {
putTaskToSleep = handleUartReception();
if (putTaskToSleep) {
performUartShutdown();
break;
}
lock->lockMutex();
InternalState currentState = state;
lock->unlockMutex();
switch (currentState) {
case InternalState::IDLE: {
case InternalState::SLEEPING:
case InternalState::GO_TO_SLEEP: {
putTaskToSleep = true;
break;
}
case InternalState::FINISH: {
state = InternalState::IDLE;
putTaskToSleep = true;
case InternalState::LONGER_REQUEST: {
if (handleRunningLongerRequest() == REQUEST_DONE) {
MutexGuard mg(lock);
state = InternalState::DEFAULT;
}
break;
}
case InternalState::RUNNING: {
putTaskToSleep = handleRunningRequest();
case InternalState::DEFAULT: {
break;
}
}
if (putTaskToSleep) {
performUartShutdown();
break;
}
}
@ -133,10 +133,7 @@ bool PlocSupvHelper::handleUartReception() {
if (bytesRead == 0) {
{
MutexGuard mg(lock);
if (state == InternalState::FINISH) {
// Flush received and unread data
tcflush(serialPort, TCIOFLUSH);
state = InternalState::IDLE;
if (state == InternalState::GO_TO_SLEEP) {
return true;
}
}
@ -869,23 +866,15 @@ void PlocSupvHelper::resetSpParams() { spParams.buf = commandBuffer; }
ReturnValue_t PlocSupvHelper::sendMessage(CookieIF* cookie, const uint8_t* sendData,
size_t sendLen) {
ReturnValue_t result;
if (sendData == nullptr or sendLen == 0) {
return FAILED;
}
lock->lockMutex();
if (state != InternalState::IDLE) {
if (state == InternalState::SLEEPING or state == InternalState::LONGER_REQUEST) {
lock->unlockMutex();
return FAILED;
}
tcflush(serialPort, TCIFLUSH);
state = InternalState::RUNNING;
lock->unlockMutex();
result = semaphore->release();
if (result != OK) {
std::cout << "PlocSupvHelper::sendMessage: Releasing semaphore failed" << std::endl;
}
return encodeAndSendPacket(sendData, sendLen);
}
@ -895,7 +884,7 @@ ReturnValue_t PlocSupvHelper::requestReceiveMessage(CookieIF* cookie, size_t req
return returnvalue::OK;
}
bool PlocSupvHelper::handleRunningRequest() {
ReturnValue_t PlocSupvHelper::handleRunningLongerRequest() {
ReturnValue_t result = OK;
switch (request) {
case Request::UPDATE: {
@ -907,15 +896,11 @@ bool PlocSupvHelper::handleRunningRequest() {
} else {
triggerEvent(SUPV_UPDATE_FAILED, result);
}
MutexGuard mg(lock);
state = InternalState::IDLE;
return true;
break;
}
case Request::CHECK_MEMORY: {
executeFullCheckMemoryCommand();
MutexGuard mg(lock);
state = InternalState::IDLE;
return true;
break;
}
case Request::CONTINUE_UPDATE: {
result = continueUpdate();
@ -926,9 +911,7 @@ bool PlocSupvHelper::handleRunningRequest() {
} else {
triggerEvent(SUPV_CONTINUE_UPDATE_FAILED, result);
}
MutexGuard mg(lock);
state = InternalState::IDLE;
return true;
break;
}
case Request::REQUEST_EVENT_BUFFER: {
result = performEventBufferRequest();
@ -940,11 +923,9 @@ bool PlocSupvHelper::handleRunningRequest() {
} else {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
}
MutexGuard mg(lock);
state = InternalState::IDLE;
return true;
break;
}
case Request::HANDLER_DRIVEN: {
case Request::DEFAULT: {
break;
}
}
@ -1037,3 +1018,8 @@ ReturnValue_t PlocSupvHelper::parseRecRingBufForHdlc(size_t& readSize) {
}
return NO_PACKET_FOUND;
}
void PlocSupvHelper::performUartShutdown() {
tcflush(serialPort, TCIOFLUSH);
state = InternalState::GO_TO_SLEEP;
}

View File

@ -158,11 +158,12 @@ class PlocSupvHelper : public DeviceCommunicationIF,
static uint32_t buildProgParams1(uint8_t percent, uint16_t seqCount);
private:
static constexpr ReturnValue_t NO_PACKET_FOUND = returnvalue::makeCode(1, 0);
static constexpr ReturnValue_t DECODE_BUF_TOO_SMALL = returnvalue::makeCode(1, 1);
static constexpr ReturnValue_t REQUEST_DONE = returnvalue::makeCode(1, 0);
static constexpr ReturnValue_t NO_PACKET_FOUND = returnvalue::makeCode(1, 1);
static constexpr ReturnValue_t DECODE_BUF_TOO_SMALL = returnvalue::makeCode(1, 2);
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_START =
returnvalue::makeCode(1, 2);
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_END = returnvalue::makeCode(1, 3);
returnvalue::makeCode(1, 3);
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_END = returnvalue::makeCode(1, 4);
static const uint16_t CRC16_INIT = 0xFFFF;
// Event buffer reply will carry 24 space packets with 1016 bytes and one space packet with
@ -211,17 +212,17 @@ class PlocSupvHelper : public DeviceCommunicationIF,
EventBufferRequest eventBufferReq;
enum class InternalState { IDLE, RUNNING, FINISH };
enum class InternalState { SLEEPING, DEFAULT, LONGER_REQUEST, GO_TO_SLEEP };
enum class Request {
HANDLER_DRIVEN,
DEFAULT,
UPDATE,
CONTINUE_UPDATE,
REQUEST_EVENT_BUFFER,
CHECK_MEMORY,
};
InternalState state = InternalState::IDLE;
Request request = Request::HANDLER_DRIVEN;
InternalState state = InternalState::SLEEPING;
Request request = Request::DEFAULT;
#ifdef XIPHOS_Q7S
SdCardManager* sdcMan = nullptr;
@ -255,7 +256,7 @@ class PlocSupvHelper : public DeviceCommunicationIF,
// Remembers APID to know at which command a procedure failed
uint16_t rememberApid = 0;
bool handleRunningRequest();
ReturnValue_t handleRunningLongerRequest();
bool handleUartReception();
ReturnValue_t encodeAndSendPacket(const uint8_t* sendData, size_t sendLen);
@ -367,6 +368,8 @@ class PlocSupvHelper : public DeviceCommunicationIF,
*/
ReturnValue_t requestReceiveMessage(CookieIF* cookie, size_t requestLen) override;
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
void performUartShutdown();
};
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */