a lot of bugfixes
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Robin Müller 2022-11-16 13:26:49 +01:00
parent 32005a2d3a
commit 3510cc85fc
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 28 additions and 25 deletions

View File

@ -1,6 +1,7 @@
#include "PlocSupervisorHandler.h" #include "PlocSupervisorHandler.h"
#include <fsfw/filesystem/HasFileSystemIF.h> #include <fsfw/filesystem/HasFileSystemIF.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
@ -586,6 +587,8 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
// } // }
tmReader.setData(start, remainingSize); tmReader.setData(start, remainingSize);
sif::debug << "PlocSupervisorHandler::scanForReply: Received Packet" << std::endl;
arrayprinter::print(start, remainingSize);
uint16_t apid = tmReader.getApid(); //(*(start) << 8 | *(start + 1)) & APID_MASK; uint16_t apid = tmReader.getApid(); //(*(start) << 8 | *(start + 1)) & APID_MASK;
switch (apid) { switch (apid) {
@ -1915,13 +1918,13 @@ void PlocSupervisorHandler::handleBadApidServiceCombination(Event event, unsigne
unsigned int serviceId) { unsigned int serviceId) {
const char* printString = ""; const char* printString = "";
if (event == SUPV_UNKNOWN_TM) { if (event == SUPV_UNKNOWN_TM) {
printString = "Unknown"; printString = "PlocSupervisorHandler: Unknown";
} else if (event == SUPV_UNINIMPLEMENTED_TM) { } else if (event == SUPV_UNINIMPLEMENTED_TM) {
printString = "Unimplemented"; printString = "PlocSupervisorHandler: Unimplemented";
} }
triggerEvent(event, apid, tmReader.getServiceId()); triggerEvent(event, apid, tmReader.getServiceId());
sif::error << printString << " APID service combination 0x" << std::setw(2) << std::setfill('0') sif::warning << printString << " APID service combination 0x" << std::setw(2) << std::setfill('0')
<< std::hex << apid << ", " << std::setw(2) << serviceId << std::endl; << std::hex << apid << ", 0x" << std::setw(2) << serviceId << std::endl;
} }
void PlocSupervisorHandler::printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId) { void PlocSupervisorHandler::printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId) {

View File

@ -1,10 +1,9 @@
#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/globalfunctions/arrayprinter.h>
#include <fsfw/tasks/SemaphoreFactory.h> #include <fsfw/tasks/SemaphoreFactory.h>
#include <linux/devices/ploc/PlocSupvUartMan.h> #include <linux/devices/ploc/PlocSupvUartMan.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <unistd.h> #include <unistd.h>
#include <cmath> #include <cmath>
@ -293,7 +292,7 @@ ReturnValue_t PlocSupvUartManager::initiateUpdateContinuation() {
void PlocSupvUartManager::stop() { void PlocSupvUartManager::stop() {
MutexGuard mg(lock); MutexGuard mg(lock);
if(state == InternalState::SLEEPING or state == InternalState::GO_TO_SLEEP) { if (state == InternalState::SLEEPING or state == InternalState::GO_TO_SLEEP) {
return; return;
} }
state = InternalState::GO_TO_SLEEP; state = InternalState::GO_TO_SLEEP;
@ -1001,16 +1000,17 @@ ReturnValue_t PlocSupvUartManager::readReceivedMessage(CookieIF* cookie, uint8_t
ReturnValue_t PlocSupvUartManager::tryHdlcParsing() { ReturnValue_t PlocSupvUartManager::tryHdlcParsing() {
size_t bytesRead = 0; size_t bytesRead = 0;
ReturnValue_t result = parseRecRingBufForHdlc(bytesRead); size_t decodedLen = 0;
ReturnValue_t result = parseRecRingBufForHdlc(bytesRead, decodedLen);
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
// Packet found, advance read pointer. // Packet found, advance read pointer.
if (state == InternalState::DEDICATED_REQUEST) { if (state == InternalState::DEDICATED_REQUEST) {
decodedRingBuf.writeData(decodedBuf.data(), bytesRead); decodedRingBuf.writeData(decodedBuf.data(), decodedLen);
decodedQueue.insert(bytesRead); decodedQueue.insert(decodedLen);
} else { } else {
MutexGuard mg(ipcLock); MutexGuard mg(ipcLock);
ipcRingBuf.writeData(decodedBuf.data(), bytesRead); ipcRingBuf.writeData(decodedBuf.data(), decodedLen);
ipcQueue.insert(bytesRead); ipcQueue.insert(decodedLen);
} }
recRingBuf.deleteData(bytesRead); recRingBuf.deleteData(bytesRead);
} else if (result != NO_PACKET_FOUND) { } else if (result != NO_PACKET_FOUND) {
@ -1023,7 +1023,7 @@ ReturnValue_t PlocSupvUartManager::tryHdlcParsing() {
return result; return result;
} }
ReturnValue_t PlocSupvUartManager::parseRecRingBufForHdlc(size_t& readSize) { ReturnValue_t PlocSupvUartManager::parseRecRingBufForHdlc(size_t& readSize, size_t& decodedLen) {
size_t availableData = recRingBuf.getAvailableReadData(); size_t availableData = recRingBuf.getAvailableReadData();
if (availableData == 0) { if (availableData == 0) {
return NO_PACKET_FOUND; return NO_PACKET_FOUND;
@ -1037,7 +1037,6 @@ ReturnValue_t PlocSupvUartManager::parseRecRingBufForHdlc(size_t& readSize) {
} }
bool startMarkerFound = false; bool startMarkerFound = false;
size_t startIdx = 0; size_t startIdx = 0;
return returnvalue::OK;
for (size_t idx = 0; idx < availableData; idx++) { for (size_t idx = 0; idx < availableData; idx++) {
// handle start marker // handle start marker
if (encodedBuf[idx] == HDLC_START_MARKER) { if (encodedBuf[idx] == HDLC_START_MARKER) {
@ -1052,9 +1051,9 @@ ReturnValue_t PlocSupvUartManager::parseRecRingBufForHdlc(size_t& readSize) {
if (encodedBuf[idx] == HDLC_END_MARKER) { if (encodedBuf[idx] == HDLC_END_MARKER) {
if (startMarkerFound) { if (startMarkerFound) {
// Probably a packet, so decode it // Probably a packet, so decode it
size_t decodedLen = 0; hdlc_remove_framing(encodedBuf.data() + startIdx, idx + 1 - startIdx, decodedBuf.data(),
hdlc_remove_framing(encodedBuf.data() + startIdx, idx + 1, decodedBuf.data(), &decodedLen); &decodedLen);
readSize = decodedLen; readSize = idx + 1;
return returnvalue::OK; return returnvalue::OK;
} else { } else {
readSize = ++idx; readSize = ++idx;

View File

@ -177,8 +177,8 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
static const uint32_t PREPARE_UPDATE_EXECUTION_REPORT = 2000; static const uint32_t PREPARE_UPDATE_EXECUTION_REPORT = 2000;
static constexpr uint8_t MAX_STORED_DECODED_PACKETS = 4; static constexpr uint8_t MAX_STORED_DECODED_PACKETS = 4;
static constexpr uint8_t HDLC_START_MARKER = 0x7C; static constexpr uint8_t HDLC_START_MARKER = 0x7E;
static constexpr uint8_t HDLC_END_MARKER = 0x7E; static constexpr uint8_t HDLC_END_MARKER = 0x7C;
struct Update { struct Update {
uint8_t memoryId; uint8_t memoryId;
@ -261,7 +261,7 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
void executeFullCheckMemoryCommand(); void executeFullCheckMemoryCommand();
ReturnValue_t tryHdlcParsing(); ReturnValue_t tryHdlcParsing();
ReturnValue_t parseRecRingBufForHdlc(size_t& readSize); ReturnValue_t parseRecRingBufForHdlc(size_t& readSize, size_t& decodedLen);
ReturnValue_t executeUpdate(); ReturnValue_t executeUpdate();
ReturnValue_t continueUpdate(); ReturnValue_t continueUpdate();
ReturnValue_t updateOperation(); ReturnValue_t updateOperation();

View File

@ -55,15 +55,15 @@ void hdlc_add_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dle
*dlen = tlen; *dlen = tlen;
} }
void hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen) int hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen)
{ {
uint16_t tlen = 0; uint16_t tlen = 0;
uint16_t ii; uint16_t ii;
uint8_t bt; uint8_t bt;
*dlen = 0; *dlen = 0;
if (slen == 0) return; if (slen == 0) return -1;
if ((src[tlen] != 0x7E) && (src[slen-1] != 0x7C)) return; if ((src[tlen] != 0x7E) && (src[slen-1] != 0x7C)) return -1;
for (ii = 1; ii < slen-1; ii++) for (ii = 1; ii < slen-1; ii++)
{ {
bt = *src++; bt = *src++;
@ -75,6 +75,7 @@ void hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *
dst[tlen++] = bt; dst[tlen++] = bt;
} }
*dlen = tlen; *dlen = tlen;
return 0;
} }

View File

@ -28,7 +28,7 @@ extern "C" {
void hdlc_add_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen); void hdlc_add_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen);
void hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen); int hdlc_remove_framing(const uint8_t *src, size_t slen, uint8_t *dst, size_t *dlen);
#ifdef __cplusplus #ifdef __cplusplus
} }