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; }
|
||||
|
||||
uint8_t getServiceId() const { return payloadStart[supv::PAYLOAD_OFFSET]; }
|
||||
uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; }
|
||||
|
||||
static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) {
|
||||
return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN;
|
||||
|
@ -138,12 +138,12 @@ void PlocSupervisorHandler::doStartUp() {
|
||||
if (setTimeDuringStartup) {
|
||||
if (startupState == StartupState::OFF) {
|
||||
bootTimeout.resetTimer();
|
||||
uartManager.start();
|
||||
startupState = StartupState::BOOTING;
|
||||
}
|
||||
if (startupState == StartupState::BOOTING) {
|
||||
if (bootTimeout.hasTimedOut()) {
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
uartManager.start();
|
||||
startupState = StartupState::SET_TIME;
|
||||
}
|
||||
}
|
||||
|
@ -101,12 +101,11 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
|
||||
lock->unlockMutex();
|
||||
semaphore->acquire();
|
||||
while (true) {
|
||||
// sif::debug << "SUPV UART MAN: Running.." << std::endl;
|
||||
putTaskToSleep = handleUartReception();
|
||||
if (putTaskToSleep) {
|
||||
performUartShutdown();
|
||||
break;
|
||||
}
|
||||
handleUartReception();
|
||||
lock->lockMutex();
|
||||
InternalState currentState = state;
|
||||
lock->unlockMutex();
|
||||
@ -126,44 +125,39 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (putTaskToSleep) {
|
||||
performUartShutdown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PlocSupvUartManager::handleUartReception() {
|
||||
ReturnValue_t PlocSupvUartManager::handleUartReception() {
|
||||
ReturnValue_t result = OK;
|
||||
ReturnValue_t status = OK;
|
||||
ssize_t bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
|
||||
static_cast<unsigned int>(recBuf.size()));
|
||||
if (bytesRead == 0) {
|
||||
{
|
||||
MutexGuard mg(lock);
|
||||
if (state == InternalState::GO_TO_SLEEP) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
while (result != NO_PACKET_FOUND) {
|
||||
result = tryHdlcParsing();
|
||||
if (result != NO_PACKET_FOUND and result != OK) {
|
||||
status = result;
|
||||
}
|
||||
}
|
||||
} else if (bytesRead < 0) {
|
||||
sif::warning << "PlocSupvHelper::performOperation: read call failed with error [" << errno
|
||||
<< ", " << strerror(errno) << "]" << std::endl;
|
||||
return true;
|
||||
return FAILED;
|
||||
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
||||
sif::error << "PlocSupvHelper::performOperation: Receive buffer too small for " << bytesRead
|
||||
<< " bytes" << std::endl;
|
||||
return FAILED;
|
||||
} else if (bytesRead > 0) {
|
||||
if (debugMode) {
|
||||
sif::info << "Received " << bytesRead << " bytes from the PLOC Supervisor:" << std::endl;
|
||||
arrayprinter::print(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,
|
||||
@ -571,23 +565,20 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
|
||||
bool ackReceived = false;
|
||||
bool packetWasHandled = false;
|
||||
while (true) {
|
||||
do {
|
||||
result = tryHdlcParsing();
|
||||
} while (result != NO_PACKET_FOUND);
|
||||
handleUartReception();
|
||||
if (not decodedQueue.empty()) {
|
||||
size_t packetLen = 0;
|
||||
decodedQueue.retrieve(&packetLen);
|
||||
decodedRingBuf.readData(decodedBuf.data(), packetLen);
|
||||
decodedRingBuf.readData(decodedBuf.data(), packetLen, true);
|
||||
tmReader.setData(decodedBuf.data(), packetLen);
|
||||
result = checkReceivedTm();
|
||||
if (result != returnvalue::OK) {
|
||||
continue;
|
||||
}
|
||||
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
|
||||
uint8_t serviceId = tmReader.getServiceId();
|
||||
int retval = 0;
|
||||
if (not ackReceived) {
|
||||
retval = handleAckReception(packet, serviceId, packetLen);
|
||||
retval = handleAckReception(packet, packetLen);
|
||||
if (retval == 1) {
|
||||
sif::debug << "ACK received" << std::endl;
|
||||
ackReceived = true;
|
||||
@ -596,7 +587,7 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
} else {
|
||||
retval = handleExeAckReception(packet, serviceId, packetLen);
|
||||
retval = handleExeAckReception(packet, packetLen);
|
||||
if (retval == 1) {
|
||||
sif::debug << "EXE ACK received" << std::endl;
|
||||
break;
|
||||
@ -619,7 +610,8 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
|
||||
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
|
||||
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::NAK)) {
|
||||
AcknowledgmentReport ackReport(tmReader);
|
||||
@ -650,8 +642,8 @@ int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, uint8_t serviceId,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, uint8_t serviceId,
|
||||
size_t packetLen) {
|
||||
int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, size_t packetLen) {
|
||||
uint8_t serviceId = tmReader.getServiceId();
|
||||
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK) or
|
||||
serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_NAK)) {
|
||||
ExecutionReport exeReport(tmReader);
|
||||
@ -660,7 +652,7 @@ int PlocSupvUartManager::handleExeAckReception(supv::TcBase& tc, uint8_t service
|
||||
triggerEvent(EXE_RECEPTION_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
if (exeReport.getRefModuleApid() == tc.getApid() and
|
||||
if (exeReport.getRefModuleApid() == tc.getModuleApid() and
|
||||
exeReport.getRefServiceId() == tc.getServiceId()) {
|
||||
if (serviceId == static_cast<uint8_t>(supv::tm::TmtcId::EXEC_ACK)) {
|
||||
return 1;
|
||||
@ -688,8 +680,7 @@ ReturnValue_t PlocSupvUartManager::checkReceivedTm() {
|
||||
triggerEvent(SUPV_REPLY_SIZE_MISSMATCH, rememberApid);
|
||||
return result;
|
||||
}
|
||||
result = tmReader.checkCrc();
|
||||
if (result != returnvalue::OK) {
|
||||
if (not tmReader.verifyCrc()) {
|
||||
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
|
||||
return result;
|
||||
}
|
||||
@ -745,12 +736,12 @@ ReturnValue_t PlocSupvUartManager::calcImageCrc() {
|
||||
ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
resetSpParams();
|
||||
supv::CheckMemory packet(spParams);
|
||||
result = packet.buildPacket(update.memoryId, update.startAddress, update.fullFileSize);
|
||||
supv::CheckMemory tcPacket(spParams);
|
||||
result = tcPacket.buildPacket(update.memoryId, update.startAddress, update.fullFileSize);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = encodeAndSendPacket(packet.getFullPacket(), packet.getFullPacketLen());
|
||||
result = encodeAndSendPacket(tcPacket.getFullPacket(), tcPacket.getFullPacketLen());
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
@ -760,14 +751,11 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
||||
bool packetWasHandled = false;
|
||||
bool exeReceived = false;
|
||||
while (true) {
|
||||
do {
|
||||
result = tryHdlcParsing();
|
||||
|
||||
} while (result != NO_PACKET_FOUND);
|
||||
handleUartReception();
|
||||
if (not decodedQueue.empty()) {
|
||||
size_t packetLen = 0;
|
||||
decodedQueue.retrieve(&packetLen);
|
||||
decodedRingBuf.readData(decodedBuf.data(), packetLen);
|
||||
decodedRingBuf.readData(decodedBuf.data(), packetLen, true);
|
||||
tmReader.setData(decodedBuf.data(), packetLen);
|
||||
result = checkReceivedTm();
|
||||
if (result != returnvalue::OK) {
|
||||
@ -775,10 +763,9 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
||||
}
|
||||
packetWasHandled = false;
|
||||
if (tmReader.getModuleApid() == Apid::TMTC_MAN) {
|
||||
uint8_t serviceId = tmReader.getServiceId();
|
||||
int retval = 0;
|
||||
if (not ackReceived) {
|
||||
retval = handleAckReception(packet, serviceId, packetLen);
|
||||
retval = handleAckReception(tcPacket, packetLen);
|
||||
if (retval == 1) {
|
||||
packetWasHandled = true;
|
||||
ackReceived = true;
|
||||
@ -786,7 +773,7 @@ ReturnValue_t PlocSupvUartManager::handleCheckMemoryCommand() {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
} else {
|
||||
retval = handleExeAckReception(packet, serviceId, packetLen);
|
||||
retval = handleExeAckReception(tcPacket, packetLen);
|
||||
if (retval == 1) {
|
||||
packetWasHandled = true;
|
||||
exeReceived = true;
|
||||
|
@ -252,14 +252,14 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
|
||||
|
||||
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
|
||||
|
||||
bool debugMode = false;
|
||||
bool debugMode = true;
|
||||
bool timestamping = true;
|
||||
|
||||
// Remembers APID to know at which command a procedure failed
|
||||
uint16_t rememberApid = 0;
|
||||
|
||||
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);
|
||||
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 handlePacketTransmissionNoReply(supv::TcBase& packet,
|
||||
uint32_t timeoutExecutionReport = 60000);
|
||||
int handleAckReception(supv::TcBase& tc, uint8_t serviceId, size_t packetLen);
|
||||
int handleExeAckReception(supv::TcBase& tc, uint8_t serviceId, size_t packetLen);
|
||||
int handleAckReception(supv::TcBase& tc, size_t packetLen);
|
||||
int handleExeAckReception(supv::TcBase& tc, size_t packetLen);
|
||||
|
||||
/**
|
||||
* @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::SEND_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
|
||||
|
||||
#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::SEND_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
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ class SpTcBase {
|
||||
void updateLenFromParams() { spParams.creator.setDataLenField(spParams.fullPayloadLen - 1); }
|
||||
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(); }
|
||||
|
||||
uint16_t getApid() const { return spParams.creator.getApid(); }
|
||||
|
Loading…
Reference in New Issue
Block a user