PLOC SUPV Update to newer firmware #316

Merged
muellerr merged 99 commits from mueller/tas_ploc_supv_update into develop 2022-11-18 14:27:13 +01:00
5 changed files with 66 additions and 81 deletions
Showing only changes of commit 32865d1834 - Show all commits

View File

@ -15,21 +15,20 @@
namespace supv {
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
// significant bit is set to 0x00. Only the most significant bit is used for
// this purpose (bit 15 of the field tm_msec)
uint16_t tm_msec; // miliseconds 0-999;
uint8_t tm_sec; // seconds after the minute, 0 to 60
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
// significant bit is set to 0x00. Only the most significant bit is used for
// this purpose (bit 15 of the field tm_msec)
uint16_t tm_msec; // miliseconds 0-999;
uint8_t tm_sec; // seconds after the minute, 0 to 60
// (0 - 60 allows for the occasional leap second)
uint8_t tm_min; // minutes after the hour, 0 to 59
uint8_t tm_hour; // hours since midnight, 0 to 23
uint8_t tm_mday; // day of the month, 1 to 31
uint8_t tm_mon; // months 1 to 12
uint8_t tm_year; // years since 1900
uint8_t tm_min; // minutes after the hour, 0 to 59
uint8_t tm_hour; // hours since midnight, 0 to 23
uint8_t tm_mday; // day of the month, 1 to 31
uint8_t tm_mon; // months 1 to 12
uint8_t tm_year; // years since 1900
} tas_time_t;
/** Command IDs */
@ -130,23 +129,23 @@ static constexpr uint16_t APID_MEM_MAN = 0x05;
static constexpr uint16_t APID_DATA_LOGGER = 0x06;
static constexpr uint16_t APID_WDOG_MAN = 0x07;
enum class HkServiceIds: uint8_t {
enum class HkServiceIds : uint8_t {
ENABLE = 0x01,
SET_PERIOD = 0x02,
GET_REPORT = 0x03,
GET_HARDFAULTS_REPORT = 0x04,
};
enum class TmtcServiceIds: uint8_t {
TIME_REF = 0x03,
GET_SUPV_VERSION = 0x05,
RUN_AUTO_EM_TEST = 0x08,
SET_GPIO = 0x0E,
READ_GPIO = 0x0F,
GET_MPSOC_POWER_INFO = 0x10
enum class TmtcServiceIds : uint8_t {
TIME_REF = 0x03,
GET_SUPV_VERSION = 0x05,
RUN_AUTO_EM_TEST = 0x08,
SET_GPIO = 0x0E,
READ_GPIO = 0x0F,
GET_MPSOC_POWER_INFO = 0x10
};
enum class BootManServiceIds: uint8_t {
enum class BootManServiceIds : uint8_t {
START_MPSOC = 0x01,
SHUTDOWN_MPSOC = 0x02,
SELECT_IMAGE = 0x03,
@ -160,7 +159,7 @@ enum class BootManServiceIds: uint8_t {
FACTORY_FLASH = 0x0C
};
enum class LatchupMonServiceIds: uint8_t {
enum class LatchupMonServiceIds : uint8_t {
ENABLE = 0x01,
DISABLE = 0x02,
SET_ALERT_LIMIT = 0x04,
@ -169,15 +168,13 @@ enum class LatchupMonServiceIds: uint8_t {
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
enum class AdcMonServiceIds: uint8_t {};
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
enum class WdogManServiceIds: uint8_t {};
enum class WdogManServiceIds : uint8_t {};
static const uint16_t APID_START_MPSOC = 0xA1;
static const uint16_t APID_SHUTWOWN_MPSOC = 0xA2;
@ -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_ */