v1.17.0 #327
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
namespace supv {
|
namespace supv {
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
// The most significant bit of msec value is set to 0x80 to indicate that full
|
// 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
|
// 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
|
// 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
|
// keep the enum here in case some are added
|
||||||
enum class AdcMonServiceIds : uint8_t {};
|
enum class AdcMonServiceIds : uint8_t {};
|
||||||
|
|
||||||
enum class DataLoggerServiceIds: uint8_t {
|
enum class DataLoggerServiceIds : uint8_t { FACTORY_RESET = 0x07 };
|
||||||
FACTORY_RESET = 0x07
|
|
||||||
};
|
|
||||||
|
|
||||||
// Right now, none of the commands seem to be implemented, but still
|
// Right now, none of the commands seem to be implemented, but still
|
||||||
// keep the enum here in case some are added
|
// 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) : ploc::SpTcBase(params) {}
|
||||||
|
|
||||||
SupvTcBase(SupvTcParams params, uint16_t apid, uint16_t seqCount)
|
SupvTcBase(SupvTcParams params, uint16_t apid, uint16_t seqCount)
|
||||||
: ploc::SpTcBase(params, apid, seqCount) {
|
: ploc::SpTcBase(params, apid, seqCount) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
target_sources(
|
target_sources(
|
||||||
${OBSW_NAME}
|
${OBSW_NAME}
|
||||||
PRIVATE PlocSupervisorHandler.cpp PlocMemoryDumper.cpp PlocMPSoCHandler.cpp
|
PRIVATE PlocSupervisorHandler.cpp PlocMemoryDumper.cpp PlocMPSoCHandler.cpp
|
||||||
PlocMPSoCHelper.cpp PlocSupvHelper.cpp)
|
PlocMPSoCHelper.cpp PlocSupvUartMan.cpp)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
||||||
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
|
||||||
|
|
||||||
|
#include <linux/devices/ploc/PlocSupvUartMan.h>
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "PlocSupvHelper.h"
|
|
||||||
#include "bsp_q7s/fs/SdCardManager.h"
|
#include "bsp_q7s/fs/SdCardManager.h"
|
||||||
#include "devices/powerSwitcherList.h"
|
#include "devices/powerSwitcherList.h"
|
||||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#include "PlocSupvHelper.h"
|
|
||||||
|
|
||||||
#include <etl/crc16_ccitt.h>
|
#include <etl/crc16_ccitt.h>
|
||||||
#include <fcntl.h> // Contains file controls like O_RDWR
|
#include <fcntl.h> // Contains file controls like O_RDWR
|
||||||
#include <fsfw/filesystem/HasFileSystemIF.h>
|
#include <fsfw/filesystem/HasFileSystemIF.h>
|
||||||
#include <fsfw/tasks/SemaphoreFactory.h>
|
#include <fsfw/tasks/SemaphoreFactory.h>
|
||||||
|
#include <linux/devices/ploc/PlocSupvUartMan.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -90,36 +89,37 @@ ReturnValue_t PlocSupvHelper::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
|
ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
|
||||||
lock->lockMutex();
|
|
||||||
state = InternalState::IDLE;
|
|
||||||
lock->unlockMutex();
|
|
||||||
bool putTaskToSleep = false;
|
bool putTaskToSleep = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
semaphore->acquire();
|
semaphore->acquire();
|
||||||
while (true) {
|
while (true) {
|
||||||
putTaskToSleep = handleUartReception();
|
putTaskToSleep = handleUartReception();
|
||||||
if (putTaskToSleep) {
|
if (putTaskToSleep) {
|
||||||
|
performUartShutdown();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lock->lockMutex();
|
lock->lockMutex();
|
||||||
InternalState currentState = state;
|
InternalState currentState = state;
|
||||||
lock->unlockMutex();
|
lock->unlockMutex();
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
case InternalState::IDLE: {
|
case InternalState::SLEEPING:
|
||||||
|
case InternalState::GO_TO_SLEEP: {
|
||||||
putTaskToSleep = true;
|
putTaskToSleep = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InternalState::FINISH: {
|
case InternalState::LONGER_REQUEST: {
|
||||||
state = InternalState::IDLE;
|
if (handleRunningLongerRequest() == REQUEST_DONE) {
|
||||||
putTaskToSleep = true;
|
MutexGuard mg(lock);
|
||||||
|
state = InternalState::DEFAULT;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case InternalState::RUNNING: {
|
case InternalState::DEFAULT: {
|
||||||
putTaskToSleep = handleRunningRequest();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (putTaskToSleep) {
|
if (putTaskToSleep) {
|
||||||
|
performUartShutdown();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,10 +133,7 @@ bool PlocSupvHelper::handleUartReception() {
|
|||||||
if (bytesRead == 0) {
|
if (bytesRead == 0) {
|
||||||
{
|
{
|
||||||
MutexGuard mg(lock);
|
MutexGuard mg(lock);
|
||||||
if (state == InternalState::FINISH) {
|
if (state == InternalState::GO_TO_SLEEP) {
|
||||||
// Flush received and unread data
|
|
||||||
tcflush(serialPort, TCIOFLUSH);
|
|
||||||
state = InternalState::IDLE;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -869,23 +866,15 @@ void PlocSupvHelper::resetSpParams() { spParams.buf = commandBuffer; }
|
|||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
ReturnValue_t PlocSupvHelper::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
||||||
size_t sendLen) {
|
size_t sendLen) {
|
||||||
ReturnValue_t result;
|
|
||||||
if (sendData == nullptr or sendLen == 0) {
|
if (sendData == nullptr or sendLen == 0) {
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
lock->lockMutex();
|
lock->lockMutex();
|
||||||
if (state != InternalState::IDLE) {
|
if (state == InternalState::SLEEPING or state == InternalState::LONGER_REQUEST) {
|
||||||
lock->unlockMutex();
|
lock->unlockMutex();
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
tcflush(serialPort, TCIFLUSH);
|
|
||||||
state = InternalState::RUNNING;
|
|
||||||
lock->unlockMutex();
|
lock->unlockMutex();
|
||||||
|
|
||||||
result = semaphore->release();
|
|
||||||
if (result != OK) {
|
|
||||||
std::cout << "PlocSupvHelper::sendMessage: Releasing semaphore failed" << std::endl;
|
|
||||||
}
|
|
||||||
return encodeAndSendPacket(sendData, sendLen);
|
return encodeAndSendPacket(sendData, sendLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,7 +884,7 @@ ReturnValue_t PlocSupvHelper::requestReceiveMessage(CookieIF* cookie, size_t req
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlocSupvHelper::handleRunningRequest() {
|
ReturnValue_t PlocSupvHelper::handleRunningLongerRequest() {
|
||||||
ReturnValue_t result = OK;
|
ReturnValue_t result = OK;
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case Request::UPDATE: {
|
case Request::UPDATE: {
|
||||||
@ -907,15 +896,11 @@ bool PlocSupvHelper::handleRunningRequest() {
|
|||||||
} else {
|
} else {
|
||||||
triggerEvent(SUPV_UPDATE_FAILED, result);
|
triggerEvent(SUPV_UPDATE_FAILED, result);
|
||||||
}
|
}
|
||||||
MutexGuard mg(lock);
|
break;
|
||||||
state = InternalState::IDLE;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case Request::CHECK_MEMORY: {
|
case Request::CHECK_MEMORY: {
|
||||||
executeFullCheckMemoryCommand();
|
executeFullCheckMemoryCommand();
|
||||||
MutexGuard mg(lock);
|
break;
|
||||||
state = InternalState::IDLE;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case Request::CONTINUE_UPDATE: {
|
case Request::CONTINUE_UPDATE: {
|
||||||
result = continueUpdate();
|
result = continueUpdate();
|
||||||
@ -926,9 +911,7 @@ bool PlocSupvHelper::handleRunningRequest() {
|
|||||||
} else {
|
} else {
|
||||||
triggerEvent(SUPV_CONTINUE_UPDATE_FAILED, result);
|
triggerEvent(SUPV_CONTINUE_UPDATE_FAILED, result);
|
||||||
}
|
}
|
||||||
MutexGuard mg(lock);
|
break;
|
||||||
state = InternalState::IDLE;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case Request::REQUEST_EVENT_BUFFER: {
|
case Request::REQUEST_EVENT_BUFFER: {
|
||||||
result = performEventBufferRequest();
|
result = performEventBufferRequest();
|
||||||
@ -940,11 +923,9 @@ bool PlocSupvHelper::handleRunningRequest() {
|
|||||||
} else {
|
} else {
|
||||||
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
|
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
|
||||||
}
|
}
|
||||||
MutexGuard mg(lock);
|
break;
|
||||||
state = InternalState::IDLE;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case Request::HANDLER_DRIVEN: {
|
case Request::DEFAULT: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1037,3 +1018,8 @@ ReturnValue_t PlocSupvHelper::parseRecRingBufForHdlc(size_t& readSize) {
|
|||||||
}
|
}
|
||||||
return NO_PACKET_FOUND;
|
return NO_PACKET_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlocSupvHelper::performUartShutdown() {
|
||||||
|
tcflush(serialPort, TCIOFLUSH);
|
||||||
|
state = InternalState::GO_TO_SLEEP;
|
||||||
|
}
|
@ -158,11 +158,12 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
|||||||
static uint32_t buildProgParams1(uint8_t percent, uint16_t seqCount);
|
static uint32_t buildProgParams1(uint8_t percent, uint16_t seqCount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr ReturnValue_t NO_PACKET_FOUND = returnvalue::makeCode(1, 0);
|
static constexpr ReturnValue_t REQUEST_DONE = returnvalue::makeCode(1, 0);
|
||||||
static constexpr ReturnValue_t DECODE_BUF_TOO_SMALL = returnvalue::makeCode(1, 1);
|
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 =
|
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_START =
|
||||||
returnvalue::makeCode(1, 2);
|
returnvalue::makeCode(1, 3);
|
||||||
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_END = returnvalue::makeCode(1, 3);
|
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_END = returnvalue::makeCode(1, 4);
|
||||||
|
|
||||||
static const uint16_t CRC16_INIT = 0xFFFF;
|
static const uint16_t CRC16_INIT = 0xFFFF;
|
||||||
// Event buffer reply will carry 24 space packets with 1016 bytes and one space packet with
|
// 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;
|
EventBufferRequest eventBufferReq;
|
||||||
|
|
||||||
enum class InternalState { IDLE, RUNNING, FINISH };
|
enum class InternalState { SLEEPING, DEFAULT, LONGER_REQUEST, GO_TO_SLEEP };
|
||||||
|
|
||||||
enum class Request {
|
enum class Request {
|
||||||
HANDLER_DRIVEN,
|
DEFAULT,
|
||||||
UPDATE,
|
UPDATE,
|
||||||
CONTINUE_UPDATE,
|
CONTINUE_UPDATE,
|
||||||
REQUEST_EVENT_BUFFER,
|
REQUEST_EVENT_BUFFER,
|
||||||
CHECK_MEMORY,
|
CHECK_MEMORY,
|
||||||
};
|
};
|
||||||
InternalState state = InternalState::IDLE;
|
InternalState state = InternalState::SLEEPING;
|
||||||
Request request = Request::HANDLER_DRIVEN;
|
Request request = Request::DEFAULT;
|
||||||
|
|
||||||
#ifdef XIPHOS_Q7S
|
#ifdef XIPHOS_Q7S
|
||||||
SdCardManager* sdcMan = nullptr;
|
SdCardManager* sdcMan = nullptr;
|
||||||
@ -255,7 +256,7 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
|||||||
// Remembers APID to know at which command a procedure failed
|
// Remembers APID to know at which command a procedure failed
|
||||||
uint16_t rememberApid = 0;
|
uint16_t rememberApid = 0;
|
||||||
|
|
||||||
bool handleRunningRequest();
|
ReturnValue_t handleRunningLongerRequest();
|
||||||
bool handleUartReception();
|
bool handleUartReception();
|
||||||
|
|
||||||
ReturnValue_t encodeAndSendPacket(const uint8_t* sendData, size_t sendLen);
|
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 requestReceiveMessage(CookieIF* cookie, size_t requestLen) override;
|
||||||
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
|
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
|
||||||
|
|
||||||
|
void performUartShutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */
|
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */
|
Loading…
Reference in New Issue
Block a user