various improvements and bugfixes
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
f545928adc
commit
98fcf06e31
@ -501,7 +501,7 @@ class TcBase : public ploc::SpTcBase {
|
|||||||
|
|
||||||
uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; }
|
uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; }
|
||||||
|
|
||||||
uint8_t getServiceId() const { return payloadStart[supv::PAYLOAD_OFFSET]; }
|
uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; }
|
||||||
|
|
||||||
static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) {
|
static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) {
|
||||||
return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN;
|
return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN;
|
||||||
|
@ -138,12 +138,12 @@ void PlocSupervisorHandler::doStartUp() {
|
|||||||
if (setTimeDuringStartup) {
|
if (setTimeDuringStartup) {
|
||||||
if (startupState == StartupState::OFF) {
|
if (startupState == StartupState::OFF) {
|
||||||
bootTimeout.resetTimer();
|
bootTimeout.resetTimer();
|
||||||
uartManager.start();
|
|
||||||
startupState = StartupState::BOOTING;
|
startupState = StartupState::BOOTING;
|
||||||
}
|
}
|
||||||
if (startupState == StartupState::BOOTING) {
|
if (startupState == StartupState::BOOTING) {
|
||||||
if (bootTimeout.hasTimedOut()) {
|
if (bootTimeout.hasTimedOut()) {
|
||||||
uartIsolatorSwitch.pullHigh();
|
uartIsolatorSwitch.pullHigh();
|
||||||
|
uartManager.start();
|
||||||
startupState = StartupState::SET_TIME;
|
startupState = StartupState::SET_TIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,12 +101,11 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
|
|||||||
lock->unlockMutex();
|
lock->unlockMutex();
|
||||||
semaphore->acquire();
|
semaphore->acquire();
|
||||||
while (true) {
|
while (true) {
|
||||||
// sif::debug << "SUPV UART MAN: Running.." << std::endl;
|
|
||||||
putTaskToSleep = handleUartReception();
|
|
||||||
if (putTaskToSleep) {
|
if (putTaskToSleep) {
|
||||||
performUartShutdown();
|
performUartShutdown();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
handleUartReception();
|
||||||
lock->lockMutex();
|
lock->lockMutex();
|
||||||
InternalState currentState = state;
|
InternalState currentState = state;
|
||||||
lock->unlockMutex();
|
lock->unlockMutex();
|
||||||
@ -126,44 +125,39 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (putTaskToSleep) {
|
|
||||||
performUartShutdown();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlocSupvUartManager::handleUartReception() {
|
ReturnValue_t PlocSupvUartManager::handleUartReception() {
|
||||||
ReturnValue_t result = OK;
|
ReturnValue_t result = OK;
|
||||||
|
ReturnValue_t status = OK;
|
||||||
ssize_t bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
|
ssize_t bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
|
||||||
static_cast<unsigned int>(recBuf.size()));
|
static_cast<unsigned int>(recBuf.size()));
|
||||||
if (bytesRead == 0) {
|
if (bytesRead == 0) {
|
||||||
{
|
|
||||||
MutexGuard mg(lock);
|
|
||||||
if (state == InternalState::GO_TO_SLEEP) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (result != NO_PACKET_FOUND) {
|
while (result != NO_PACKET_FOUND) {
|
||||||
result = tryHdlcParsing();
|
result = tryHdlcParsing();
|
||||||
|
if (result != NO_PACKET_FOUND and result != OK) {
|
||||||
|
status = result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (bytesRead < 0) {
|
} else if (bytesRead < 0) {
|
||||||
sif::warning << "PlocSupvHelper::performOperation: read call failed with error [" << errno
|
sif::warning << "PlocSupvHelper::performOperation: read call failed with error [" << errno
|
||||||
<< ", " << strerror(errno) << "]" << std::endl;
|
<< ", " << strerror(errno) << "]" << std::endl;
|
||||||
return true;
|
return FAILED;
|
||||||
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
||||||
sif::error << "PlocSupvHelper::performOperation: Receive buffer too small for " << bytesRead
|
sif::error << "PlocSupvHelper::performOperation: Receive buffer too small for " << bytesRead
|
||||||
<< " bytes" << std::endl;
|
<< " bytes" << std::endl;
|
||||||
|
return FAILED;
|
||||||
} else if (bytesRead > 0) {
|
} else if (bytesRead > 0) {
|
||||||
if (debugMode) {
|
if (debugMode) {
|
||||||
sif::info << "Received " << bytesRead << " bytes from the PLOC Supervisor:" << std::endl;
|
sif::info << "Received " << bytesRead << " bytes from the PLOC Supervisor:" << std::endl;
|
||||||
arrayprinter::print(recBuf.data(), bytesRead);
|
arrayprinter::print(recBuf.data(), bytesRead);
|
||||||
}
|
}
|
||||||
recRingBuf.writeData(recBuf.data(), bytesRead);
|
recRingBuf.writeData(recBuf.data(), bytesRead);
|
||||||
tryHdlcParsing();
|
status = tryHdlcParsing();
|
||||||
}
|
}
|
||||||
return false;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocSupvUartManager::startUpdate(std::string file, uint8_t memoryId,
|
ReturnValue_t PlocSupvUartManager::startUpdate(std::string file, uint8_t memoryId,
|
||||||
@ -571,23 +565,20 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
|
|||||||
bool ackReceived = false;
|
bool ackReceived = false;
|
||||||
bool packetWasHandled = false;
|
bool packetWasHandled = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
do {
|
handleUartReception();
|
||||||
result = tryHdlcParsing();
|
|
||||||
} while (result != NO_PACKET_FOUND);
|
|
||||||
if (not decodedQueue.empty()) {
|
if (not decodedQueue.empty()) {
|
||||||
size_t packetLen = 0;
|
size_t packetLen = 0;
|
||||||
decodedQueue.retrieve(&packetLen);
|
decodedQueue.retrieve(&packetLen);
|
||||||
decodedRingBuf.readData(decodedBuf.data(), packetLen);
|
decodedRingBuf.readData(decodedBuf.data(), packetLen, true);
|
||||||
tmReader.setData(decodedBuf.data(), packetLen);
|
tmReader.setData(decodedBuf.data(), packetLen);
|
||||||
result = checkReceivedTm();
|
result = checkReceivedTm();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
|
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
|
||||||
uint8_t serviceId = tmReader.getServiceId();
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
if (not ackReceived) {
|
if (not ackReceived) {
|
||||||
retval = handleAckReception(packet, serviceId, packetLen);
|
retval = handleAckReception(packet, packetLen);
|
||||||
if (retval == 1) {
|
if (retval == 1) {
|
||||||
sif::debug << "ACK received" << std::endl;
|
sif::debug << "ACK received" << std::endl;
|
||||||
ackReceived = true;
|
ackReceived = true;
|
||||||
@ -596,7 +587,7 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
retval = handleExeAckReception(packet, serviceId, packetLen);
|
retval = handleExeAckReception(packet, packetLen);
|
||||||
if (retval == 1) {
|
if (retval == 1) {
|
||||||
sif::debug << "EXE ACK received" << std::endl;
|
sif::debug << "EXE ACK received" << std::endl;
|
||||||
break;
|
break;
|
||||||
@ -619,7 +610,8 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, uint8_t serviceId, size_t packetLen) {
|
int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, size_t packetLen) {
|
||||||
|
uint8_t serviceId = tmReader.getServiceId();
|
||||||
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::ACK) or
|
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::ACK) or
|
||||||
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
|
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
|
||||||
AcknowledgmentReport ackReport(tmReader);
|
AcknowledgmentReport ackReport(tmReader);
|
||||||
@ -650,8 +642,8 @@ int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, uint8_t serviceId,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, uint8_t serviceId,
|
int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, size_t packetLen) {
|
||||||
size_t packetLen) {
|
uint8_t serviceId = tmReader.getServiceId();
|
||||||
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK) or
|
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK) or
|
||||||
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) {
|
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) {
|
||||||
ExecutionReport exeReport(tmReader);
|
ExecutionReport exeReport(tmReader);
|
||||||
@ -660,7 +652,7 @@ int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, uint8_t service
|
|||||||
triggerEvent(EXE_RECEPTION_FAILURE);
|
triggerEvent(EXE_RECEPTION_FAILURE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (exeReport.getRefModuleApid() == tc.getApid() and
|
if (exeReport.getRefModuleApid() == tc.getModuleApid() and
|
||||||
exeReport.getRefServiceId() == tc.getServiceId()) {
|
exeReport.getRefServiceId() == tc.getServiceId()) {
|
||||||
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) {
|
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -688,8 +680,7 @@ ReturnValue_t PlocSupvUartManager::checkReceivedTm() {
|
|||||||
triggerEvent(SUPV_REPLY_SIZE_MISSMATCH, rememberApid);
|
triggerEvent(SUPV_REPLY_SIZE_MISSMATCH, rememberApid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = tmReader.checkCrc();
|
if (not tmReader.verifyCrc()) {
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
|
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -745,12 +736,12 @@ ReturnValue_t PlocSupvUartManager::calcImageCrc() {
|
|||||||
ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
resetSpParams();
|
resetSpParams();
|
||||||
supv::CheckMemory packet(spParams);
|
supv::CheckMemory tcPacket(spParams);
|
||||||
result = packet.buildPacket(update.memoryId, update.startAddress, update.fullFileSize);
|
result = tcPacket.buildPacket(update.memoryId, update.startAddress, update.fullFileSize);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = encodeAndSendPacket(packet.getFullPacket(), packet.getFullPacketLen());
|
result = encodeAndSendPacket(tcPacket.getFullPacket(), tcPacket.getFullPacketLen());
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -760,14 +751,11 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
|||||||
bool packetWasHandled = false;
|
bool packetWasHandled = false;
|
||||||
bool exeReceived = false;
|
bool exeReceived = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
do {
|
handleUartReception();
|
||||||
result = tryHdlcParsing();
|
|
||||||
|
|
||||||
} while (result != NO_PACKET_FOUND);
|
|
||||||
if (not decodedQueue.empty()) {
|
if (not decodedQueue.empty()) {
|
||||||
size_t packetLen = 0;
|
size_t packetLen = 0;
|
||||||
decodedQueue.retrieve(&packetLen);
|
decodedQueue.retrieve(&packetLen);
|
||||||
decodedRingBuf.readData(decodedBuf.data(), packetLen);
|
decodedRingBuf.readData(decodedBuf.data(), packetLen, true);
|
||||||
tmReader.setData(decodedBuf.data(), packetLen);
|
tmReader.setData(decodedBuf.data(), packetLen);
|
||||||
result = checkReceivedTm();
|
result = checkReceivedTm();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
@ -775,10 +763,9 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
|||||||
}
|
}
|
||||||
packetWasHandled = false;
|
packetWasHandled = false;
|
||||||
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
|
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
|
||||||
uint8_t serviceId = tmReader.getServiceId();
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
if (not ackReceived) {
|
if (not ackReceived) {
|
||||||
retval = handleAckReception(packet, serviceId, packetLen);
|
retval = handleAckReception(tcPacket, packetLen);
|
||||||
if (retval == 1) {
|
if (retval == 1) {
|
||||||
packetWasHandled = true;
|
packetWasHandled = true;
|
||||||
ackReceived = true;
|
ackReceived = true;
|
||||||
@ -786,7 +773,7 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
retval = handleExeAckReception(packet, serviceId, packetLen);
|
retval = handleExeAckReception(tcPacket, packetLen);
|
||||||
if (retval == 1) {
|
if (retval == 1) {
|
||||||
packetWasHandled = true;
|
packetWasHandled = true;
|
||||||
exeReceived = true;
|
exeReceived = true;
|
||||||
|
@ -252,14 +252,14 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
|
|||||||
|
|
||||||
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
|
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
|
||||||
|
|
||||||
bool debugMode = false;
|
bool debugMode = true;
|
||||||
bool timestamping = true;
|
bool timestamping = true;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
ReturnValue_t handleRunningLongerRequest();
|
ReturnValue_t handleRunningLongerRequest();
|
||||||
bool handleUartReception();
|
ReturnValue_t handleUartReception();
|
||||||
void addHdlcFraming(const uint8_t* src, size_t slen, uint8_t* dst, size_t* dlen, size_t maxDest);
|
void addHdlcFraming(const uint8_t* src, size_t slen, uint8_t* dst, size_t* dlen, size_t maxDest);
|
||||||
int removeHdlcFramingWithCrcCheck(const uint8_t* src, size_t slen, uint8_t* dst, size_t* dlen);
|
int removeHdlcFramingWithCrcCheck(const uint8_t* src, size_t slen, uint8_t* dst, size_t* dlen);
|
||||||
|
|
||||||
@ -275,8 +275,8 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
|
|||||||
// ReturnValue_t performEventBufferRequest();
|
// ReturnValue_t performEventBufferRequest();
|
||||||
ReturnValue_t handlePacketTransmissionNoReply(supv::TcBase& packet,
|
ReturnValue_t handlePacketTransmissionNoReply(supv::TcBase& packet,
|
||||||
uint32_t timeoutExecutionReport = 60000);
|
uint32_t timeoutExecutionReport = 60000);
|
||||||
int handleAckReception(supv::TcBase& tc, uint8_t serviceId, size_t packetLen);
|
int handleAckReception(supv::TcBase& tc, size_t packetLen);
|
||||||
int handleExeAckReception(supv::TcBase& tc, uint8_t serviceId, size_t packetLen);
|
int handleExeAckReception(supv::TcBase& tc, size_t packetLen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handles reading of TM packets from the communication interface
|
* @brief Handles reading of TM packets from the communication interface
|
||||||
|
@ -54,6 +54,8 @@ void scheduling::addMpsocSupvHandlers(PeriodicTaskIF* plTask) {
|
|||||||
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::GET_WRITE);
|
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::GET_WRITE);
|
||||||
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::SEND_READ);
|
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::SEND_READ);
|
||||||
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::GET_READ);
|
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::GET_READ);
|
||||||
|
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::SEND_READ);
|
||||||
|
plTask->addComponent(objects::PLOC_SUPERVISOR_HANDLER, DeviceHandlerIF::GET_READ);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if OBSW_ADD_PLOC_MPSOC == 1
|
#if OBSW_ADD_PLOC_MPSOC == 1
|
||||||
@ -62,5 +64,7 @@ void scheduling::addMpsocSupvHandlers(PeriodicTaskIF* plTask) {
|
|||||||
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_WRITE);
|
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_WRITE);
|
||||||
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::SEND_READ);
|
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::SEND_READ);
|
||||||
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_READ);
|
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_READ);
|
||||||
|
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::SEND_READ);
|
||||||
|
plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_READ);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ class SpTcBase {
|
|||||||
void updateLenFromParams() { spParams.creator.setDataLenField(spParams.fullPayloadLen - 1); }
|
void updateLenFromParams() { spParams.creator.setDataLenField(spParams.fullPayloadLen - 1); }
|
||||||
const uint8_t* getFullPacket() const { return spParams.buf; }
|
const uint8_t* getFullPacket() const { return spParams.buf; }
|
||||||
|
|
||||||
|
const uint8_t* getPacketData() const { return spParams.buf + ccsds::HEADER_LEN; }
|
||||||
|
|
||||||
size_t getFullPacketLen() const { return spParams.creator.getFullPacketLen(); }
|
size_t getFullPacketLen() const { return spParams.creator.getFullPacketLen(); }
|
||||||
|
|
||||||
uint16_t getApid() const { return spParams.creator.getApid(); }
|
uint16_t getApid() const { return spParams.creator.getApid(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user