From df712c71000fa129a95bd2a6311a78a8109713e3 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 25 Mar 2022 17:48:38 +0100 Subject: [PATCH 01/48] scex reader task started --- bsp_linux_board/InitMission.cpp | 8 ++++++++ bsp_linux_board/ObjectFactory.cpp | 2 ++ linux/boardtest/UartTestClass.cpp | 1 + linux/devices/CMakeLists.txt | 3 +++ linux/devices/ScexUartReader.cpp | 18 ++++++++++++++++++ linux/devices/ScexUartReader.h | 18 ++++++++++++++++++ linux/fsfwconfig/objects/systemObjectList.h | 2 ++ 7 files changed, 52 insertions(+) create mode 100644 linux/devices/ScexUartReader.cpp create mode 100644 linux/devices/ScexUartReader.h diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 6dfe3af1..0a242209 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -228,7 +228,15 @@ void initmission::createTestTasks(TaskFactory& factory, if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("UART_TEST", objects::UART_TEST); } + PeriodicTaskIF* scexReaderTask = factory.createPeriodicTask( + "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = scexReaderTask->addComponent(objects::SCEX_UART_READER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); + } + #endif /* RPI_ADD_GPIO_TEST == 1 */ + taskVec.push_back(scexReaderTask); taskVec.push_back(testTask); bool startTestPst = true; diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 18da8896..7df6b116 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,3 +1,4 @@ +#include #include "ObjectFactory.h" #include "OBSWConfig.h" @@ -182,6 +183,7 @@ void ObjectFactory::createTestTasks() { #endif #if OBSW_ADD_UART_TEST_CODE == 1 + new ScexUartReader(objects::SCEX_UART_READER); new UartTestClass(objects::UART_TEST); #else new UartComIF(objects::UART_COM_IF); diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 9c51ed8a..bfa735e9 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -197,6 +197,7 @@ void UartTestClass::scexPeriodic() { sif::info << "Received " << bytesRead << " bytes from the Solar Cell Experiment:" << std::endl; arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); + break; } } while (bytesRead > 0); } diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 7d39837d..1130e7cd 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -4,4 +4,7 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER) ) endif() +target_sources(${OBSW_NAME} PRIVATE + ScexUartReader.cpp +) add_subdirectory(startracker) diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp new file mode 100644 index 00000000..4aa78357 --- /dev/null +++ b/linux/devices/ScexUartReader.cpp @@ -0,0 +1,18 @@ +#include "ScexUartReader.h" +#include + + +ScexUartReader::ScexUartReader(object_id_t objectId):SystemObject(objectId) { +} + +void ScexUartRead::start() { + semaphore->give(); +} +ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { + std::cout<<"hallo welt"<take(); + while(true) { + semaphore->take(); + } + return RETURN_OK; +} diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h new file mode 100644 index 00000000..70eafcf7 --- /dev/null +++ b/linux/devices/ScexUartReader.h @@ -0,0 +1,18 @@ +#ifndef LINUX_DEVICES_SCEXUARTREADER_H_ +#define LINUX_DEVICES_SCEXUARTREADER_H_ +#include +#include + + +class ScexUartReader: public SystemObject, //strg+shift+n +public ExecutableObjectIF, +public HasReturnvaluesIF { +public: + ScexUartReader(object_id_t objectId); +private: + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + +}; + + +#endif /* LINUX_DEVICES_SCEXUARTREADER_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index a03e4d38..5fbc99d5 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -49,6 +49,7 @@ enum sourceObjects : uint32_t { UART_COM_IF = 0x49030003, SPI_COM_IF = 0x49020004, GPIO_IF = 0x49010005, + SCEX_UART_READER = 0x49010006, /* Custom device handler */ PCDU_HANDLER = 0x442000A1, @@ -57,6 +58,7 @@ enum sourceObjects : uint32_t { HEATER_HANDLER = 0x444100A4, RAD_SENSOR = 0x443200A5, + /* 0x54 ('T') for test handlers */ TEST_TASK = 0x54694269, LIBGPIOD_TEST = 0x54123456, -- 2.43.0 From 35f2d2cb9cb5c6df84ca782c5d86c44c4c1fd004 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 8 Apr 2022 15:25:07 +0200 Subject: [PATCH 02/48] solve merge comflioct --- linux/devices/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index b88d59fc..b8568560 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -4,11 +4,8 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER) ) endif() -<<<<<<< HEAD target_sources(${OBSW_NAME} PRIVATE ScexUartReader.cpp ) -======= add_subdirectory(ploc) ->>>>>>> origin/develop add_subdirectory(startracker) -- 2.43.0 From 01d86a0c7b9e0e3dc8f1d63642d3860d45332662 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 8 Apr 2022 19:12:21 +0200 Subject: [PATCH 03/48] huge progress --- bsp_linux_board/InitMission.cpp | 13 +- bsp_linux_board/ObjectFactory.cpp | 7 +- linux/boardtest/UartTestClass.cpp | 183 ++++++++++++-------- linux/boardtest/UartTestClass.h | 11 +- linux/devices/ScexUartReader.cpp | 176 +++++++++++++++++-- linux/devices/ScexUartReader.h | 53 +++++- linux/fsfwconfig/objects/systemObjectList.h | 1 - 7 files changed, 339 insertions(+), 105 deletions(-) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 7814b61d..f634e8d6 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -229,14 +229,13 @@ void initmission::createTestTasks(TaskFactory& factory, initmission::printAddObjectError("UART_TEST", objects::UART_TEST); } PeriodicTaskIF* scexReaderTask = factory.createPeriodicTask( - "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = scexReaderTask->addComponent(objects::SCEX_UART_READER); - if (result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); - } - -#endif /* RPI_ADD_GPIO_TEST == 1 */ + "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = scexReaderTask->addComponent(objects::SCEX_UART_READER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); + } taskVec.push_back(scexReaderTask); +#endif /* RPI_ADD_GPIO_TEST == 1 */ taskVec.push_back(testTask); bool startTestPst = true; diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 76d35c6b..6bfa487f 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,6 +1,7 @@ -#include #include "ObjectFactory.h" +#include + #include "OBSWConfig.h" #include "devConf.h" #include "devices/addresses.h" @@ -198,8 +199,8 @@ void ObjectFactory::createTestTasks() { #endif #if OBSW_ADD_UART_TEST_CODE == 1 - new ScexUartReader(objects::SCEX_UART_READER); - new UartTestClass(objects::UART_TEST); + auto scexReader = new ScexUartReader(objects::SCEX_UART_READER); + new UartTestClass(objects::UART_TEST, scexReader); #else new UartComIF(objects::UART_COM_IF); #endif diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index bfa735e9..0941e423 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -3,6 +3,8 @@ #include // Error integer and strerror() function #include // Contains file controls like O_RDWR #include +#include +#include #include // write(), read(), close() #include "OBSWConfig.h" @@ -18,7 +20,11 @@ #define RPI_TEST_GPS_HANDLER 0 #endif -UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) { mode = TestModes::SCEX; } +UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) + : TestTask(objectId), reader(reader) { + mode = TestModes::SCEX; + scexMode = ScexModes::READER_TASK; +} ReturnValue_t UartTestClass::initialize() { if (mode == TestModes::GPS) { @@ -127,100 +133,129 @@ void UartTestClass::gpsPeriodic() { } void UartTestClass::scexInit() { -#if defined(RASPBERRY_PI) - std::string devname = "/dev/serial0"; -#else - std::string devname = "/dev/ul-scex"; -#endif - /* Get file descriptor */ - serialPort = open(devname.c_str(), O_RDWR); - if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; + if (reader == nullptr) { + sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; return; } - // Setting up UART parameters - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + if (scexMode == ScexModes::SIMPLE) { +#if defined(RASPBERRY_PI) + std::string devname = "/dev/serial0"; +#else + std::string devname = "/dev/ul-scex"; +#endif + /* Get file descriptor */ + serialPort = open(devname.c_str(), O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + return; + } + // Setting up UART parameters + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use non-canonical mode and clear echo flag - tty.c_lflag &= ~(ICANON | ECHO); + // Use non-canonical mode and clear echo flag + tty.c_lflag &= ~(ICANON | ECHO); - // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are - // received in one go - tty.c_cc[VTIME] = 1; // In units of 0.1 seconds - tty.c_cc[VMIN] = 255; // Read up to 255 bytes + // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are + // received in one go + tty.c_cc[VTIME] = 1; // In units of 0.1 seconds + tty.c_cc[VMIN] = 255; // Read up to 255 bytes - // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. + // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) - if (cfsetispeed(&tty, B57600) != 0) { - sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; - } + if (cfsetispeed(&tty, B57600) != 0) { + sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; + } #endif - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + // Flush received and unread data + tcflush(serialPort, TCIFLUSH); + } else { +#if defined(RASPBERRY_PI) + std::string devname = "/dev/serial0"; +#else + std::string devname = "/dev/ul-scex"; +#endif + uartCookie = + new UartCookie(this->getObjectId(), devname, UartModes::NON_CANONICAL, 57600, 4096); + reader->setDebugMode(true); + ReturnValue_t result = reader->initializeInterface(uartCookie); } - // Flush received and unread data - tcflush(serialPort, TCIFLUSH); } void UartTestClass::scexPeriodic() { - sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; - int result = prepareScexPing(); - if (result != 0) { + if (reader == nullptr) { return; - }; - size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); - if (bytesWritten != encodedLen) { - sif::warning << "Sending ping command to solar experiment failed" << std::endl; } - // Read back reply immediately - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno - << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - sif::info << "Received " << bytesRead - << " bytes from the Solar Cell Experiment:" << std::endl; - arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); - break; + if (scexMode == ScexModes::SIMPLE) { + sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; + // reader->sendMessage(nullptr, nullptr, 0); + uint8_t tmpCmdBuf[32] = {}; + size_t len = 0; + prepareScexPing(tmpCmdBuf, &len); + ReturnValue_t result = + dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return; } - } while (bytesRead > 0); + if (result != 0) { + return; + }; + size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending ping command to solar experiment failed" << std::endl; + } + + // Read back reply immediately + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" + << errno << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + sif::info << "Received " << bytesRead + << " bytes from the Solar Cell Experiment:" << std::endl; + arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); + break; + } + } while (bytesRead > 0); + } else { + size_t len = 0; + prepareScexPing(cmdBuf.data(), &len); + reader->sendMessage(uartCookie, cmdBuf.data(), len); + } } -int UartTestClass::prepareScexPing() { - std::array tmpCmdBuf = {}; +int UartTestClass::prepareScexPing(uint8_t* cmdBuf, size_t* len) { // Send ping command - tmpCmdBuf[0] = scex::CMD_PING; + cmdBuf[0] = scex::CMD_PING; // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each // telecommand so far - tmpCmdBuf[1] = 1; - tmpCmdBuf[2] = 1; + cmdBuf[1] = 1; + cmdBuf[2] = 1; uint16_t userDataLen = 0; - tmpCmdBuf[3] = (userDataLen >> 8) & 0xff; - tmpCmdBuf[4] = userDataLen & 0xff; - uint16_t crc = CRC::crc16ccitt(tmpCmdBuf.data(), 5); - tmpCmdBuf[5] = (crc >> 8) & 0xff; - tmpCmdBuf[6] = crc & 0xff; - ReturnValue_t result = - dleEncoder.encode(tmpCmdBuf.data(), 7, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return -1; - } + cmdBuf[3] = (userDataLen >> 8) & 0xff; + cmdBuf[4] = userDataLen & 0xff; + uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); + cmdBuf[5] = (crc >> 8) & 0xff; + cmdBuf[6] = crc & 0xff; + *len = 7; return 0; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 786d01ce..17fdca59 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -2,6 +2,7 @@ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ #include +#include #include // Contains POSIX terminal control definitions #include @@ -9,9 +10,11 @@ #include "lwgps/lwgps.h" #include "test/testtasks/TestTask.h" +class ScexUartReader; + class UartTestClass : public TestTask { public: - UartTestClass(object_id_t objectId); + UartTestClass(object_id_t objectId, ScexUartReader* reader); ReturnValue_t initialize() override; ReturnValue_t performOneShotAction() override; @@ -24,14 +27,17 @@ class UartTestClass : public TestTask { SCEX }; + enum ScexModes { SIMPLE, READER_TASK } scexMode; + void gpsInit(); void gpsPeriodic(); void scexInit(); void scexPeriodic(); - int prepareScexPing(); + int prepareScexPing(uint8_t* cmdBuf, size_t* len); TestModes mode = TestModes::GPS; DleEncoder dleEncoder = DleEncoder(); + UartCookie* uartCookie = nullptr; size_t encodedLen = 0; lwgps_t gpsData = {}; struct termios tty = {}; @@ -39,6 +45,7 @@ class UartTestClass : public TestTask { std::array cmdBuf = {}; std::array recBuf = {}; uint8_t recvCnt = 0; + ScexUartReader* reader = nullptr; }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 4aa78357..a35f153f 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -1,18 +1,174 @@ #include "ScexUartReader.h" + +#include // Contains file controls like O_RDWR +#include +#include +#include +#include +#include +#include // write(), read(), close() + +#include // Error integer and strerror() function #include +#include "OBSWConfig.h" -ScexUartReader::ScexUartReader(object_id_t objectId):SystemObject(objectId) { +ScexUartReader::ScexUartReader(object_id_t objectId) + : SystemObject(objectId), ringBuffer(200 * 2048, true), sizesQueue(200) { + semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); + semaphore->acquire(); + lock = MutexFactory::instance()->createMutex(); } -void ScexUartRead::start() { - semaphore->give(); -} +// void ScexUartRead::start() { /* semaphore->give(); */ } ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { - std::cout<<"hallo welt"<take(); - while(true) { - semaphore->take(); - } - return RETURN_OK; + lock->lockMutex(); + state = States::IDLE; + lock->unlockMutex(); + while (true) { + semaphore->acquire(); + std::cout << "task was started" << std::endl; + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead == 0) { + MutexGuard mg(lock); + States currentState = state; + if (currentState == States::FINISH) { + state = States::IDLE; + break; + } + } else if (bytesRead < 0) { + sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::error << "ScexUartReader::performOperation: Receive buffer too small" << std::endl; + } else if (bytesRead > 0) { + MutexGuard mg(lock); + sizesQueue.insert(bytesRead); + ReturnValue_t result = ringBuffer.writeData(recBuf.data(), bytesRead); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "ScexUartReader::performOperation: Writing into ring buffer failed" + << std::endl; + } + if (debugMode) { + sif::info << "Received " << bytesRead + << " bytes from the Solar Cell Experiment:" << std::endl; + arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); + } + break; + } + } while (bytesRead > 0); + // task block comes here + std::cout << "done" << std::endl; + } + return RETURN_OK; +} + +ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { + UartCookie *uartCookie = dynamic_cast(cookie); + if (uartCookie) { + return RETURN_FAILED; + } + std::string devname = uartCookie->getDeviceFile(); + /* Get file descriptor */ + serialPort = open(devname.c_str(), O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + // Setting up UART parameters + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + + // Use non-canonical mode and clear echo flag + tty.c_lflag &= ~(ICANON | ECHO); + + // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are + // received in one go + tty.c_cc[VTIME] = 20; // Read for up to 2 seconds + tty.c_cc[VMIN] = 0; // Read as much as there is available + + // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. +#if !defined(XIPHOS_Q7S) + if (cfsetispeed(&tty, B57600) != 0) { + sif::warning << "ScexUartReader::initializeInterface: Setting baud rate failed" << std::endl; + } +#endif + + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + // Flush received and unread data + tcflush(serialPort, TCIFLUSH); + return RETURN_OK; +} + +ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendData, + size_t sendLen) { + lock->lockMutex(); + if (state == States::NOT_READY or state == States::RUNNING) { + lock->unlockMutex(); + return HasReturnvaluesIF::RETURN_FAILED; + } + state = States::RUNNING; + lock->unlockMutex(); + size_t encodedLen = 0; + ReturnValue_t result = + dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return RETURN_FAILED; + } + size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending ping command to solar experiment failed" << std::endl; + return RETURN_FAILED; + } + result = semaphore->release(); + if (result != HasReturnvaluesIF::RETURN_OK) { + std::cout << "ScexUartReader::sendMessag: Releasing semaphore failed" << std::endl; + } + return RETURN_OK; +} + +ReturnValue_t ScexUartReader::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ScexUartReader::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { + return RETURN_OK; +} + +void ScexUartReader::setDebugMode(bool enable) { this->debugMode = enable; } + +ReturnValue_t ScexUartReader::finish() { + MutexGuard mg(lock); + if (state == States::IDLE) { + return HasReturnvaluesIF::RETURN_FAILED; + } + state = States::FINISH; + return RETURN_OK; +} + +ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, + size_t *size) { + MutexGuard mg(lock); + if (sizesQueue.empty()) { + *size = 0; + return RETURN_OK; + } + *size = sizesQueue.pop(); + *buffer = ipcBuffer.data(); + ReturnValue_t result = ringBuffer.readData(ipcBuffer.data(), *size, true); + if (result != RETURN_OK) { + sif::warning << "ScexUartReader::readReceivedMessage: Reading RingBuffer failed" << std::endl; + } + return RETURN_OK; } diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h index 70eafcf7..13ff7d73 100644 --- a/linux/devices/ScexUartReader.h +++ b/linux/devices/ScexUartReader.h @@ -1,18 +1,55 @@ #ifndef LINUX_DEVICES_SCEXUARTREADER_H_ #define LINUX_DEVICES_SCEXUARTREADER_H_ + +#include +#include +#include +#include #include #include +#include +#include // Contains POSIX terminal control definitions +class SemaphoreIF; +class MutexIF; -class ScexUartReader: public SystemObject, //strg+shift+n -public ExecutableObjectIF, -public HasReturnvaluesIF { -public: - ScexUartReader(object_id_t objectId); -private: - ReturnValue_t performOperation(uint8_t operationCode = 0) override; +class ScexUartReader : public SystemObject, // strg+shift+n + public ExecutableObjectIF, + public DeviceCommunicationIF { + friend class UartTestClass; + public: + enum class States { NOT_READY, IDLE, RUNNING, FINISH }; + ScexUartReader(object_id_t objectId); + + ReturnValue_t finish(); + void setDebugMode(bool enable); + + private: + SemaphoreIF *semaphore; + bool debugMode = false; + MutexIF *lock; + int serialPort = 0; + States state = States::IDLE; + struct termios tty = {}; + bool doFinish = false; + DleEncoder dleEncoder = DleEncoder(); + SimpleRingBuffer ringBuffer; + DynamicFIFO sizesQueue; + Countdown finishCoutdown = Countdown(180 * 1000); + std::array cmdbuf = {}; + std::array recBuf = {}; + + std::array ipcBuffer = {}; + + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + + // DeviceCommunicationIF implementation + ReturnValue_t initializeInterface(CookieIF *cookie) override; + ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) override; + ReturnValue_t getSendSuccess(CookieIF *cookie) override; + ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) override; }; - #endif /* LINUX_DEVICES_SCEXUARTREADER_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index 5fbc99d5..3d8edba2 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -58,7 +58,6 @@ enum sourceObjects : uint32_t { HEATER_HANDLER = 0x444100A4, RAD_SENSOR = 0x443200A5, - /* 0x54 ('T') for test handlers */ TEST_TASK = 0x54694269, LIBGPIOD_TEST = 0x54123456, -- 2.43.0 From 6071e34771af2d62e48b2c7a1f47eafb1b07dd6c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Apr 2022 21:16:02 +0200 Subject: [PATCH 04/48] some refactoring --- linux/boardtest/UartTestClass.cpp | 174 ++++++++++--------- linux/boardtest/UartTestClass.h | 4 + linux/devices/GPSHyperionLinuxController.cpp | 1 - mission/devices/P60DockHandler.cpp | 2 +- tmtc | 2 +- 5 files changed, 100 insertions(+), 83 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 0941e423..6ca8ef9a 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -23,7 +23,7 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; - scexMode = ScexModes::READER_TASK; + scexMode = ScexModes::SIMPLE; } ReturnValue_t UartTestClass::initialize() { @@ -138,47 +138,7 @@ void UartTestClass::scexInit() { return; } if (scexMode == ScexModes::SIMPLE) { -#if defined(RASPBERRY_PI) - std::string devname = "/dev/serial0"; -#else - std::string devname = "/dev/ul-scex"; -#endif - /* Get file descriptor */ - serialPort = open(devname.c_str(), O_RDWR); - if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - return; - } - // Setting up UART parameters - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - - // Use non-canonical mode and clear echo flag - tty.c_lflag &= ~(ICANON | ECHO); - - // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are - // received in one go - tty.c_cc[VTIME] = 1; // In units of 0.1 seconds - tty.c_cc[VMIN] = 255; // Read up to 255 bytes - - // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. -#if !defined(XIPHOS_Q7S) - if (cfsetispeed(&tty, B57600) != 0) { - sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; - } -#endif - - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - // Flush received and unread data - tcflush(serialPort, TCIFLUSH); + scexSimpleInit(); } else { #if defined(RASPBERRY_PI) std::string devname = "/dev/serial0"; @@ -189,6 +149,11 @@ void UartTestClass::scexInit() { new UartCookie(this->getObjectId(), devname, UartModes::NON_CANONICAL, 57600, 4096); reader->setDebugMode(true); ReturnValue_t result = reader->initializeInterface(uartCookie); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " + "UART IF failed" + << std::endl; + } } } @@ -198,44 +163,7 @@ void UartTestClass::scexPeriodic() { } if (scexMode == ScexModes::SIMPLE) { - sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; - // reader->sendMessage(nullptr, nullptr, 0); - uint8_t tmpCmdBuf[32] = {}; - size_t len = 0; - prepareScexPing(tmpCmdBuf, &len); - ReturnValue_t result = - dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return; - } - if (result != 0) { - return; - }; - size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); - if (bytesWritten != encodedLen) { - sif::warning << "Sending ping command to solar experiment failed" << std::endl; - } - - // Read back reply immediately - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" - << errno << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - sif::info << "Received " << bytesRead - << " bytes from the Solar Cell Experiment:" << std::endl; - arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); - break; - } - } while (bytesRead > 0); + scexSimplePeriodic(); } else { size_t len = 0; prepareScexPing(cmdBuf.data(), &len); @@ -259,3 +187,89 @@ int UartTestClass::prepareScexPing(uint8_t* cmdBuf, size_t* len) { *len = 7; return 0; } + +void UartTestClass::scexSimplePeriodic() { + sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; + uint8_t tmpCmdBuf[32] = {}; + size_t len = 0; + prepareScexPing(tmpCmdBuf, &len); + ReturnValue_t result = + dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return; + } + if (result != 0) { + return; + }; + size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending ping command to solar experiment failed" << std::endl; + } + + // Read back reply immediately + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead == 0) { + sif::warning << "Reading SCEX: Timeout occured after 0.5 seconds" << std::endl; + } else if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + sif::info << "Received " << bytesRead + << " bytes from the Solar Cell Experiment:" << std::endl; + arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); + break; + } + } while (bytesRead > 0); +} + +void UartTestClass::scexSimpleInit() { +#if defined(RASPBERRY_PI) + std::string devname = "/dev/serial0"; +#else + std::string devname = "/dev/ul-scex"; +#endif + /* Get file descriptor */ + serialPort = open(devname.c_str(), O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + return; + } + // Setting up UART parameters + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + + // Use non-canonical mode and clear echo flag + tty.c_lflag &= ~(ICANON | ECHO); + + // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are + // received in one go + tty.c_cc[VTIME] = 5; // In units of 0.1 seconds + tty.c_cc[VMIN] = 1; // Read up to 255 bytes + + // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. +#if !defined(XIPHOS_Q7S) + if (cfsetispeed(&tty, B57600) != 0) { + sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; + } +#endif + + // Flush received and unread data + tcflush(serialPort, TCIOFLUSH); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } +} diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 17fdca59..7c046931 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -35,6 +35,10 @@ class UartTestClass : public TestTask { void scexInit(); void scexPeriodic(); int prepareScexPing(uint8_t* cmdBuf, size_t* len); + + void scexSimplePeriodic(); + void scexSimpleInit(); + TestModes mode = TestModes::GPS; DleEncoder dleEncoder = DleEncoder(); UartCookie* uartCookie = nullptr; diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index d1ef7d1b..20860211 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -3,7 +3,6 @@ #include "OBSWConfig.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" - #include "linux/utility/utility.h" #include "mission/utility/compileTime.h" diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index d37673fc..508471d2 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -111,7 +111,7 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) { dataOffset += 6; coreHk.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3); - if(firstHk) { + if (firstHk) { triggerEvent(P60_BOOT_COUNT, coreHk.bootCount.value); } dataOffset += 6; diff --git a/tmtc b/tmtc index 3a1c7c62..091cf2dd 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 3a1c7c62887eb377c498bd9cdac47b93f40c85ba +Subproject commit 091cf2dd632c71a0fa8000312bb11e84f1a755db -- 2.43.0 From 44c8f5f7307549b2c7399fcdcf2f5014d25b2ee4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 9 Apr 2022 01:00:42 +0200 Subject: [PATCH 05/48] bugfix for SCEX --- bsp_linux_board/ObjectFactory.cpp | 2 +- linux/boardtest/UartTestClass.cpp | 99 ++++++++++--------- linux/boardtest/UartTestClass.h | 4 +- .../devicedefinitions/SCEXDefinitions.h | 12 ++- 4 files changed, 66 insertions(+), 51 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 6bfa487f..fe6a0fa3 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -78,7 +78,7 @@ void ObjectFactory::produce(void* args) { createRpiAcsBoard(gpioIF, spiDev); #endif -#if OBSW_ADD_SUN_SENSORS == 1 || defined(OBSW_ADD_RTD_DEVICES) +#if OBSW_ADD_SUN_SENSORS == 1 || OBSW_ADD_RTD_DEVICES == 1 #ifdef RASPBERRY_PI rpi::gpio::initSpiCsDecoder(gpioIF); #endif diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 6ca8ef9a..a59dc4ea 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -12,7 +12,6 @@ #include "fsfw/globalfunctions/DleEncoder.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface.h" -#include "mission/devices/devicedefinitions/SCEXDefinitions.h" #define GPS_REPLY_WIRETAPPING 0 @@ -24,6 +23,7 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; scexMode = ScexModes::SIMPLE; + currCmd = scex::ScexCmds::ONE_CELL; } ReturnValue_t UartTestClass::initialize() { @@ -166,14 +166,16 @@ void UartTestClass::scexPeriodic() { scexSimplePeriodic(); } else { size_t len = 0; - prepareScexPing(cmdBuf.data(), &len); + prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len); reader->sendMessage(uartCookie, cmdBuf.data(), len); } } -int UartTestClass::prepareScexPing(uint8_t* cmdBuf, size_t* len) { +int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, + uint8_t* cmdBuf, size_t* len) { + using namespace scex; // Send ping command - cmdBuf[0] = scex::CMD_PING; + cmdBuf[0] = scex::createCmdByte(cmd, false); // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each // telecommand so far cmdBuf[1] = 1; @@ -188,48 +190,6 @@ int UartTestClass::prepareScexPing(uint8_t* cmdBuf, size_t* len) { return 0; } -void UartTestClass::scexSimplePeriodic() { - sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; - uint8_t tmpCmdBuf[32] = {}; - size_t len = 0; - prepareScexPing(tmpCmdBuf, &len); - ReturnValue_t result = - dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return; - } - if (result != 0) { - return; - }; - size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); - if (bytesWritten != encodedLen) { - sif::warning << "Sending ping command to solar experiment failed" << std::endl; - } - - // Read back reply immediately - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead == 0) { - sif::warning << "Reading SCEX: Timeout occured after 0.5 seconds" << std::endl; - } else if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno - << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - sif::info << "Received " << bytesRead - << " bytes from the Solar Cell Experiment:" << std::endl; - arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); - break; - } - } while (bytesRead > 0); -} - void UartTestClass::scexSimpleInit() { #if defined(RASPBERRY_PI) std::string devname = "/dev/serial0"; @@ -256,8 +216,8 @@ void UartTestClass::scexSimpleInit() { // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are // received in one go - tty.c_cc[VTIME] = 5; // In units of 0.1 seconds - tty.c_cc[VMIN] = 1; // Read up to 255 bytes + tty.c_cc[VTIME] = 0; // In units of 0.1 seconds + tty.c_cc[VMIN] = 0; // Read up to 255 bytes // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) @@ -273,3 +233,46 @@ void UartTestClass::scexSimpleInit() { << std::endl; } } + +void UartTestClass::scexSimplePeriodic() { + using namespace scex; + sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; + uint8_t tmpCmdBuf[32] = {}; + size_t len = 0; + prepareScexCmd(currCmd, false, tmpCmdBuf, &len); + ReturnValue_t result = + dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return; + } + if (result != 0) { + return; + }; + size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending ping command to solar experiment failed" << std::endl; + } + + // Read back reply immediately + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead == 0) { + sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; + } else if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + sif::info << "Received " << bytesRead + << " bytes from the Solar Cell Experiment:" << std::endl; + arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); + break; + } + } while (bytesRead > 0); +} diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 7c046931..3836506c 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -8,6 +8,7 @@ #include #include "lwgps/lwgps.h" +#include "mission/devices/devicedefinitions/SCEXDefinitions.h" #include "test/testtasks/TestTask.h" class ScexUartReader; @@ -34,11 +35,12 @@ class UartTestClass : public TestTask { void scexInit(); void scexPeriodic(); - int prepareScexPing(uint8_t* cmdBuf, size_t* len); + int prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, size_t* len); void scexSimplePeriodic(); void scexSimpleInit(); + scex::ScexCmds currCmd = scex::ScexCmds::PING; TestModes mode = TestModes::GPS; DleEncoder dleEncoder = DleEncoder(); UartCookie* uartCookie = nullptr; diff --git a/mission/devices/devicedefinitions/SCEXDefinitions.h b/mission/devices/devicedefinitions/SCEXDefinitions.h index 8becabc8..f9c532ff 100644 --- a/mission/devices/devicedefinitions/SCEXDefinitions.h +++ b/mission/devices/devicedefinitions/SCEXDefinitions.h @@ -6,7 +6,17 @@ // Definitions for the Solar Cell Experiment namespace scex { -static constexpr uint8_t CMD_PING = 0x4e; +enum ScexCmds: uint8_t { + PING = 0b00111, + ONE_CELL = 0b00110 +}; + +static constexpr uint8_t IDLE_BIT_0_DEF_STATE = 0; +static constexpr uint8_t IDLE_BIT_1_DEF_STATE = 1; + +uint8_t createCmdByte(ScexCmds cmd, bool tempCheck) { + return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; +} } -- 2.43.0 From 808e01dfd360e7894d0aba11f985ea42cc7318ac Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 9 Apr 2022 14:43:06 +0200 Subject: [PATCH 06/48] DLE FRAM packets can be read now --- fsfw | 2 +- linux/boardtest/UartTestClass.cpp | 152 ++++++++++-------- linux/boardtest/UartTestClass.h | 20 ++- linux/devices/CMakeLists.txt | 1 + linux/devices/ScexDleParser.cpp | 6 + linux/devices/ScexDleParser.h | 12 ++ linux/devices/ScexUartReader.cpp | 37 +++-- linux/devices/ScexUartReader.h | 16 +- linux/fsfwconfig/OBSWConfig.h.in | 2 + mission/devices/CMakeLists.txt | 2 + .../devices/devicedefinitions/CMakeLists.txt | 3 + .../devicedefinitions/ScexDefinitions.cpp | 5 + .../{SCEXDefinitions.h => ScexDefinitions.h} | 11 +- 13 files changed, 176 insertions(+), 93 deletions(-) create mode 100644 linux/devices/ScexDleParser.cpp create mode 100644 linux/devices/ScexDleParser.h create mode 100644 mission/devices/devicedefinitions/CMakeLists.txt create mode 100644 mission/devices/devicedefinitions/ScexDefinitions.cpp rename mission/devices/devicedefinitions/{SCEXDefinitions.h => ScexDefinitions.h} (63%) diff --git a/fsfw b/fsfw index 85a6e4b1..bdddee4f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 85a6e4b12977f24247ed3ca3011c6f8b611a144e +Subproject commit bdddee4f81fbdff7f207fd03b3c592522e04c5aa diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index a59dc4ea..0a164c8b 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -4,6 +4,7 @@ #include // Contains file controls like O_RDWR #include #include +#include #include #include // write(), read(), close() @@ -20,10 +21,15 @@ #endif UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) - : TestTask(objectId), reader(reader) { + : TestTask(objectId), reader(reader), decodeRingBuf(4096, true) { mode = TestModes::SCEX; scexMode = ScexModes::SIMPLE; - currCmd = scex::ScexCmds::ONE_CELL; + currCmd = scex::ScexCmds::FRAM; + if (mode == TestModes::SCEX) { + dleParser = + new ScexDleParser(decodeRingBuf, dleEncoder, {encodedBuf.data(), encodedBuf.size()}, + {decodedBuf.data(), decodedBuf.size()}, &foundDlePacketHandler, this); + } } ReturnValue_t UartTestClass::initialize() { @@ -145,8 +151,7 @@ void UartTestClass::scexInit() { #else std::string devname = "/dev/ul-scex"; #endif - uartCookie = - new UartCookie(this->getObjectId(), devname, UartModes::NON_CANONICAL, 57600, 4096); + uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); reader->setDebugMode(true); ReturnValue_t result = reader->initializeInterface(uartCookie); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -171,25 +176,6 @@ void UartTestClass::scexPeriodic() { } } -int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, - uint8_t* cmdBuf, size_t* len) { - using namespace scex; - // Send ping command - cmdBuf[0] = scex::createCmdByte(cmd, false); - // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each - // telecommand so far - cmdBuf[1] = 1; - cmdBuf[2] = 1; - uint16_t userDataLen = 0; - cmdBuf[3] = (userDataLen >> 8) & 0xff; - cmdBuf[4] = userDataLen & 0xff; - uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); - cmdBuf[5] = (crc >> 8) & 0xff; - cmdBuf[6] = crc & 0xff; - *len = 7; - return 0; -} - void UartTestClass::scexSimpleInit() { #if defined(RASPBERRY_PI) std::string devname = "/dev/serial0"; @@ -216,8 +202,8 @@ void UartTestClass::scexSimpleInit() { // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are // received in one go - tty.c_cc[VTIME] = 0; // In units of 0.1 seconds - tty.c_cc[VMIN] = 0; // Read up to 255 bytes + tty.c_cc[VTIME] = 10; // In units of 0.1 seconds + tty.c_cc[VMIN] = 255; // Read up to 255 bytes // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) @@ -226,53 +212,89 @@ void UartTestClass::scexSimpleInit() { } #endif - // Flush received and unread data - tcflush(serialPort, TCIOFLUSH); if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) << std::endl; } + // Flush received and unread data + tcflush(serialPort, TCIOFLUSH); } void UartTestClass::scexSimplePeriodic() { using namespace scex; - sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl; - uint8_t tmpCmdBuf[32] = {}; - size_t len = 0; - prepareScexCmd(currCmd, false, tmpCmdBuf, &len); - ReturnValue_t result = - dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return; - } - if (result != 0) { - return; - }; - size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); - if (bytesWritten != encodedLen) { - sif::warning << "Sending ping command to solar experiment failed" << std::endl; - } - - // Read back reply immediately - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead == 0) { - sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; - } else if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno - << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - sif::info << "Received " << bytesRead - << " bytes from the Solar Cell Experiment:" << std::endl; - arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); - break; + ReturnValue_t result = RETURN_OK; + if (not cmdSent) { + // Flush received and unread data + tcflush(serialPort, TCIFLUSH); + uint8_t tmpCmdBuf[32] = {}; + size_t len = 0; + sif::info << "UartTestClass::scexSimplePeriodic: Sending command to SCEX" << std::endl; + prepareScexCmd(currCmd, false, tmpCmdBuf, &len); + result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return; } - } while (bytesRead > 0); + if (result != 0) { + return; + }; + size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending command to solar experiment failed" << std::endl; + } + cmdSent = true; + cmdDone = false; + } + if (not cmdDone) { + // Read back reply immediately + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead == 0) { + sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; + } else if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" + << errno << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + dleParser->passData(recBuf.data(), bytesRead); + if (currCmd == ScexCmds::PING) { + cmdDone = true; + cmdSent = false; + } + } + } while (bytesRead > 0); + } +} + +int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, + size_t* len) { + using namespace scex; + // Send ping command + cmdBuf[0] = scex::createCmdByte(cmd, false); + // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each + // telecommand so far + cmdBuf[1] = 1; + cmdBuf[2] = 1; + uint16_t userDataLen = 0; + cmdBuf[3] = (userDataLen >> 8) & 0xff; + cmdBuf[4] = userDataLen & 0xff; + uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); + cmdBuf[5] = (crc >> 8) & 0xff; + cmdBuf[6] = crc & 0xff; + *len = 7; + return 0; +} + +void UartTestClass::foundDlePacketHandler(uint8_t* packet, size_t len, void* args) { + UartTestClass* obj = reinterpret_cast(args); + obj->handleFoundDlePacket(packet, len); +} + +void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { + sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 3836506c..b080f8a3 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -1,6 +1,7 @@ #ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ +#include #include #include #include // Contains POSIX terminal control definitions @@ -8,10 +9,11 @@ #include #include "lwgps/lwgps.h" -#include "mission/devices/devicedefinitions/SCEXDefinitions.h" +#include "mission/devices/devicedefinitions/ScexDefinitions.h" #include "test/testtasks/TestTask.h" class ScexUartReader; +class ScexDleParser; class UartTestClass : public TestTask { public: @@ -40,6 +42,11 @@ class UartTestClass : public TestTask { void scexSimplePeriodic(); void scexSimpleInit(); + static void foundDlePacketHandler(uint8_t* packet, size_t len, void* args); + void handleFoundDlePacket(uint8_t* packet, size_t len); + + bool cmdSent = false; + bool cmdDone = false; scex::ScexCmds currCmd = scex::ScexCmds::PING; TestModes mode = TestModes::GPS; DleEncoder dleEncoder = DleEncoder(); @@ -48,10 +55,15 @@ class UartTestClass : public TestTask { lwgps_t gpsData = {}; struct termios tty = {}; int serialPort = 0; - std::array cmdBuf = {}; - std::array recBuf = {}; - uint8_t recvCnt = 0; + bool startFound = false; ScexUartReader* reader = nullptr; + SimpleRingBuffer decodeRingBuf; + std::array cmdBuf = {}; + std::array recBuf = {}; + std::array encodedBuf = {}; + std::array decodedBuf = {}; + ScexDleParser* dleParser; + uint8_t recvCnt = 0; }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index b8568560..6be5da2f 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -6,6 +6,7 @@ endif() target_sources(${OBSW_NAME} PRIVATE ScexUartReader.cpp + ScexDleParser.cpp ) add_subdirectory(ploc) add_subdirectory(startracker) diff --git a/linux/devices/ScexDleParser.cpp b/linux/devices/ScexDleParser.cpp new file mode 100644 index 00000000..f2620b8e --- /dev/null +++ b/linux/devices/ScexDleParser.cpp @@ -0,0 +1,6 @@ +#include "ScexDleParser.h" + +ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, + BufPair encodedBuf, BufPair decodedBuf, FoundPacketHandler handler, + void *args) + : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args) {} diff --git a/linux/devices/ScexDleParser.h b/linux/devices/ScexDleParser.h new file mode 100644 index 00000000..d914cdaf --- /dev/null +++ b/linux/devices/ScexDleParser.h @@ -0,0 +1,12 @@ +#ifndef LINUX_DEVICES_SCEXDLEPARSER_H_ +#define LINUX_DEVICES_SCEXDLEPARSER_H_ + +#include + +class ScexDleParser : public DleParser { + public: + ScexDleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPair encodedBuf, + BufPair decodedBuf, FoundPacketHandler handler, void* args); +}; + +#endif /* LINUX_DEVICES_SCEXDLEPARSER_H_ */ diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index a35f153f..8017e8c6 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include // write(), read(), close() #include // Error integer and strerror() function @@ -14,7 +15,12 @@ #include "OBSWConfig.h" ScexUartReader::ScexUartReader(object_id_t objectId) - : SystemObject(objectId), ringBuffer(200 * 2048, true), sizesQueue(200) { + : SystemObject(objectId), + decodeRingBuf(4096, true), + ipcRingBuf(200 * 2048, true), + ipcQueue(200), + dleParser(decodeRingBuf, dleEncoder, {encodedBuf.data(), encodedBuf.size()}, + {decodedBuf.data(), decodedBuf.size()}, &foundDlePacketHandler, this) { semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); semaphore->acquire(); lock = MutexFactory::instance()->createMutex(); @@ -47,10 +53,10 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { sif::error << "ScexUartReader::performOperation: Receive buffer too small" << std::endl; } else if (bytesRead > 0) { MutexGuard mg(lock); - sizesQueue.insert(bytesRead); - ReturnValue_t result = ringBuffer.writeData(recBuf.data(), bytesRead); + ipcQueue.insert(bytesRead); + ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "ScexUartReader::performOperation: Writing into ring buffer failed" + sif::warning << "ScexUartReader::performOperation: Passing data to DLE parser failed" << std::endl; } if (debugMode) { @@ -91,10 +97,9 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { // Use non-canonical mode and clear echo flag tty.c_lflag &= ~(ICANON | ECHO); - // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are - // received in one go - tty.c_cc[VTIME] = 20; // Read for up to 2 seconds - tty.c_cc[VMIN] = 0; // Read as much as there is available + // Non-blocking mode, use polling + tty.c_cc[VTIME] = 0; // Read for up to 2 seconds + tty.c_cc[VMIN] = 0; // Read as much as there is available // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) @@ -157,16 +162,26 @@ ReturnValue_t ScexUartReader::finish() { return RETURN_OK; } +void ScexUartReader::foundDlePacketHandler(uint8_t *packet, size_t len, void *args) { + ScexUartReader *obj = reinterpret_cast(args); + obj->handleFoundDlePacket(packet, len); +} + +void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { + // TODO: insert data into IPC ring buffer here + sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; +} + ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { MutexGuard mg(lock); - if (sizesQueue.empty()) { + if (ipcQueue.empty()) { *size = 0; return RETURN_OK; } - *size = sizesQueue.pop(); + *size = ipcQueue.pop(); *buffer = ipcBuffer.data(); - ReturnValue_t result = ringBuffer.readData(ipcBuffer.data(), *size, true); + ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true); if (result != RETURN_OK) { sif::warning << "ScexUartReader::readReceivedMessage: Reading RingBuffer failed" << std::endl; } diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h index 13ff7d73..246dd8f9 100644 --- a/linux/devices/ScexUartReader.h +++ b/linux/devices/ScexUartReader.h @@ -8,6 +8,7 @@ #include #include #include +#include #include // Contains POSIX terminal control definitions class SemaphoreIF; @@ -34,13 +35,20 @@ class ScexUartReader : public SystemObject, // strg+shift+n struct termios tty = {}; bool doFinish = false; DleEncoder dleEncoder = DleEncoder(); - SimpleRingBuffer ringBuffer; - DynamicFIFO sizesQueue; + SimpleRingBuffer decodeRingBuf; + Countdown finishCoutdown = Countdown(180 * 1000); std::array cmdbuf = {}; - std::array recBuf = {}; - + std::array recBuf = {}; + std::array encodedBuf = {}; + std::array decodedBuf = {}; std::array ipcBuffer = {}; + SimpleRingBuffer ipcRingBuf; + DynamicFIFO ipcQueue; + ScexDleParser dleParser; + + static void foundDlePacketHandler(uint8_t *packet, size_t len, void *args); + void handleFoundDlePacket(uint8_t *packet, size_t len); ReturnValue_t performOperation(uint8_t operationCode = 0) override; diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index bbf8da64..d288a0aa 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -163,6 +163,8 @@ debugging. */ #ifdef RASPBERRY_PI +#define OBSW_TC_FROM_PDEC 0 + #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 #define OBSW_ADD_PLOC_SUPERVISOR 0 diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 2919ff1f..fc013271 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -19,3 +19,5 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE PayloadPcduHandler.cpp SolarArrayDeploymentHandler.cpp ) + +add_subdirectory(devicedefinitions) diff --git a/mission/devices/devicedefinitions/CMakeLists.txt b/mission/devices/devicedefinitions/CMakeLists.txt new file mode 100644 index 00000000..3ac1d9bc --- /dev/null +++ b/mission/devices/devicedefinitions/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${LIB_EIVE_MISSION} PRIVATE + ScexDefinitions.cpp +) diff --git a/mission/devices/devicedefinitions/ScexDefinitions.cpp b/mission/devices/devicedefinitions/ScexDefinitions.cpp new file mode 100644 index 00000000..1e39f414 --- /dev/null +++ b/mission/devices/devicedefinitions/ScexDefinitions.cpp @@ -0,0 +1,5 @@ +#include "ScexDefinitions.h" + +uint8_t scex::createCmdByte(ScexCmds cmd, bool tempCheck) { + return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; +} diff --git a/mission/devices/devicedefinitions/SCEXDefinitions.h b/mission/devices/devicedefinitions/ScexDefinitions.h similarity index 63% rename from mission/devices/devicedefinitions/SCEXDefinitions.h rename to mission/devices/devicedefinitions/ScexDefinitions.h index f9c532ff..704500f4 100644 --- a/mission/devices/devicedefinitions/SCEXDefinitions.h +++ b/mission/devices/devicedefinitions/ScexDefinitions.h @@ -6,18 +6,13 @@ // Definitions for the Solar Cell Experiment namespace scex { -enum ScexCmds: uint8_t { - PING = 0b00111, - ONE_CELL = 0b00110 -}; +enum ScexCmds : uint8_t { PING = 0b00111, ONE_CELL = 0b00110, FRAM = 0b00001 }; static constexpr uint8_t IDLE_BIT_0_DEF_STATE = 0; static constexpr uint8_t IDLE_BIT_1_DEF_STATE = 1; -uint8_t createCmdByte(ScexCmds cmd, bool tempCheck) { - return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; -} +uint8_t createCmdByte(ScexCmds cmd, bool tempCheck); -} +} // namespace scex #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SCEXDEFINITIONS_H_ */ -- 2.43.0 From d00cb6d4a540d74cfa906187e2f21f7c5a1ce657 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 9 Apr 2022 15:38:09 +0200 Subject: [PATCH 07/48] updates for new dle parser API --- fsfw | 2 +- linux/boardtest/UartTestClass.cpp | 10 +++++++--- linux/boardtest/UartTestClass.h | 3 ++- linux/devices/ScexDleParser.cpp | 2 +- linux/devices/ScexDleParser.h | 2 +- linux/devices/ScexUartReader.cpp | 10 +++++++--- linux/devices/ScexUartReader.h | 2 +- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/fsfw b/fsfw index bdddee4f..4e242aa9 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit bdddee4f81fbdff7f207fd03b3c592522e04c5aa +Subproject commit 4e242aa9547dfc6d7abc0cdd405440547239016b diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 0a164c8b..672a34c8 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -290,9 +290,13 @@ int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* c return 0; } -void UartTestClass::foundDlePacketHandler(uint8_t* packet, size_t len, void* args) { - UartTestClass* obj = reinterpret_cast(args); - obj->handleFoundDlePacket(packet, len); +void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) { + UartTestClass* obj = reinterpret_cast(ctx.userArgs); + if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { + obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); + } else { + DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); + } } void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index b080f8a3..c6242281 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -3,6 +3,7 @@ #include #include +#include #include #include // Contains POSIX terminal control definitions @@ -42,7 +43,7 @@ class UartTestClass : public TestTask { void scexSimplePeriodic(); void scexSimpleInit(); - static void foundDlePacketHandler(uint8_t* packet, size_t len, void* args); + static void foundDlePacketHandler(const DleParser::Context& ctx); void handleFoundDlePacket(uint8_t* packet, size_t len); bool cmdSent = false; diff --git a/linux/devices/ScexDleParser.cpp b/linux/devices/ScexDleParser.cpp index f2620b8e..3a95e497 100644 --- a/linux/devices/ScexDleParser.cpp +++ b/linux/devices/ScexDleParser.cpp @@ -1,6 +1,6 @@ #include "ScexDleParser.h" ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, - BufPair encodedBuf, BufPair decodedBuf, FoundPacketHandler handler, + BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args) {} diff --git a/linux/devices/ScexDleParser.h b/linux/devices/ScexDleParser.h index d914cdaf..eab7e9c1 100644 --- a/linux/devices/ScexDleParser.h +++ b/linux/devices/ScexDleParser.h @@ -6,7 +6,7 @@ class ScexDleParser : public DleParser { public: ScexDleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPair encodedBuf, - BufPair decodedBuf, FoundPacketHandler handler, void* args); + BufPair decodedBuf, UserHandler handler, void* args); }; #endif /* LINUX_DEVICES_SCEXDLEPARSER_H_ */ diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 8017e8c6..5a325668 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -162,9 +162,13 @@ ReturnValue_t ScexUartReader::finish() { return RETURN_OK; } -void ScexUartReader::foundDlePacketHandler(uint8_t *packet, size_t len, void *args) { - ScexUartReader *obj = reinterpret_cast(args); - obj->handleFoundDlePacket(packet, len); +void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) { + ScexUartReader *obj = reinterpret_cast(ctx.userArgs); + if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { + obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); + } else { + DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); + } } void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h index 246dd8f9..ad760b39 100644 --- a/linux/devices/ScexUartReader.h +++ b/linux/devices/ScexUartReader.h @@ -47,7 +47,7 @@ class ScexUartReader : public SystemObject, // strg+shift+n DynamicFIFO ipcQueue; ScexDleParser dleParser; - static void foundDlePacketHandler(uint8_t *packet, size_t len, void *args); + static void foundDlePacketHandler(const DleParser::Context &ctx); void handleFoundDlePacket(uint8_t *packet, size_t len); ReturnValue_t performOperation(uint8_t operationCode = 0) override; -- 2.43.0 From 9f3f264eac0a986d7c0f025124f1595b9d21763f Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 13 Apr 2022 17:43:16 +0200 Subject: [PATCH 08/48] continued scex uart reader, some bugs --- fsfw | 2 +- linux/boardtest/UartTestClass.cpp | 493 ++++++++++++++++-------------- linux/boardtest/UartTestClass.h | 3 - linux/devices/ScexUartReader.cpp | 38 ++- 4 files changed, 293 insertions(+), 243 deletions(-) diff --git a/fsfw b/fsfw index 5ff88129..e0c9bf58 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5ff88129b8158a3a66366968231a68d01564f8fe +Subproject commit e0c9bf587151094a54568117aa7159607b8bac2e diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 672a34c8..c2619699 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -21,284 +21,331 @@ #endif UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) - : TestTask(objectId), reader(reader), decodeRingBuf(4096, true) { - mode = TestModes::SCEX; - scexMode = ScexModes::SIMPLE; - currCmd = scex::ScexCmds::FRAM; - if (mode == TestModes::SCEX) { - dleParser = - new ScexDleParser(decodeRingBuf, dleEncoder, {encodedBuf.data(), encodedBuf.size()}, - {decodedBuf.data(), decodedBuf.size()}, &foundDlePacketHandler, this); - } +: TestTask(objectId), reader(reader) { + mode = TestModes::SCEX; + scexMode = ScexModes::READER_TASK; + currCmd = scex::ScexCmds::FRAM; + if (scexMode == ScexModes::SIMPLE) { + auto encodingBuf = new std::array; + DleParser::BufPair encodingBufPair {encodingBuf->data(), encodingBuf->size()}; + auto decodedBuf = new std::array; + DleParser::BufPair decodingBufPair {decodedBuf->data(), decodedBuf->size()}; + dleParser = + new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, decodingBufPair, &foundDlePacketHandler, this); + } } ReturnValue_t UartTestClass::initialize() { - if (mode == TestModes::GPS) { - gpsInit(); - } else if (mode == TestModes::SCEX) { - scexInit(); - } - return HasReturnvaluesIF::RETURN_OK; + if (mode == TestModes::GPS) { + gpsInit(); + } else if (mode == TestModes::SCEX) { + scexInit(); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performOneShotAction() { return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performPeriodicAction() { - if (mode == TestModes::GPS) { - gpsPeriodic(); - } else if (mode == TestModes::SCEX) { - scexPeriodic(); - } - return HasReturnvaluesIF::RETURN_OK; + if (mode == TestModes::GPS) { + gpsPeriodic(); + } else if (mode == TestModes::SCEX) { + scexPeriodic(); + } + return HasReturnvaluesIF::RETURN_OK; } void UartTestClass::gpsInit() { #if RPI_TEST_GPS_HANDLER == 1 - int result = lwgps_init(&gpsData); - if (result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; - } + int result = lwgps_init(&gpsData); + if (result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } - /* Get file descriptor */ - serialPort = open("/dev/serial0", O_RDWR); - if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - /* Setting up UART parameters */ - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use canonical mode for GPS device - tty.c_lflag |= ICANON; - tty.c_lflag &= ~ECHO; // Disable echo - tty.c_lflag &= ~ECHOE; // Disable erasure - tty.c_lflag &= ~ECHONL; // Disable new-line echo - tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP - tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl - tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | - ICRNL); // Disable any special handling of received bytes - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + tty.c_lflag &= ~ECHONL; // Disable new-line echo + tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl + tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | + ICRNL); // Disable any special handling of received bytes + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - // Non-blocking mode - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 0; + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - ; - } - // Flush received and unread data. Those are old NMEA strings which are not relevant anymore - tcflush(serialPort, TCIFLUSH); + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + ; + } + // Flush received and unread data. Those are old NMEA strings which are not relevant anymore + tcflush(serialPort, TCIFLUSH); #endif } void UartTestClass::gpsPeriodic() { #if RPI_TEST_GPS_HANDLER == 1 - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno - << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " - "recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - // pass data to lwgps for processing + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + // pass data to lwgps for processing #if GPS_REPLY_WIRETAPPING == 1 - sif::info << recBuf.data() << std::endl; + sif::info << recBuf.data() << std::endl; #endif - int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); - if (result == 0) { - sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; - } - recvCnt++; - if (recvCnt == 6) { - recvCnt = 0; - sif::info << "GPS Data" << std::endl; - // Print messages - printf("Valid status: %d\n", gpsData.is_valid); - printf("Latitude: %f degrees\n", gpsData.latitude); - printf("Longitude: %f degrees\n", gpsData.longitude); - printf("Altitude: %f meters\n", gpsData.altitude); - } - } - } while (bytesRead > 0); + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if (result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + } + recvCnt++; + if (recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } + } + } while (bytesRead > 0); #endif } void UartTestClass::scexInit() { - if (reader == nullptr) { - sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; - return; - } - if (scexMode == ScexModes::SIMPLE) { - scexSimpleInit(); - } else { + if (reader == nullptr) { + sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; + return; + } + if (scexMode == ScexModes::SIMPLE) { + scexSimpleInit(); + } else { #if defined(RASPBERRY_PI) - std::string devname = "/dev/serial0"; + std::string devname = "/dev/serial0"; #else - std::string devname = "/dev/ul-scex"; + std::string devname = "/dev/ul-scex"; #endif - uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); - reader->setDebugMode(true); - ReturnValue_t result = reader->initializeInterface(uartCookie); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " - "UART IF failed" - << std::endl; - } - } + uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); + reader->setDebugMode(true); + ReturnValue_t result = reader->initializeInterface(uartCookie); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " + "UART IF failed" + << std::endl; + } + } } void UartTestClass::scexPeriodic() { - if (reader == nullptr) { - return; - } + using namespace std; + if (reader == nullptr) { + return; + } + + if (scexMode == ScexModes::SIMPLE) { + scexSimplePeriodic(); + } else { + if (not cmdSent){ + size_t len = 0; + prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len); + reader->sendMessage(uartCookie, cmdBuf.data(), len); + cmdSent = true; + cmdDone = false; + } + if (cmdSent and not cmdDone){ + uint8_t* decodedPacket = nullptr; + size_t len = 0; + ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); + + if(len > 0){ + sif::info<<"CmdByte: "<<(int)decodedPacket[0]<((decodedPacket[0] >> 1) & 0b11111); + size_t packetCounter = decodedPacket[1]; + sif::info<<"PacketCounter: "<finish(); + sif::info<<"Reader is finished" << endl; + cmdDone = true; + if(cmd == scex::ScexCmds::PING){ + cmdSent = false; + } + } + + } + } + + } - if (scexMode == ScexModes::SIMPLE) { - scexSimplePeriodic(); - } else { - size_t len = 0; - prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len); - reader->sendMessage(uartCookie, cmdBuf.data(), len); - } } void UartTestClass::scexSimpleInit() { #if defined(RASPBERRY_PI) - std::string devname = "/dev/serial0"; + std::string devname = "/dev/serial0"; #else - std::string devname = "/dev/ul-scex"; + std::string devname = "/dev/ul-scex"; #endif - /* Get file descriptor */ - serialPort = open(devname.c_str(), O_RDWR); - if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - return; - } - // Setting up UART parameters - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + /* Get file descriptor */ + serialPort = open(devname.c_str(), O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + return; + } + // Setting up UART parameters + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use non-canonical mode and clear echo flag - tty.c_lflag &= ~(ICANON | ECHO); + // Use non-canonical mode and clear echo flag + tty.c_lflag &= ~(ICANON | ECHO); - // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are - // received in one go - tty.c_cc[VTIME] = 10; // In units of 0.1 seconds - tty.c_cc[VMIN] = 255; // Read up to 255 bytes + // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are + // received in one go + tty.c_cc[VTIME] = 10; // In units of 0.1 seconds + tty.c_cc[VMIN] = 255; // Read up to 255 bytes - // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. + // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) - if (cfsetispeed(&tty, B57600) != 0) { - sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; - } + if (cfsetispeed(&tty, B57600) != 0) { + sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; + } #endif - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - // Flush received and unread data - tcflush(serialPort, TCIOFLUSH); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + // Flush received and unread data + tcflush(serialPort, TCIOFLUSH); } void UartTestClass::scexSimplePeriodic() { - using namespace scex; - ReturnValue_t result = RETURN_OK; - if (not cmdSent) { - // Flush received and unread data - tcflush(serialPort, TCIFLUSH); - uint8_t tmpCmdBuf[32] = {}; - size_t len = 0; - sif::info << "UartTestClass::scexSimplePeriodic: Sending command to SCEX" << std::endl; - prepareScexCmd(currCmd, false, tmpCmdBuf, &len); - result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return; - } - if (result != 0) { - return; - }; - size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); - if (bytesWritten != encodedLen) { - sif::warning << "Sending command to solar experiment failed" << std::endl; - } - cmdSent = true; - cmdDone = false; - } - if (not cmdDone) { - // Read back reply immediately - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead == 0) { - sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; - } else if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" - << errno << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - dleParser->passData(recBuf.data(), bytesRead); - if (currCmd == ScexCmds::PING) { - cmdDone = true; - cmdSent = false; - } - } - } while (bytesRead > 0); - } + using namespace scex; + ReturnValue_t result = RETURN_OK; + if (not cmdSent) { + // Flush received and unread data + tcflush(serialPort, TCIFLUSH); + uint8_t tmpCmdBuf[32] = {}; + size_t len = 0; + sif::info << "UartTestClass::scexSimplePeriodic: Sending command to SCEX" << std::endl; + prepareScexCmd(currCmd, false, tmpCmdBuf, &len); + result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return; + } + if (result != 0) { + return; + }; + size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending command to solar experiment failed" << std::endl; + } + cmdSent = true; + cmdDone = false; + } + if (not cmdDone) { + // Read back reply immediately + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead == 0) { + sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; + } else if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" + << errno << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + dleParser->passData(recBuf.data(), bytesRead); + if (currCmd == ScexCmds::PING) { + cmdDone = true; + cmdSent = false; + } + } + } while (bytesRead > 0); + } } int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, - size_t* len) { - using namespace scex; - // Send ping command - cmdBuf[0] = scex::createCmdByte(cmd, false); - // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each - // telecommand so far - cmdBuf[1] = 1; - cmdBuf[2] = 1; - uint16_t userDataLen = 0; - cmdBuf[3] = (userDataLen >> 8) & 0xff; - cmdBuf[4] = userDataLen & 0xff; - uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); - cmdBuf[5] = (crc >> 8) & 0xff; - cmdBuf[6] = crc & 0xff; - *len = 7; - return 0; + size_t* len) { + using namespace scex; + // Send ping command + cmdBuf[0] = scex::createCmdByte(cmd, false); + // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each + // telecommand so far + cmdBuf[1] = 1; + cmdBuf[2] = 1; + uint16_t userDataLen = 0; + cmdBuf[3] = (userDataLen >> 8) & 0xff; + cmdBuf[4] = userDataLen & 0xff; + uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); + cmdBuf[5] = (crc >> 8) & 0xff; + cmdBuf[6] = crc & 0xff; + *len = 7; + return 0; } void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) { - UartTestClass* obj = reinterpret_cast(ctx.userArgs); - if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { - obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); - } else { - DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); - } + UartTestClass* obj = reinterpret_cast(ctx.userArgs); + if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { + obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); + } else { + DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); + } } void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { - sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; + sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index c6242281..03c6805d 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -58,11 +58,8 @@ class UartTestClass : public TestTask { int serialPort = 0; bool startFound = false; ScexUartReader* reader = nullptr; - SimpleRingBuffer decodeRingBuf; std::array cmdBuf = {}; std::array recBuf = {}; - std::array encodedBuf = {}; - std::array decodedBuf = {}; ScexDleParser* dleParser; uint8_t recvCnt = 0; }; diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 5a325668..15201dd1 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -26,16 +26,15 @@ ScexUartReader::ScexUartReader(object_id_t objectId) lock = MutexFactory::instance()->createMutex(); } -// void ScexUartRead::start() { /* semaphore->give(); */ } ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { lock->lockMutex(); state = States::IDLE; lock->unlockMutex(); while (true) { semaphore->acquire(); - std::cout << "task was started" << std::endl; + sif::info << "task was started" << std::endl; int bytesRead = 0; - do { + while(true) { bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), static_cast(recBuf.size())); if (bytesRead == 0) { @@ -52,21 +51,17 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { } else if (bytesRead >= static_cast(recBuf.size())) { sif::error << "ScexUartReader::performOperation: Receive buffer too small" << std::endl; } else if (bytesRead > 0) { - MutexGuard mg(lock); - ipcQueue.insert(bytesRead); ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead); + if (debugMode) { + sif::info << "Received " << bytesRead + << " bytes from the Solar Cell Experiment:" << std::endl; + } if (result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "ScexUartReader::performOperation: Passing data to DLE parser failed" << std::endl; } - if (debugMode) { - sif::info << "Received " << bytesRead - << " bytes from the Solar Cell Experiment:" << std::endl; - arrayprinter::print(recBuf.data(), bytesRead, OutputType::HEX, false); - } - break; } - } while (bytesRead > 0); + }; // task block comes here std::cout << "done" << std::endl; } @@ -75,10 +70,11 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { UartCookie *uartCookie = dynamic_cast(cookie); - if (uartCookie) { + if (uartCookie == nullptr) { return RETURN_FAILED; } std::string devname = uartCookie->getDeviceFile(); + sif::info << devname << std::endl; /* Get file descriptor */ serialPort = open(devname.c_str(), O_RDWR); if (serialPort < 0) { @@ -98,8 +94,8 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { tty.c_lflag &= ~(ICANON | ECHO); // Non-blocking mode, use polling - tty.c_cc[VTIME] = 0; // Read for up to 2 seconds - tty.c_cc[VMIN] = 0; // Read as much as there is available + tty.c_cc[VTIME] = 10; // Read for up to 1 seconds + tty.c_cc[VMIN] = 255; // Read as much as there is available // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) @@ -174,11 +170,21 @@ void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) { void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { // TODO: insert data into IPC ring buffer here sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; + //MutexGuard mg(lock); + ReturnValue_t result = ipcQueue.insert(len); + if(result != RETURN_OK){ + sif::warning<< "IPCQueue error" << std::endl; + } + result = ipcRingBuf.writeData(packet, len); + if(result != RETURN_OK){ + sif::warning<< "IPCRingBuf error" << std::endl; + } + sif::info << "DLE handler done" << std::endl; } ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { - MutexGuard mg(lock); + //MutexGuard mg(lock); if (ipcQueue.empty()) { *size = 0; return RETURN_OK; -- 2.43.0 From bbdd3c052e31f9270fa037b472bf91ba4eb4288e Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 13 Apr 2022 17:47:24 +0200 Subject: [PATCH 09/48] mutex --- linux/boardtest/UartTestClass.cpp | 2 +- linux/devices/ScexUartReader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index c2619699..28d92c40 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -23,7 +23,7 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; - scexMode = ScexModes::READER_TASK; + scexMode = ScexModes::SIMPLE; currCmd = scex::ScexCmds::FRAM; if (scexMode == ScexModes::SIMPLE) { auto encodingBuf = new std::array; diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 15201dd1..657fb829 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -170,7 +170,7 @@ void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) { void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { // TODO: insert data into IPC ring buffer here sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; - //MutexGuard mg(lock); + MutexGuard mg(lock); ReturnValue_t result = ipcQueue.insert(len); if(result != RETURN_OK){ sif::warning<< "IPCQueue error" << std::endl; @@ -184,7 +184,7 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { - //MutexGuard mg(lock); + MutexGuard mg(lock); if (ipcQueue.empty()) { *size = 0; return RETURN_OK; -- 2.43.0 From 57cc77e19750b508823b8578cd47c34de61670c2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 15 Apr 2022 01:39:47 +0200 Subject: [PATCH 10/48] fixed some tiny bugs --- linux/boardtest/UartTestClass.cpp | 538 +++++++++++++++--------------- linux/devices/ScexUartReader.cpp | 31 +- mission/devices/IMTQHandler.cpp | 2 +- tmtc | 2 +- 4 files changed, 289 insertions(+), 284 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 28d92c40..7723dc86 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -21,331 +21,333 @@ #endif UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) -: TestTask(objectId), reader(reader) { - mode = TestModes::SCEX; - scexMode = ScexModes::SIMPLE; - currCmd = scex::ScexCmds::FRAM; - if (scexMode == ScexModes::SIMPLE) { - auto encodingBuf = new std::array; - DleParser::BufPair encodingBufPair {encodingBuf->data(), encodingBuf->size()}; - auto decodedBuf = new std::array; - DleParser::BufPair decodingBufPair {decodedBuf->data(), decodedBuf->size()}; - dleParser = - new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, decodingBufPair, &foundDlePacketHandler, this); - } + : TestTask(objectId), reader(reader) { + mode = TestModes::SCEX; + scexMode = ScexModes::READER_TASK; + currCmd = scex::ScexCmds::PING; + if (scexMode == ScexModes::SIMPLE) { + auto encodingBuf = new std::array; + DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()}; + auto decodedBuf = new std::array; + DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()}; + dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, + decodingBufPair, &foundDlePacketHandler, this); + } } ReturnValue_t UartTestClass::initialize() { - if (mode == TestModes::GPS) { - gpsInit(); - } else if (mode == TestModes::SCEX) { - scexInit(); - } - return HasReturnvaluesIF::RETURN_OK; + if (mode == TestModes::GPS) { + gpsInit(); + } else if (mode == TestModes::SCEX) { + scexInit(); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performOneShotAction() { return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t UartTestClass::performPeriodicAction() { - if (mode == TestModes::GPS) { - gpsPeriodic(); - } else if (mode == TestModes::SCEX) { - scexPeriodic(); - } - return HasReturnvaluesIF::RETURN_OK; + if (mode == TestModes::GPS) { + gpsPeriodic(); + } else if (mode == TestModes::SCEX) { + scexPeriodic(); + } + return HasReturnvaluesIF::RETURN_OK; } void UartTestClass::gpsInit() { #if RPI_TEST_GPS_HANDLER == 1 - int result = lwgps_init(&gpsData); - if (result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; - } + int result = lwgps_init(&gpsData); + if (result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } - /* Get file descriptor */ - serialPort = open("/dev/serial0", O_RDWR); - if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - /* Setting up UART parameters */ - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use canonical mode for GPS device - tty.c_lflag |= ICANON; - tty.c_lflag &= ~ECHO; // Disable echo - tty.c_lflag &= ~ECHOE; // Disable erasure - tty.c_lflag &= ~ECHONL; // Disable new-line echo - tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP - tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl - tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | - ICRNL); // Disable any special handling of received bytes - tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) - tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + tty.c_lflag &= ~ECHONL; // Disable new-line echo + tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl + tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | + ICRNL); // Disable any special handling of received bytes + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed - // Non-blocking mode - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 0; + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; - cfsetispeed(&tty, B9600); - cfsetospeed(&tty, B9600); - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - ; - } - // Flush received and unread data. Those are old NMEA strings which are not relevant anymore - tcflush(serialPort, TCIFLUSH); + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + ; + } + // Flush received and unread data. Those are old NMEA strings which are not relevant anymore + tcflush(serialPort, TCIFLUSH); #endif } void UartTestClass::gpsPeriodic() { #if RPI_TEST_GPS_HANDLER == 1 - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno - << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " - "recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - // pass data to lwgps for processing + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + // pass data to lwgps for processing #if GPS_REPLY_WIRETAPPING == 1 - sif::info << recBuf.data() << std::endl; + sif::info << recBuf.data() << std::endl; #endif - int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); - if (result == 0) { - sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; - } - recvCnt++; - if (recvCnt == 6) { - recvCnt = 0; - sif::info << "GPS Data" << std::endl; - // Print messages - printf("Valid status: %d\n", gpsData.is_valid); - printf("Latitude: %f degrees\n", gpsData.latitude); - printf("Longitude: %f degrees\n", gpsData.longitude); - printf("Altitude: %f meters\n", gpsData.altitude); - } - } - } while (bytesRead > 0); + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if (result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + } + recvCnt++; + if (recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } + } + } while (bytesRead > 0); #endif } void UartTestClass::scexInit() { - if (reader == nullptr) { - sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; - return; - } - if (scexMode == ScexModes::SIMPLE) { - scexSimpleInit(); - } else { + if (reader == nullptr) { + sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; + return; + } + if (scexMode == ScexModes::SIMPLE) { + scexSimpleInit(); + } else { #if defined(RASPBERRY_PI) - std::string devname = "/dev/serial0"; + std::string devname = "/dev/serial0"; #else - std::string devname = "/dev/ul-scex"; + std::string devname = "/dev/ul-scex"; #endif - uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); - reader->setDebugMode(true); - ReturnValue_t result = reader->initializeInterface(uartCookie); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " - "UART IF failed" - << std::endl; - } - } + uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); + reader->setDebugMode(true); + ReturnValue_t result = reader->initializeInterface(uartCookie); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " + "UART IF failed" + << std::endl; + } + } } void UartTestClass::scexPeriodic() { - using namespace std; - if (reader == nullptr) { - return; - } + using namespace std; + if (reader == nullptr) { + return; + } - if (scexMode == ScexModes::SIMPLE) { - scexSimplePeriodic(); - } else { - if (not cmdSent){ - size_t len = 0; - prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len); - reader->sendMessage(uartCookie, cmdBuf.data(), len); - cmdSent = true; - cmdDone = false; - } - if (cmdSent and not cmdDone){ - uint8_t* decodedPacket = nullptr; - size_t len = 0; - ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); + if (scexMode == ScexModes::SIMPLE) { + scexSimplePeriodic(); + } else { + if (not cmdSent) { + size_t len = 0; + prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len); + reader->sendMessage(uartCookie, cmdBuf.data(), len); + cmdSent = true; + cmdDone = false; + } + if (cmdSent and not cmdDone) { + uint8_t* decodedPacket = nullptr; + size_t len = 0; + ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); - if(len > 0){ - sif::info<<"CmdByte: "<<(int)decodedPacket[0]<((decodedPacket[0] >> 1) & 0b11111); - size_t packetCounter = decodedPacket[1]; - sif::info<<"PacketCounter: "<finish(); - sif::info<<"Reader is finished" << endl; - cmdDone = true; - if(cmd == scex::ScexCmds::PING){ - cmdSent = false; - } - } - - } - } - - } + if (len > 0) { + sif::info << "CmdByte: " << std::setw(2) << std::setfill('0') << std::hex + << (int)decodedPacket[0] << std::dec << endl; + scex::ScexCmds cmd = static_cast((decodedPacket[0] >> 1) & 0b11111); + sif::info << "Command: 0x" << std::setw(2) << std::setfill('0') << std::hex + << static_cast(cmd) << std::dec << std::endl; + size_t packetCounter = decodedPacket[1]; + sif::info << "PacketCounter: " << packetCounter << endl; + size_t totalPacketCounter = decodedPacket[2]; + sif::info << "TotalPacketCount: " << totalPacketCounter << endl; + uint16_t packetLen = (decodedPacket[3] << 8) | (decodedPacket[4]); + sif::info << "PacketLength: " << packetLen << endl; + uint16_t expectedPacketLen = packetLen + 7; + sif::info << "ExpectedPacketLength: " << packetLen + 7 << endl; + if (expectedPacketLen != len) { + sif::warning << "ExpectedPacketLength " << expectedPacketLen << " is not Length" << len + << endl; + } + if (CRC::crc16ccitt(decodedPacket, expectedPacketLen) != 0) { + sif::warning << "CRC invalid" << endl; + } else { + sif::info << "CRC valid" << endl; + } + if (packetCounter == totalPacketCounter) { + reader->finish(); + sif::info << "Reader is finished" << endl; + cmdDone = true; + // TODO: Bug in firmware, other command will be returned + cmdSent = false; + // if (cmd == scex::ScexCmds::PING) { + // cmdSent = false; + // } + } + } + } + } } void UartTestClass::scexSimpleInit() { #if defined(RASPBERRY_PI) - std::string devname = "/dev/serial0"; + std::string devname = "/dev/serial0"; #else - std::string devname = "/dev/ul-scex"; + std::string devname = "/dev/ul-scex"; #endif - /* Get file descriptor */ - serialPort = open(devname.c_str(), O_RDWR); - if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - return; - } - // Setting up UART parameters - tty.c_cflag &= ~PARENB; // Clear parity bit - tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication - tty.c_cflag &= ~CSIZE; // Clear all the size bits - tty.c_cflag |= CS8; // 8 bits per byte - tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control - tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + /* Get file descriptor */ + serialPort = open(devname.c_str(), O_RDWR); + if (serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + return; + } + // Setting up UART parameters + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) - // Use non-canonical mode and clear echo flag - tty.c_lflag &= ~(ICANON | ECHO); + // Use non-canonical mode and clear echo flag + tty.c_lflag &= ~(ICANON | ECHO); - // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are - // received in one go - tty.c_cc[VTIME] = 10; // In units of 0.1 seconds - tty.c_cc[VMIN] = 255; // Read up to 255 bytes + // Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are + // received in one go + tty.c_cc[VTIME] = 0; // In units of 0.1 seconds + tty.c_cc[VMIN] = 0; // Read up to 255 bytes - // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. + // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) - if (cfsetispeed(&tty, B57600) != 0) { - sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; - } + if (cfsetispeed(&tty, B57600) != 0) { + sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; + } #endif - if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; - } - // Flush received and unread data - tcflush(serialPort, TCIOFLUSH); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + // Flush received and unread data + tcflush(serialPort, TCIOFLUSH); } void UartTestClass::scexSimplePeriodic() { - using namespace scex; - ReturnValue_t result = RETURN_OK; - if (not cmdSent) { - // Flush received and unread data - tcflush(serialPort, TCIFLUSH); - uint8_t tmpCmdBuf[32] = {}; - size_t len = 0; - sif::info << "UartTestClass::scexSimplePeriodic: Sending command to SCEX" << std::endl; - prepareScexCmd(currCmd, false, tmpCmdBuf, &len); - result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return; - } - if (result != 0) { - return; - }; - size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); - if (bytesWritten != encodedLen) { - sif::warning << "Sending command to solar experiment failed" << std::endl; - } - cmdSent = true; - cmdDone = false; - } - if (not cmdDone) { - // Read back reply immediately - int bytesRead = 0; - do { - bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), - static_cast(recBuf.size())); - if (bytesRead == 0) { - sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; - } else if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" - << errno << ", " << strerror(errno) << "]" << std::endl; - break; - } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; - } else if (bytesRead > 0) { - dleParser->passData(recBuf.data(), bytesRead); - if (currCmd == ScexCmds::PING) { - cmdDone = true; - cmdSent = false; - } - } - } while (bytesRead > 0); - } + using namespace scex; + ReturnValue_t result = RETURN_OK; + if (not cmdSent) { + // Flush received and unread data + tcflush(serialPort, TCIFLUSH); + uint8_t tmpCmdBuf[32] = {}; + size_t len = 0; + sif::info << "UartTestClass::scexSimplePeriodic: Sending command to SCEX" << std::endl; + prepareScexCmd(currCmd, false, tmpCmdBuf, &len); + result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + return; + } + if (result != 0) { + return; + }; + size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); + if (bytesWritten != encodedLen) { + sif::warning << "Sending command to solar experiment failed" << std::endl; + } + cmdSent = true; + cmdDone = false; + } + if (not cmdDone) { + // Read back reply immediately + int bytesRead = 0; + do { + bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if (bytesRead == 0) { + sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; + } else if (bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" + << errno << ", " << strerror(errno) << "]" << std::endl; + break; + } else if (bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" + << std::endl; + } else if (bytesRead > 0) { + dleParser->passData(recBuf.data(), bytesRead); + if (currCmd == ScexCmds::PING) { + cmdDone = true; + cmdSent = false; + } + } + } while (bytesRead > 0); + } } int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, - size_t* len) { - using namespace scex; - // Send ping command - cmdBuf[0] = scex::createCmdByte(cmd, false); - // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each - // telecommand so far - cmdBuf[1] = 1; - cmdBuf[2] = 1; - uint16_t userDataLen = 0; - cmdBuf[3] = (userDataLen >> 8) & 0xff; - cmdBuf[4] = userDataLen & 0xff; - uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); - cmdBuf[5] = (crc >> 8) & 0xff; - cmdBuf[6] = crc & 0xff; - *len = 7; - return 0; + size_t* len) { + using namespace scex; + // Send ping command + cmdBuf[0] = scex::createCmdByte(cmd, false); + // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each + // telecommand so far + cmdBuf[1] = 1; + cmdBuf[2] = 1; + uint16_t userDataLen = 0; + cmdBuf[3] = (userDataLen >> 8) & 0xff; + cmdBuf[4] = userDataLen & 0xff; + uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); + cmdBuf[5] = (crc >> 8) & 0xff; + cmdBuf[6] = crc & 0xff; + *len = 7; + return 0; } void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) { - UartTestClass* obj = reinterpret_cast(ctx.userArgs); - if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { - obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); - } else { - DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); - } + UartTestClass* obj = reinterpret_cast(ctx.userArgs); + if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { + obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); + } else { + DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); + } } void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { - sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; + sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 657fb829..e0868b48 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include // write(), read(), close() @@ -34,16 +35,17 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { semaphore->acquire(); sif::info << "task was started" << std::endl; int bytesRead = 0; - while(true) { + while (true) { bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), static_cast(recBuf.size())); if (bytesRead == 0) { MutexGuard mg(lock); - States currentState = state; - if (currentState == States::FINISH) { + if (state == States::FINISH) { + sif::debug << "finish detected" << std::endl; state = States::IDLE; break; } + TaskFactory::delayTask(1000); } else if (bytesRead < 0) { sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno << ", " << strerror(errno) << "]" << std::endl; @@ -63,7 +65,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { } }; // task block comes here - std::cout << "done" << std::endl; + sif::info << "task was stopped" << std::endl; } return RETURN_OK; } @@ -74,7 +76,7 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { return RETURN_FAILED; } std::string devname = uartCookie->getDeviceFile(); - sif::info << devname << std::endl; + sif::info << devname << std::endl; /* Get file descriptor */ serialPort = open(devname.c_str(), O_RDWR); if (serialPort < 0) { @@ -94,8 +96,8 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { tty.c_lflag &= ~(ICANON | ECHO); // Non-blocking mode, use polling - tty.c_cc[VTIME] = 10; // Read for up to 1 seconds - tty.c_cc[VMIN] = 255; // Read as much as there is available + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) @@ -109,7 +111,7 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { << std::endl; } // Flush received and unread data - tcflush(serialPort, TCIFLUSH); + tcflush(serialPort, TCIOFLUSH); return RETURN_OK; } @@ -172,13 +174,13 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; MutexGuard mg(lock); ReturnValue_t result = ipcQueue.insert(len); - if(result != RETURN_OK){ - sif::warning<< "IPCQueue error" << std::endl; + if (result != RETURN_OK) { + sif::warning << "IPCQueue error" << std::endl; } result = ipcRingBuf.writeData(packet, len); - if(result != RETURN_OK){ - sif::warning<< "IPCRingBuf error" << std::endl; - } + if (result != RETURN_OK) { + sif::warning << "IPCRingBuf error" << std::endl; + } sif::info << "DLE handler done" << std::endl; } @@ -189,7 +191,8 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu *size = 0; return RETURN_OK; } - *size = ipcQueue.pop(); + sif::info << "returning data" << std::endl; + ipcQueue.retrieve(size); *buffer = ipcBuffer.data(); ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true); if (result != RETURN_OK) { diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 645a8aa7..e9483d35 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -118,7 +118,7 @@ ReturnValue_t IMTQHandler::buildCommandFromCommand(DeviceCommandId_t deviceComma case (IMTQ::START_ACTUATION_DIPOLE): { /* IMTQ expects low byte first */ commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE; - if(commandData == nullptr) { + if (commandData == nullptr) { return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; } commandBuffer[1] = commandData[1]; diff --git a/tmtc b/tmtc index ecb973c3..8a30f669 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ecb973c37fe43954d0be1f19b0735b3546d2ef1b +Subproject commit 8a30f669f075c284494d7c1c6618e42e2aec8f15 -- 2.43.0 From f52c2a32b7064b2a11d1a2f6e1fddd4c56efbc33 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 15 Apr 2022 01:40:14 +0200 Subject: [PATCH 11/48] repoint fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index e0c9bf58..186b3565 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e0c9bf587151094a54568117aa7159607b8bac2e +Subproject commit 186b3565e0eb6ca10ec2203febdbc7eb7e7f7fe0 -- 2.43.0 From ad12fa606020b6f261d8a944f12e1a82a6c116fb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 15 Apr 2022 01:40:53 +0200 Subject: [PATCH 12/48] repoint fsfw again --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 186b3565..e949368b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 186b3565e0eb6ca10ec2203febdbc7eb7e7f7fe0 +Subproject commit e949368b062e8703c35d2043ece8d7258cd2608b -- 2.43.0 From 01f812b932dff83601fd780a1548eeb06fba947f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 15 Apr 2022 01:42:00 +0200 Subject: [PATCH 13/48] reorder fix --- mission/devices/IMTQHandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 2b3ba240..07f610b7 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -10,7 +10,6 @@ IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, power::Switch_t pwrSwitcher) : DeviceHandlerBase(objectId, comIF, comCookie), - switcher(pwrSwitcher), engHkDataset(this), calMtmMeasurementSet(this), rawMtmMeasurementSet(this), @@ -19,8 +18,9 @@ IMTQHandler::IMTQHandler(object_id_t objectId, object_id_t comIF, CookieIF* comC posYselfTestDataset(this), negYselfTestDataset(this), posZselfTestDataset(this), - negZselfTestDataset(this) { - if (comCookie == NULL) { + negZselfTestDataset(this), + switcher(pwrSwitcher) { + if (comCookie == nullptr) { sif::error << "IMTQHandler: Invalid com cookie" << std::endl; } } -- 2.43.0 From a99b0007db8694441e32e457ba12fe7425f742e7 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 21 Apr 2022 16:58:43 +0200 Subject: [PATCH 14/48] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index e0c9bf58..befaca78 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e0c9bf587151094a54568117aa7159607b8bac2e +Subproject commit befaca78c660f232c312667202f2bbd5da95c235 -- 2.43.0 From 578899b5a584c8e7952d303103fd71982172a5d3 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 21 Apr 2022 19:47:09 +0200 Subject: [PATCH 15/48] scexhelper --- linux/boardtest/UartTestClass.cpp | 55 ++++++------ linux/boardtest/UartTestClass.h | 1 + linux/devices/CMakeLists.txt | 1 + linux/devices/ScexHelper.cpp | 83 +++++++++++++++++++ linux/devices/ScexHelper.h | 48 +++++++++++ .../devicedefinitions/ScexDefinitions.h | 2 +- 6 files changed, 163 insertions(+), 27 deletions(-) create mode 100644 linux/devices/ScexHelper.cpp create mode 100644 linux/devices/ScexHelper.h diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 7723dc86..b4a23c6c 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include // write(), read(), close() @@ -167,6 +168,7 @@ void UartTestClass::scexInit() { void UartTestClass::scexPeriodic() { using namespace std; + using namespace scex; if (reader == nullptr) { return; } @@ -187,38 +189,39 @@ void UartTestClass::scexPeriodic() { ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); if (len > 0) { - sif::info << "CmdByte: " << std::setw(2) << std::setfill('0') << std::hex - << (int)decodedPacket[0] << std::dec << endl; - scex::ScexCmds cmd = static_cast((decodedPacket[0] >> 1) & 0b11111); - sif::info << "Command: 0x" << std::setw(2) << std::setfill('0') << std::hex - << static_cast(cmd) << std::dec << std::endl; - size_t packetCounter = decodedPacket[1]; - sif::info << "PacketCounter: " << packetCounter << endl; - size_t totalPacketCounter = decodedPacket[2]; - sif::info << "TotalPacketCount: " << totalPacketCounter << endl; - uint16_t packetLen = (decodedPacket[3] << 8) | (decodedPacket[4]); - sif::info << "PacketLength: " << packetLen << endl; - uint16_t expectedPacketLen = packetLen + 7; + ScexHelper helper; + const uint8_t* helperPtr = decodedPacket; + result = helper.deSerialize(&helperPtr, &len); + if (result == ScexHelper::INVALID_CRC) { + sif::warning << "CRC invalid" << std::endl; + } + sif::info << helper << endl; - sif::info << "ExpectedPacketLength: " << packetLen + 7 << endl; - if (expectedPacketLen != len) { - sif::warning << "ExpectedPacketLength " << expectedPacketLen << " is not Length" << len - << endl; + //ping + //if ping cmd + ofstream out("/tmp/scex-ping.bin", ofstream::binary ); + if (out.bad()) { + sif::warning << "bad" < + //countdown (max 2min), wenn nicht if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { nach 2min reader->finish(); + if(helper.getCmd() == FRAM) { + if(helper.getPacketCounter() == 0) { + // neues file anlegen wie oben ping + } else { + // an bestehendes file hinzufügen + } } - if (packetCounter == totalPacketCounter) { + out << helper; + + if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { reader->finish(); sif::info << "Reader is finished" << endl; cmdDone = true; - // TODO: Bug in firmware, other command will be returned - cmdSent = false; - // if (cmd == scex::ScexCmds::PING) { - // cmdSent = false; - // } + if (helper.getCmd() == scex::ScexCmds::PING) { + cmdSent = false; + } } } } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 03c6805d..0a228782 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -61,6 +61,7 @@ class UartTestClass : public TestTask { std::array cmdBuf = {}; std::array recBuf = {}; ScexDleParser* dleParser; + scex::ScexCmds cmdHelper; uint8_t recvCnt = 0; }; diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 6be5da2f..9a4695ca 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -7,6 +7,7 @@ endif() target_sources(${OBSW_NAME} PRIVATE ScexUartReader.cpp ScexDleParser.cpp + ScexHelper.cpp ) add_subdirectory(ploc) add_subdirectory(startracker) diff --git a/linux/devices/ScexHelper.cpp b/linux/devices/ScexHelper.cpp new file mode 100644 index 00000000..bc7ee04f --- /dev/null +++ b/linux/devices/ScexHelper.cpp @@ -0,0 +1,83 @@ +#include "ScexHelper.h" + +#include + +#include "fsfw/serviceinterface.h" + +ScexHelper::ScexHelper() {} + +ReturnValue_t ScexHelper::serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const { + return RETURN_FAILED; +} + +size_t ScexHelper::getSerializedSize() const { return totalPacketLen; } + +ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) { + if (buffer == nullptr or size == nullptr) { + return RETURN_FAILED; + } + if (*size < 7) { + return STREAM_TOO_SHORT; + } + start = *buffer; + cmdByteRaw = **buffer; + cmd = static_cast((cmdByteRaw >> 1) & 0b11111); + + *buffer += 1; + packetCounter = **buffer; + + *buffer += 1; + totalPacketCounter = **buffer; + + *buffer += 1; + payloadLen = (**buffer << 8) | *(*buffer + 1); + + *buffer += 2; + totalPacketLen = payloadLen + HEADER_LEN + CRC_LEN; + if (totalPacketLen >= *size) { + return STREAM_TOO_SHORT; + } + *buffer += payloadLen; + crc = (**buffer << 8) | *(*buffer + 1); + if (CRC::crc16ccitt(start, totalPacketLen) != 0) { + return INVALID_CRC; + } + return RETURN_OK; +} + +scex::ScexCmds ScexHelper::getCmd() const { return cmd; } + +uint8_t ScexHelper::getCmdByteRaw() const { return cmdByteRaw; } + +uint16_t ScexHelper::getCrc() const { return crc; } + +size_t ScexHelper::getExpectedPacketLen() const { return totalPacketLen; } + +uint8_t ScexHelper::getPacketCounter() const { return packetCounter; } + +uint16_t ScexHelper::getPayloadLen() const { return payloadLen; } + +const uint8_t* ScexHelper::getStart() const { return start; } + +uint8_t ScexHelper::getTotalPacketCounter() const { return totalPacketCounter; } + +std::ostream& operator<<(std::ostream& os, const ScexHelper& h) { + using namespace std; + sif::info << "Command Byte Raw: 0x" << std::setw(2) << std::setfill('0') << std::hex + << (int)h.cmdByteRaw << " | Command: 0x" << std::setw(2) << std::setfill('0') + << std::hex << static_cast(h.cmd) << std::dec << std::endl; + sif::info << "PacketCounter: " << h.packetCounter << endl; + sif::info << "TotalPacketCount: " << h.totalPacketCounter << endl; + sif::info << "PayloadLength: " << h.payloadLen << endl; + sif::info << "TotalPacketLength: " << h.totalPacketLen << endl; + + return os; +} + +std::ofstream& operator<<(std::ofstream& of, const ScexHelper& h) { + of.write(reinterpret_cast(h.start), h.getSerializedSize()); + + return of; +} diff --git a/linux/devices/ScexHelper.h b/linux/devices/ScexHelper.h new file mode 100644 index 00000000..a835bd0a --- /dev/null +++ b/linux/devices/ScexHelper.h @@ -0,0 +1,48 @@ +#ifndef LINUX_DEVICES_SCEXHELPER_H_ +#define LINUX_DEVICES_SCEXHELPER_H_ +#include +#include + +#include +#include +#include +#include +// ScexHelper helper; +// helper.deSerialize(data, ...); +// sif::info << helper << std::endl; +class ScexHelper : public HasReturnvaluesIF, public SerializeIF { + public: + static const ReturnValue_t INVALID_CRC = HasReturnvaluesIF::makeReturnCode(0, 2); + static constexpr uint8_t HEADER_LEN = 5; + static constexpr uint8_t CRC_LEN = 2; + ScexHelper(); + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; + + size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness = Endianness::BIG) override; + friend std::ostream &operator<<(std::ostream &os, const ScexHelper &h); + friend std::ofstream &operator<<(std::ofstream &os, const ScexHelper &h); + + scex::ScexCmds getCmd() const; + uint8_t getCmdByteRaw() const; + uint16_t getCrc() const; + size_t getExpectedPacketLen() const; + uint8_t getPacketCounter() const; + uint16_t getPayloadLen() const; + const uint8_t *getStart() const; + uint8_t getTotalPacketCounter() const; + + private: + const uint8_t *start = nullptr; + uint16_t crc = 0; + uint8_t cmdByteRaw = 0; + scex::ScexCmds cmd = scex::ScexCmds::INVALID; + int packetCounter = 0; + int totalPacketCounter = 0; + uint16_t payloadLen = 0; + size_t totalPacketLen = 0; +}; + +#endif /* LINUX_DEVICES_SCEXHELPER_H_ */ diff --git a/mission/devices/devicedefinitions/ScexDefinitions.h b/mission/devices/devicedefinitions/ScexDefinitions.h index 704500f4..f479981e 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.h +++ b/mission/devices/devicedefinitions/ScexDefinitions.h @@ -6,7 +6,7 @@ // Definitions for the Solar Cell Experiment namespace scex { -enum ScexCmds : uint8_t { PING = 0b00111, ONE_CELL = 0b00110, FRAM = 0b00001 }; +enum ScexCmds : uint8_t { PING = 0b00111, ONE_CELL = 0b00110, FRAM = 0b00001, INVALID = 255 }; static constexpr uint8_t IDLE_BIT_0_DEF_STATE = 0; static constexpr uint8_t IDLE_BIT_1_DEF_STATE = 1; -- 2.43.0 From e2f0c0f1be3885abec108d34f0333fd786109db0 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 26 Apr 2022 13:22:56 +0200 Subject: [PATCH 16/48] fram rec --- linux/boardtest/UartTestClass.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index b4a23c6c..12404269 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -25,7 +25,7 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; scexMode = ScexModes::READER_TASK; - currCmd = scex::ScexCmds::PING; + currCmd = scex::ScexCmds::FRAM; if (scexMode == ScexModes::SIMPLE) { auto encodingBuf = new std::array; DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()}; @@ -178,7 +178,7 @@ void UartTestClass::scexPeriodic() { } else { if (not cmdSent) { size_t len = 0; - prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len); + prepareScexCmd(currCmd, false, cmdBuf.data(), &len); reader->sendMessage(uartCookie, cmdBuf.data(), len); cmdSent = true; cmdDone = false; @@ -199,21 +199,24 @@ void UartTestClass::scexPeriodic() { //ping //if ping cmd + if(helper.getCmd() == PING) { ofstream out("/tmp/scex-ping.bin", ofstream::binary ); if (out.bad()) { sif::warning << "bad" < //countdown (max 2min), wenn nicht if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { nach 2min reader->finish(); if(helper.getCmd() == FRAM) { if(helper.getPacketCounter() == 0) { - // neues file anlegen wie oben ping + ofstream out("/tmp/scex-fram.bin", ofstream::binary ); // neues file anlegen wie oben ping } else { - // an bestehendes file hinzufügen + ofstream out("/tmp/scex-fram.bin", ofstream::binary | ofstream::app );// an bestehendes file hinzufügen + out << helper; } } - out << helper; if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { reader->finish(); @@ -326,7 +329,7 @@ void UartTestClass::scexSimplePeriodic() { int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, size_t* len) { using namespace scex; - // Send ping command + // Send command cmdBuf[0] = scex::createCmdByte(cmd, false); // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each // telecommand so far -- 2.43.0 From c5683afe9f892a838bc4654ddc64130ca9177736 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 27 Apr 2022 16:46:11 +0200 Subject: [PATCH 17/48] fram --- linux/devices/ScexUartReader.cpp | 2 +- linux/devices/ScexUartReader.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index e0868b48..cfac79e4 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -51,7 +51,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { << ", " << strerror(errno) << "]" << std::endl; break; } else if (bytesRead >= static_cast(recBuf.size())) { - sif::error << "ScexUartReader::performOperation: Receive buffer too small" << std::endl; + sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead << " bytes" << std::endl; } else if (bytesRead > 0) { ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead); if (debugMode) { diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h index ad760b39..4cebb31e 100644 --- a/linux/devices/ScexUartReader.h +++ b/linux/devices/ScexUartReader.h @@ -37,9 +37,9 @@ class ScexUartReader : public SystemObject, // strg+shift+n DleEncoder dleEncoder = DleEncoder(); SimpleRingBuffer decodeRingBuf; - Countdown finishCoutdown = Countdown(180 * 1000); + Countdown finishCountdown = Countdown(180 * 1000); std::array cmdbuf = {}; - std::array recBuf = {}; + std::array recBuf = {}; std::array encodedBuf = {}; std::array decodedBuf = {}; std::array ipcBuffer = {}; -- 2.43.0 From e11c84a5ed09f20a8ba75cd2663f515f48c414bb Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 27 Apr 2022 18:21:32 +0200 Subject: [PATCH 18/48] update --- linux/boardtest/UartTestClass.cpp | 63 +++++++++++++++++++------------ linux/boardtest/UartTestClass.h | 4 +- linux/devices/ScexHelper.cpp | 2 +- linux/devices/ScexUartReader.cpp | 11 +++--- linux/devices/ScexUartReader.h | 1 - 5 files changed, 47 insertions(+), 34 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 12404269..27e8d02e 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -156,7 +156,7 @@ void UartTestClass::scexInit() { std::string devname = "/dev/ul-scex"; #endif uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); - reader->setDebugMode(true); + reader->setDebugMode(false); ReturnValue_t result = reader->initializeInterface(uartCookie); if (result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " @@ -186,9 +186,11 @@ void UartTestClass::scexPeriodic() { if (cmdSent and not cmdDone) { uint8_t* decodedPacket = nullptr; size_t len = 0; - ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); - - if (len > 0) { + do { + ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); + if(len == 0){ + break; + } ScexHelper helper; const uint8_t* helperPtr = decodedPacket; result = helper.deSerialize(&helperPtr, &len); @@ -197,25 +199,35 @@ void UartTestClass::scexPeriodic() { } sif::info << helper << endl; - //ping - //if ping cmd - if(helper.getCmd() == PING) { - ofstream out("/tmp/scex-ping.bin", ofstream::binary ); - if (out.bad()) { - sif::warning << "bad" < - //countdown (max 2min), wenn nicht if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { nach 2min reader->finish(); - if(helper.getCmd() == FRAM) { - if(helper.getPacketCounter() == 0) { - ofstream out("/tmp/scex-fram.bin", ofstream::binary ); // neues file anlegen wie oben ping - } else { - ofstream out("/tmp/scex-fram.bin", ofstream::binary | ofstream::app );// an bestehendes file hinzufügen - out << helper; - } + // fram + // packetcounter eins höher, wenn mehr packet verloren -> merkt sich welches packet fehlt + //was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit finish false wird? + // countdown (max 2min), wenn nicht if (helper.getPacketCounter() == + // helper.getTotalPacketCounter()) { nach 2min reader->finish(); + if (helper.getCmd() == FRAM) { + if (helper.getPacketCounter() == 1) { + //countdown starten + finishCountdown.resetTimer(); + ofstream out("/tmp/scex-fram.bin", + ofstream::binary); // neues file anlegen wie oben ping + } else { + ofstream out("/tmp/scex-fram.bin", + ofstream::binary | ofstream::app); // an bestehendes file hinzufügen + out << helper; + } + + if(finishCountdown.hasTimedOut()){ + reader->finish(); + } } if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { @@ -226,7 +238,7 @@ void UartTestClass::scexPeriodic() { cmdSent = false; } } - } + } while (len > 0); } } } @@ -313,8 +325,9 @@ void UartTestClass::scexSimplePeriodic() { << errno << ", " << strerror(errno) << "]" << std::endl; break; } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough" - << std::endl; + sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large " + "enough, bytes read:" + << bytesRead << std::endl; } else if (bytesRead > 0) { dleParser->passData(recBuf.data(), bytesRead); if (currCmd == ScexCmds::PING) { diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 0a228782..28a8b8a7 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include // Contains POSIX terminal control definitions @@ -46,6 +47,7 @@ class UartTestClass : public TestTask { static void foundDlePacketHandler(const DleParser::Context& ctx); void handleFoundDlePacket(uint8_t* packet, size_t len); + Countdown finishCountdown = Countdown(180 * 1000); bool cmdSent = false; bool cmdDone = false; scex::ScexCmds currCmd = scex::ScexCmds::PING; @@ -59,7 +61,7 @@ class UartTestClass : public TestTask { bool startFound = false; ScexUartReader* reader = nullptr; std::array cmdBuf = {}; - std::array recBuf = {}; + std::array recBuf = {}; ScexDleParser* dleParser; scex::ScexCmds cmdHelper; uint8_t recvCnt = 0; diff --git a/linux/devices/ScexHelper.cpp b/linux/devices/ScexHelper.cpp index bc7ee04f..ca29ff65 100644 --- a/linux/devices/ScexHelper.cpp +++ b/linux/devices/ScexHelper.cpp @@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& os, const ScexHelper& h) { sif::info << "PacketCounter: " << h.packetCounter << endl; sif::info << "TotalPacketCount: " << h.totalPacketCounter << endl; sif::info << "PayloadLength: " << h.payloadLen << endl; - sif::info << "TotalPacketLength: " << h.totalPacketLen << endl; + sif::info << "TotalPacketLength: " << h.totalPacketLen; return os; } diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index cfac79e4..517ee4a1 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -45,13 +45,14 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { state = States::IDLE; break; } - TaskFactory::delayTask(1000); + TaskFactory::delayTask(400); } else if (bytesRead < 0) { sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno << ", " << strerror(errno) << "]" << std::endl; break; } else if (bytesRead >= static_cast(recBuf.size())) { - sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead << " bytes" << std::endl; + sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead + << " bytes" << std::endl; } else if (bytesRead > 0) { ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead); if (debugMode) { @@ -76,7 +77,6 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { return RETURN_FAILED; } std::string devname = uartCookie->getDeviceFile(); - sif::info << devname << std::endl; /* Get file descriptor */ serialPort = open(devname.c_str(), O_RDWR); if (serialPort < 0) { @@ -171,7 +171,7 @@ void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) { void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { // TODO: insert data into IPC ring buffer here - sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; + // sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; MutexGuard mg(lock); ReturnValue_t result = ipcQueue.insert(len); if (result != RETURN_OK) { @@ -181,7 +181,7 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { if (result != RETURN_OK) { sif::warning << "IPCRingBuf error" << std::endl; } - sif::info << "DLE handler done" << std::endl; + // sif::info << "DLE handler done" << std::endl; } ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, @@ -191,7 +191,6 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu *size = 0; return RETURN_OK; } - sif::info << "returning data" << std::endl; ipcQueue.retrieve(size); *buffer = ipcBuffer.data(); ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true); diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h index 4cebb31e..4abbfd86 100644 --- a/linux/devices/ScexUartReader.h +++ b/linux/devices/ScexUartReader.h @@ -37,7 +37,6 @@ class ScexUartReader : public SystemObject, // strg+shift+n DleEncoder dleEncoder = DleEncoder(); SimpleRingBuffer decodeRingBuf; - Countdown finishCountdown = Countdown(180 * 1000); std::array cmdbuf = {}; std::array recBuf = {}; std::array encodedBuf = {}; -- 2.43.0 From e16e6c2d17ab41df0aea08cd1e2cc76c5541643c Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 29 Apr 2022 12:26:18 +0200 Subject: [PATCH 19/48] fileId --- linux/boardtest/UartTestClass.cpp | 26 ++++++++++++++++++++++---- linux/boardtest/UartTestClass.h | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 27e8d02e..88a0895c 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -217,11 +217,13 @@ void UartTestClass::scexPeriodic() { if (helper.getPacketCounter() == 1) { //countdown starten finishCountdown.resetTimer(); - ofstream out("/tmp/scex-fram.bin", - ofstream::binary); // neues file anlegen wie oben ping + fileId = gen_random(12); + fileName = "/tmp/scex-fram_"+fileId+".bin"; + ofstream out(fileName, + ofstream::binary); // neues file anlegen } else { - ofstream out("/tmp/scex-fram.bin", - ofstream::binary | ofstream::app); // an bestehendes file hinzufügen + ofstream out(fileName, + ofstream::binary | ofstream::app); // an bestehendes file appenden out << helper; } @@ -370,3 +372,19 @@ void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) { void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } + +std::string gen_random(const int len) { + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + std::string tmp_s; + tmp_s.reserve(len); + + for (int i = 0; i < len; ++i) { + tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)]; + } + + return tmp_s; +} diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 28a8b8a7..dad9152e 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -46,7 +46,10 @@ class UartTestClass : public TestTask { static void foundDlePacketHandler(const DleParser::Context& ctx); void handleFoundDlePacket(uint8_t* packet, size_t len); + std::string gen_random(const int len); + std::string fileId = ""; + std::string fileName = ""; Countdown finishCountdown = Countdown(180 * 1000); bool cmdSent = false; bool cmdDone = false; -- 2.43.0 From be7b1411268ff97850de370bccdbbd48c5846e90 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 29 Apr 2022 12:30:52 +0200 Subject: [PATCH 20/48] update --- linux/boardtest/UartTestClass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 88a0895c..2e1a195c 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -373,7 +373,7 @@ void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } -std::string gen_random(const int len) { +std::string UartTestClass::gen_random(const int len) { static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -- 2.43.0 From 7c15eb57bbde24efd1e84abc926803f148fc4d74 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 29 Apr 2022 12:48:13 +0200 Subject: [PATCH 21/48] update --- linux/boardtest/UartTestClass.cpp | 47 ++++++++++++++++++------------- linux/boardtest/UartTestClass.h | 1 + 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 2e1a195c..1fa6a10c 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -188,8 +188,8 @@ void UartTestClass::scexPeriodic() { size_t len = 0; do { ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len); - if(len == 0){ - break; + if (len == 0) { + break; } ScexHelper helper; const uint8_t* helperPtr = decodedPacket; @@ -210,15 +210,19 @@ void UartTestClass::scexPeriodic() { } // fram // packetcounter eins höher, wenn mehr packet verloren -> merkt sich welches packet fehlt - //was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit finish false wird? + // was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit + // finish false wird? // countdown (max 2min), wenn nicht if (helper.getPacketCounter() == // helper.getTotalPacketCounter()) { nach 2min reader->finish(); if (helper.getCmd() == FRAM) { + if (not fileNameSet) { + fileId = gen_random(12); + fileName = "/tmp/scex-fram_" + fileId + ".bin"; + fileNameSet = true; + } if (helper.getPacketCounter() == 1) { - //countdown starten - finishCountdown.resetTimer(); - fileId = gen_random(12); - fileName = "/tmp/scex-fram_"+fileId+".bin"; + // countdown starten + finishCountdown.resetTimer(); ofstream out(fileName, ofstream::binary); // neues file anlegen } else { @@ -227,8 +231,11 @@ void UartTestClass::scexPeriodic() { out << helper; } - if(finishCountdown.hasTimedOut()){ - reader->finish(); + if (finishCountdown.hasTimedOut()) { + reader->finish(); + sif::warning << "Reader countdown expired" << endl; + cmdDone = true; + fileNameSet = false; } } @@ -236,8 +243,10 @@ void UartTestClass::scexPeriodic() { reader->finish(); sif::info << "Reader is finished" << endl; cmdDone = true; + fileNameSet = false; if (helper.getCmd() == scex::ScexCmds::PING) { cmdSent = false; + fileNameSet = true; // to not generate everytime new file } } } while (len > 0); @@ -374,17 +383,17 @@ void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { } std::string UartTestClass::gen_random(const int len) { - static const char alphanum[] = - "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; - std::string tmp_s; - tmp_s.reserve(len); + std::string tmp_s; + tmp_s.reserve(len); - for (int i = 0; i < len; ++i) { - tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)]; - } + for (int i = 0; i < len; ++i) { + tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)]; + } - return tmp_s; + return tmp_s; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index dad9152e..8c6bc22f 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -50,6 +50,7 @@ class UartTestClass : public TestTask { std::string fileId = ""; std::string fileName = ""; + bool fileNameSet = false; Countdown finishCountdown = Countdown(180 * 1000); bool cmdSent = false; bool cmdDone = false; -- 2.43.0 From 57f3103e52d19c26fca380a44832cf40564aa9cd Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 29 Apr 2022 13:31:14 +0200 Subject: [PATCH 22/48] update --- linux/boardtest/UartTestClass.cpp | 28 +++++++++++++++++----------- linux/boardtest/UartTestClass.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 1fa6a10c..b958579a 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -9,6 +9,9 @@ #include #include // write(), read(), close() +#include +#include + #include "OBSWConfig.h" #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/DleEncoder.h" @@ -216,7 +219,7 @@ void UartTestClass::scexPeriodic() { // helper.getTotalPacketCounter()) { nach 2min reader->finish(); if (helper.getCmd() == FRAM) { if (not fileNameSet) { - fileId = gen_random(12); + fileId = random_string(12); fileName = "/tmp/scex-fram_" + fileId + ".bin"; fileNameSet = true; } @@ -382,18 +385,21 @@ void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } -std::string UartTestClass::gen_random(const int len) { - static const char alphanum[] = +std::string UartTestClass::random_string(std::string::size_type length) { + static auto& chrs = "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - std::string tmp_s; - tmp_s.reserve(len); + thread_local static std::mt19937 rg{std::random_device{}()}; + thread_local static std::uniform_int_distribution pick(0, + sizeof(chrs) - 2); - for (int i = 0; i < len; ++i) { - tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)]; - } + std::string s; - return tmp_s; + s.reserve(length); + + while (length--) s += chrs[pick(rg)]; + + return s; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 8c6bc22f..ca42a688 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -46,7 +46,7 @@ class UartTestClass : public TestTask { static void foundDlePacketHandler(const DleParser::Context& ctx); void handleFoundDlePacket(uint8_t* packet, size_t len); - std::string gen_random(const int len); + std::string random_string(std::string::size_type length); std::string fileId = ""; std::string fileName = ""; -- 2.43.0 From f2cb43a52fb91f13c20e8b30887eb33af4f207d5 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Fri, 29 Apr 2022 15:46:16 +0200 Subject: [PATCH 23/48] scexDataHandler --- common/config/commonSubsystemIds.h | 1 + linux/boardtest/UartTestClass.cpp | 15 +- linux/boardtest/UartTestClass.h | 6 +- linux/devices/ScexHelper.cpp | 6 +- linux/devices/ScexHelper.h | 7 +- mission/devices/CMakeLists.txt | 1 + mission/devices/ScexDeviceHandler.cpp | 128 ++++++++++++++++++ mission/devices/ScexDeviceHandler.h | 36 +++++ .../devicedefinitions/ScexDefinitions.cpp | 33 ++++- .../devicedefinitions/ScexDefinitions.h | 33 ++++- 10 files changed, 246 insertions(+), 20 deletions(-) create mode 100644 mission/devices/ScexDeviceHandler.cpp create mode 100644 mission/devices/ScexDeviceHandler.h diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index cd692231..c19a4d0c 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -30,6 +30,7 @@ enum: uint8_t { PDU1_HANDLER = 133, PDU2_HANDLER = 134, ACU_HANDLER = 135, + SCEX_HANDLER = 136, COMMON_SUBSYSTEM_ID_END }; } diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index b958579a..469081cd 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -17,6 +17,7 @@ #include "fsfw/globalfunctions/DleEncoder.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface.h" +#include "mission/devices/devicedefinitions/ScexDefinitions.h" #define GPS_REPLY_WIRETAPPING 0 @@ -28,7 +29,7 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; scexMode = ScexModes::READER_TASK; - currCmd = scex::ScexCmds::FRAM; + currCmd = scex::Cmds::FRAM; if (scexMode == ScexModes::SIMPLE) { auto encodingBuf = new std::array; DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()}; @@ -219,7 +220,7 @@ void UartTestClass::scexPeriodic() { // helper.getTotalPacketCounter()) { nach 2min reader->finish(); if (helper.getCmd() == FRAM) { if (not fileNameSet) { - fileId = random_string(12); + fileId = random_string(6); fileName = "/tmp/scex-fram_" + fileId + ".bin"; fileNameSet = true; } @@ -235,8 +236,9 @@ void UartTestClass::scexPeriodic() { } if (finishCountdown.hasTimedOut()) { + triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); reader->finish(); - sif::warning << "Reader countdown expired" << endl; + sif::warning << "Reader timeout" << endl; cmdDone = true; fileNameSet = false; } @@ -247,7 +249,7 @@ void UartTestClass::scexPeriodic() { sif::info << "Reader is finished" << endl; cmdDone = true; fileNameSet = false; - if (helper.getCmd() == scex::ScexCmds::PING) { + if (helper.getCmd() == scex::Cmds::PING) { cmdSent = false; fileNameSet = true; // to not generate everytime new file } @@ -344,7 +346,7 @@ void UartTestClass::scexSimplePeriodic() { << bytesRead << std::endl; } else if (bytesRead > 0) { dleParser->passData(recBuf.data(), bytesRead); - if (currCmd == ScexCmds::PING) { + if (currCmd == Cmds::PING) { cmdDone = true; cmdSent = false; } @@ -353,8 +355,7 @@ void UartTestClass::scexSimplePeriodic() { } } -int UartTestClass::prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, - size_t* len) { +int UartTestClass::prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBuf, size_t* len) { using namespace scex; // Send command cmdBuf[0] = scex::createCmdByte(cmd, false); diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index ca42a688..efe15dc1 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -39,7 +39,7 @@ class UartTestClass : public TestTask { void scexInit(); void scexPeriodic(); - int prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, size_t* len); + int prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBuf, size_t* len); void scexSimplePeriodic(); void scexSimpleInit(); @@ -54,7 +54,7 @@ class UartTestClass : public TestTask { Countdown finishCountdown = Countdown(180 * 1000); bool cmdSent = false; bool cmdDone = false; - scex::ScexCmds currCmd = scex::ScexCmds::PING; + scex::Cmds currCmd = scex::Cmds::PING; TestModes mode = TestModes::GPS; DleEncoder dleEncoder = DleEncoder(); UartCookie* uartCookie = nullptr; @@ -67,7 +67,7 @@ class UartTestClass : public TestTask { std::array cmdBuf = {}; std::array recBuf = {}; ScexDleParser* dleParser; - scex::ScexCmds cmdHelper; + scex::Cmds cmdHelper; uint8_t recvCnt = 0; }; diff --git a/linux/devices/ScexHelper.cpp b/linux/devices/ScexHelper.cpp index ca29ff65..92a9e24a 100644 --- a/linux/devices/ScexHelper.cpp +++ b/linux/devices/ScexHelper.cpp @@ -23,7 +23,7 @@ ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, } start = *buffer; cmdByteRaw = **buffer; - cmd = static_cast((cmdByteRaw >> 1) & 0b11111); + cmd = static_cast((cmdByteRaw >> 1) & 0b11111); *buffer += 1; packetCounter = **buffer; @@ -35,7 +35,7 @@ ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, payloadLen = (**buffer << 8) | *(*buffer + 1); *buffer += 2; - totalPacketLen = payloadLen + HEADER_LEN + CRC_LEN; + totalPacketLen = payloadLen + scex::HEADER_LEN + scex::CRC_LEN; if (totalPacketLen >= *size) { return STREAM_TOO_SHORT; } @@ -47,7 +47,7 @@ ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, return RETURN_OK; } -scex::ScexCmds ScexHelper::getCmd() const { return cmd; } +scex::Cmds ScexHelper::getCmd() const { return cmd; } uint8_t ScexHelper::getCmdByteRaw() const { return cmdByteRaw; } diff --git a/linux/devices/ScexHelper.h b/linux/devices/ScexHelper.h index a835bd0a..02908514 100644 --- a/linux/devices/ScexHelper.h +++ b/linux/devices/ScexHelper.h @@ -13,8 +13,7 @@ class ScexHelper : public HasReturnvaluesIF, public SerializeIF { public: static const ReturnValue_t INVALID_CRC = HasReturnvaluesIF::makeReturnCode(0, 2); - static constexpr uint8_t HEADER_LEN = 5; - static constexpr uint8_t CRC_LEN = 2; + ScexHelper(); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; @@ -25,7 +24,7 @@ class ScexHelper : public HasReturnvaluesIF, public SerializeIF { friend std::ostream &operator<<(std::ostream &os, const ScexHelper &h); friend std::ofstream &operator<<(std::ofstream &os, const ScexHelper &h); - scex::ScexCmds getCmd() const; + scex::Cmds getCmd() const; uint8_t getCmdByteRaw() const; uint16_t getCrc() const; size_t getExpectedPacketLen() const; @@ -38,7 +37,7 @@ class ScexHelper : public HasReturnvaluesIF, public SerializeIF { const uint8_t *start = nullptr; uint16_t crc = 0; uint8_t cmdByteRaw = 0; - scex::ScexCmds cmd = scex::ScexCmds::INVALID; + scex::Cmds cmd = scex::Cmds::INVALID; int packetCounter = 0; int totalPacketCounter = 0; uint16_t payloadLen = 0; diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index fc013271..9ad299e8 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -18,6 +18,7 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE SusHandler.cpp PayloadPcduHandler.cpp SolarArrayDeploymentHandler.cpp + ScexDeviceHandler.cpp ) add_subdirectory(devicedefinitions) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp new file mode 100644 index 00000000..fe948a7e --- /dev/null +++ b/mission/devices/ScexDeviceHandler.cpp @@ -0,0 +1,128 @@ +#include "ScexDeviceHandler.h" + +#include + +#include "mission/devices/devicedefinitions/ScexDefinitions.h" +#include "fsfw/globalfunctions/CRC.h" +#include + +ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie) + : DeviceHandlerBase(objectId, reader.getObjectId(),cookie), reader(reader) +{ + +} + +void ScexDeviceHandler::doStartUp() { + // mode on + setMode(MODE_ON); +} + +void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { + return RETURN_OK; +} + +ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + return RETURN_OK; +} + +ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { + using namespace scex; + + if (not std::find(VALID_CMDS.begin(), VALID_CMDS.end(), deviceCommand) != VALID_CMDS.end()) { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + if (commandDataLen < 1) { + return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; + } + + switch (deviceCommand) { + case (PING): { + rawPacket = cmdBuf.size(); + + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {nullptr, 0}); + return RETURN_OK; + } + case (FRAM): { + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {nullptr, 0}); + return RETURN_OK; + } + case (ION_CMD): { + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {nullptr, 0}); + return RETURN_OK; + } + case (TEMP_CMD): { + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {nullptr, 0}); + return RETURN_OK; + } + case (ONE_CELL): { + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandData - 1}); + return RETURN_OK; + } + case (ALL_CELLS_CMD): { + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandData - 1}); + return RETURN_OK; + } + case (EXP_STATUS_CMD): { + prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {nullptr, 0}); + return RETURN_OK; + } + } + return RETURN_OK; +} + +void ScexDeviceHandler::fillCommandAndReplyMap() { + insertInCommandAndReplyMap(scex::Cmds::PING, 3); + insertInCommandAndReplyMap(scex::Cmds::ION_CMD, 3); + insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3); + insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); + + insertInCommandMap(scex::Cmds::ALL_CELLS_CMD); + insertInCommandMap(scex::Cmds::ONE_CELL); + insertInCommandMap(scex::Cmds::FRAM); + + insertInReplyMap(scex::Cmds::ERROR_REPLY, 3); +} + +ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, + DeviceCommandId_t* foundId, size_t* foundLen) { + //helper.deSerialize(blabla); + //crc check + + *foundId = helper.getCmd(); + *foundLen = remainingSize; + + return RETURN_OK; +} + +ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { + //cmd auswertung (in file reinschreiben) + return RETURN_OK; +} + +uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return RETURN_OK; +} + +ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { + return RETURN_OK; +} + +ReturnValue_t ScexDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return RETURN_OK; +} + + + +void ScexDeviceHandler::modeChanged() {} diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h new file mode 100644 index 00000000..5058ed3b --- /dev/null +++ b/mission/devices/ScexDeviceHandler.h @@ -0,0 +1,36 @@ +#ifndef MISSION_DEVICES_SCEXDEVICEHANDLER_H_ +#define MISSION_DEVICES_SCEXDEVICEHANDLER_H_ + +#include +#include +#include + +class ScexDeviceHandler : public DeviceHandlerBase { + public: + // ctor vervollständigen + ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie); + private: + std::array cmdBuf = {}; + + // DeviceHandlerBase private function implementation + void doStartUp() override; + void doShutDown() override; + ScexHelper helper; + ScexUartReader& reader; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + void fillCommandAndReplyMap() override; + ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; + + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; + void modeChanged() override; +}; + +#endif /* MISSION_DEVICES_SCEXDEVICEHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/ScexDefinitions.cpp b/mission/devices/devicedefinitions/ScexDefinitions.cpp index 1e39f414..c202dd5c 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.cpp +++ b/mission/devices/devicedefinitions/ScexDefinitions.cpp @@ -1,5 +1,36 @@ #include "ScexDefinitions.h" -uint8_t scex::createCmdByte(ScexCmds cmd, bool tempCheck) { +#include + +#include + +uint8_t scex::createCmdByte(Cmds cmd, bool tempCheck) { return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; } + +ReturnValue_t scex::prepareScexCmd(scex::Cmds cmd, bool tempCheck, + std::pair cmdBufPair, size_t& cmdLen, + std::pair usrDataPair) { + using namespace scex; + uint8_t* cmdBuf = cmdBufPair.first; + const uint8_t* userData = usrDataPair.first; + // Send command + if (cmdBuf == nullptr or (cmdBufPair.second < usrDataPair.second + HEADER_LEN + CRC_LEN) or + (usrDataPair.second > 0 and userData == nullptr)) { + cmdLen = 0; + return HasReturnvaluesIF::RETURN_FAILED; + } + cmdBuf[0] = scex::createCmdByte(cmd, tempCheck); + // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each + // telecommand so far + cmdBuf[1] = 1; + cmdBuf[2] = 1; + cmdBuf[3] = (usrDataPair.second >> 8) & 0xff; + cmdBuf[4] = usrDataPair.second & 0xff; + std::memcpy(cmdBuf + HEADER_LEN, userData, usrDataPair.second); + uint16_t crc = CRC::crc16ccitt(cmdBuf, usrDataPair.second + HEADER_LEN); + cmdBuf[usrDataPair.second + HEADER_LEN] = (crc >> 8) & 0xff; + cmdBuf[usrDataPair.second + HEADER_LEN + 1] = crc & 0xff; + cmdLen = usrDataPair.second + HEADER_LEN + CRC_LEN; + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/mission/devices/devicedefinitions/ScexDefinitions.h b/mission/devices/devicedefinitions/ScexDefinitions.h index f479981e..70426085 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.h +++ b/mission/devices/devicedefinitions/ScexDefinitions.h @@ -1,17 +1,46 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SCEXDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SCEXDEFINITIONS_H_ +#include +#include +#include + #include +#include // Definitions for the Solar Cell Experiment namespace scex { -enum ScexCmds : uint8_t { PING = 0b00111, ONE_CELL = 0b00110, FRAM = 0b00001, INVALID = 255 }; +static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SCEX_HANDLER; + +static constexpr Event MISSING_PACKET = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + +static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + +enum Cmds : DeviceCommandId_t { + PING = 0b00111, + ALL_CELLS_CMD = 0b00101, + ONE_CELL = 0b00110, + FRAM = 0b00001, + EXP_STATUS_CMD = 0b00010, + TEMP_CMD = 0b00011, + ION_CMD = 0b00100, + ERROR_REPLY = 0b01000, + INVALID = 255 +}; + +static const std::vector VALID_CMDS = { + PING, ALL_CELLS_CMD, ONE_CELL, FRAM, EXP_STATUS_CMD, TEMP_CMD, ION_CMD}; + +static constexpr uint8_t HEADER_LEN = 5; +static constexpr uint8_t CRC_LEN = 2; static constexpr uint8_t IDLE_BIT_0_DEF_STATE = 0; static constexpr uint8_t IDLE_BIT_1_DEF_STATE = 1; -uint8_t createCmdByte(ScexCmds cmd, bool tempCheck); +uint8_t createCmdByte(Cmds cmd, bool tempCheck); +ReturnValue_t prepareScexCmd(scex::Cmds cmd, bool tempCheck, std::pair cmdBufPair, + size_t& cmdLen, std::pair usrDataPair); } // namespace scex -- 2.43.0 From 7179d9dec314f35ccfa48bb1042754fb5bf8ec50 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 19 May 2022 09:59:33 +0200 Subject: [PATCH 24/48] deSerialize --- mission/devices/ScexDeviceHandler.cpp | 36 ++++++++++++++++----------- mission/devices/ScexDeviceHandler.h | 10 +++++--- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index fe948a7e..8b80bc0e 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -1,16 +1,16 @@ #include "ScexDeviceHandler.h" +#include + #include -#include "mission/devices/devicedefinitions/ScexDefinitions.h" #include "fsfw/globalfunctions/CRC.h" -#include +#include "mission/devices/devicedefinitions/ScexDefinitions.h" ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie) - : DeviceHandlerBase(objectId, reader.getObjectId(),cookie), reader(reader) -{ + : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), reader(reader) {} -} +ScexDeviceHandler::~ScexDeviceHandler() {} void ScexDeviceHandler::doStartUp() { // mode on @@ -27,9 +27,9 @@ ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* return RETURN_OK; } -ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t* commandData, - size_t commandDataLen) { +ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( + scex::Cmds deviceCommand, // DeviceCommandId_t + const uint8_t* commandData, size_t commandDataLen) { using namespace scex; if (not std::find(VALID_CMDS.begin(), VALID_CMDS.end(), deviceCommand) != VALID_CMDS.end()) { @@ -96,17 +96,25 @@ void ScexDeviceHandler::fillCommandAndReplyMap() { ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { - //helper.deSerialize(blabla); - //crc check + uint8_t* decodedPacket = nullptr; + size_t len = 0; - *foundId = helper.getCmd(); - *foundLen = remainingSize; + const uint8_t* helperPtr = decodedPacket; + ReturnValue_t result = helper.deSerialize(&helperPtr, &len); + if (result == ScexHelper::INVALID_CRC) { + sif::warning << "CRC invalid" << std::endl; + } + sif::info << helper << std::endl; + // crc check + + *foundId = helper.getCmd(); + *foundLen = remainingSize; return RETURN_OK; } ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { - //cmd auswertung (in file reinschreiben) + // cmd auswertung (in file reinschreiben) return RETURN_OK; } @@ -123,6 +131,4 @@ ReturnValue_t ScexDeviceHandler::initializeLocalDataPool(localpool::DataPool& lo return RETURN_OK; } - - void ScexDeviceHandler::modeChanged() {} diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index 5058ed3b..f5a46971 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -7,8 +7,10 @@ class ScexDeviceHandler : public DeviceHandlerBase { public: - // ctor vervollständigen - ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie); + // ctor vervollständigen + ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie); + virtual ~ScexDeviceHandler(); + private: std::array cmdBuf = {}; @@ -16,10 +18,10 @@ class ScexDeviceHandler : public DeviceHandlerBase { void doStartUp() override; void doShutDown() override; ScexHelper helper; - ScexUartReader& reader; + ScexUartReader &reader; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + ReturnValue_t buildCommandFromCommand(scex::Cmds deviceCommand, const uint8_t *commandData, size_t commandDataLen) override; void fillCommandAndReplyMap() override; ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, -- 2.43.0 From b4e1451501ab51dc9654799e5ff0f2cb80cb7d69 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 19 May 2022 10:16:46 +0200 Subject: [PATCH 25/48] ScexDeviceHandler DeviceReply --- mission/devices/ScexDeviceHandler.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 8b80bc0e..407c470e 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -3,10 +3,13 @@ #include #include +#include #include "fsfw/globalfunctions/CRC.h" #include "mission/devices/devicedefinitions/ScexDefinitions.h" +using std::ofstream; + ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie) : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), reader(reader) {} @@ -104,8 +107,12 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai if (result == ScexHelper::INVALID_CRC) { sif::warning << "CRC invalid" << std::endl; } - sif::info << helper << std::endl; + // crc check + if (result == ScexHelper::INVALID_CRC) { + sif::warning << "CRC invalid" << std::endl; + } + sif::info << helper << std::endl; *foundId = helper.getCmd(); *foundLen = remainingSize; @@ -115,6 +122,15 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { // cmd auswertung (in file reinschreiben) + using namespace scex; + if (helper.getCmd() == PING) { + ofstream out("/tmp/scex-ping.bin", ofstream::binary); + if (out.bad()) { + sif::warning << "bad" << std::endl; + } + out << helper; + } + // was alles hier rein? return RETURN_OK; } -- 2.43.0 From e8882b11cf65cecda633af290dc2baa57cbbea77 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 19 May 2022 11:56:59 +0200 Subject: [PATCH 26/48] ScexDeviceHandler --- linux/devices/ScexHelper.cpp | 1 + linux/devices/ScexHelper.h | 1 + mission/devices/ScexDeviceHandler.cpp | 117 +++++++++++++++++++++----- mission/devices/ScexDeviceHandler.h | 18 +++- 4 files changed, 113 insertions(+), 24 deletions(-) diff --git a/linux/devices/ScexHelper.cpp b/linux/devices/ScexHelper.cpp index 92a9e24a..3e61d346 100644 --- a/linux/devices/ScexHelper.cpp +++ b/linux/devices/ScexHelper.cpp @@ -35,6 +35,7 @@ ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, payloadLen = (**buffer << 8) | *(*buffer + 1); *buffer += 2; + payloadStart = *buffer; totalPacketLen = payloadLen + scex::HEADER_LEN + scex::CRC_LEN; if (totalPacketLen >= *size) { return STREAM_TOO_SHORT; diff --git a/linux/devices/ScexHelper.h b/linux/devices/ScexHelper.h index 02908514..eb258568 100644 --- a/linux/devices/ScexHelper.h +++ b/linux/devices/ScexHelper.h @@ -41,6 +41,7 @@ class ScexHelper : public HasReturnvaluesIF, public SerializeIF { int packetCounter = 0; int totalPacketCounter = 0; uint16_t payloadLen = 0; + const uint8_t *payloadStart = 0; size_t totalPacketLen = 0; }; diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 407c470e..b45e603c 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -1,6 +1,7 @@ #include "ScexDeviceHandler.h" #include +#include #include #include @@ -10,8 +11,9 @@ using std::ofstream; -ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie) - : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), reader(reader) {} +ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie, + SdCardMountedIF* sdcMan) + : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), reader(reader), sdcMan(sdcMan) {} ScexDeviceHandler::~ScexDeviceHandler() {} @@ -31,11 +33,12 @@ ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* } ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( - scex::Cmds deviceCommand, // DeviceCommandId_t + DeviceCommandId_t deviceCommand, // DeviceCommandId_t const uint8_t* commandData, size_t commandDataLen) { using namespace scex; - if (not std::find(VALID_CMDS.begin(), VALID_CMDS.end(), deviceCommand) != VALID_CMDS.end()) { + auto cmdTyped = static_cast(deviceCommand); + if (std::find(VALID_CMDS.begin(), VALID_CMDS.end(), deviceCommand) == VALID_CMDS.end()) { return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } if (commandDataLen < 1) { @@ -44,39 +47,38 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( switch (deviceCommand) { case (PING): { - rawPacket = cmdBuf.size(); - - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + rawPacket = cmdBuf.data(); + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; } case (FRAM): { - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; } case (ION_CMD): { - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; } case (TEMP_CMD): { - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; } case (ONE_CELL): { - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {commandData + 1, commandData - 1}); + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandDataLen - 1}); return RETURN_OK; } case (ALL_CELLS_CMD): { - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {commandData + 1, commandData - 1}); + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandDataLen - 1}); return RETURN_OK; } case (EXP_STATUS_CMD): { - prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; } @@ -111,9 +113,8 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai // crc check if (result == ScexHelper::INVALID_CRC) { sif::warning << "CRC invalid" << std::endl; + return result; } - sif::info << helper << std::endl; - *foundId = helper.getCmd(); *foundLen = remainingSize; @@ -123,14 +124,86 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { // cmd auswertung (in file reinschreiben) using namespace scex; - if (helper.getCmd() == PING) { - ofstream out("/tmp/scex-ping.bin", ofstream::binary); + + auto oneFileHandler = [&](std::string cmdName) { + fileId = random_string(6); + std::ostringstream oss("/tmp/scex-"); + oss << cmdName << fileId << ".bin"; + fileName = oss.str(); + ofstream out(fileName, ofstream::binary); if (out.bad()) { - sif::warning << "bad" << std::endl; + sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName + << std::endl; + return RETURN_FAILED; + } + if (debugMode) { + out << helper; + } + return RETURN_OK; + }; + auto multiFileHandler = [&](std::string cmdName) { + if (helper.getPacketCounter() == 1) { + // countdown starten + finishCountdown.resetTimer(); + fileId = random_string(6); + std::ostringstream oss("/tmp/scex-"); + oss << cmdName << fileId << ".bin"; + fileName = oss.str(); + ofstream out(fileName, + ofstream::binary); // neues file anlegen + } else { + ofstream out(fileName, + ofstream::binary | ofstream::app); // an bestehendes file appenden + if (debugMode) { + out << helper; + } + } + if (finishCountdown.hasTimedOut()) { + triggerEvent(scex::EXPERIMENT_TIMEDOUT, id, 0); + reader.finish(); + sif::warning << "ScexDeviceHandler: Reader timeout" << std::endl; + // cmdDone = true; + fileNameSet = false; + } + return RETURN_OK; + }; + switch (id) { + case (PING): { + return oneFileHandler("ping_"); + } + case (ION_CMD): { + return oneFileHandler("ion_"); + } + case (TEMP_CMD): { + return oneFileHandler("temp_"); + } + case (EXP_STATUS_CMD): { + return oneFileHandler("exp_status_"); + } + case (FRAM): { + return multiFileHandler("fram_"); + } + case (ONE_CELL): { + return multiFileHandler("one_cell_"); + } + case (ALL_CELLS_CMD): { + return multiFileHandler("all_cell_"); + } + default: + // Unknown DeviceCommand + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + + if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { + reader.finish(); + sif::info << "Reader is finished" << std::endl; + // cmdDone = true; + fileNameSet = false; + if (helper.getCmd() == scex::Cmds::PING) { + // cmdSent = false; + fileNameSet = true; // to not generate everytime new file } - out << helper; } - // was alles hier rein? return RETURN_OK; } diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index f5a46971..a719fc49 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -5,15 +5,29 @@ #include #include +class SdCardMountedIF; + class ScexDeviceHandler : public DeviceHandlerBase { public: // ctor vervollständigen - ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie); + ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie, + SdCardMountedIF *sdcMan); virtual ~ScexDeviceHandler(); private: std::array cmdBuf = {}; + std::string fileId = ""; + std::string fileName = ""; + bool fileNameSet = false; + bool debugMode = true; + + scex::Cmds currCmd = scex::Cmds::PING; + SdCardMountedIF *sdcMan = nullptr; + Countdown finishCountdown = Countdown(180 * 1000); + + std::string random_string(std::string::size_type length); + // DeviceHandlerBase private function implementation void doStartUp() override; void doShutDown() override; @@ -21,7 +35,7 @@ class ScexDeviceHandler : public DeviceHandlerBase { ScexUartReader &reader; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand(scex::Cmds deviceCommand, const uint8_t *commandData, + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) override; void fillCommandAndReplyMap() override; ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, -- 2.43.0 From 2f4d44433d97721414ce6cfa8a54fd3d638a24c2 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 24 May 2022 18:38:34 +0200 Subject: [PATCH 27/48] scexDeviceHandler::interpretDeviceReply --- mission/devices/ScexDeviceHandler.cpp | 64 +++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index b45e603c..6c3aa17b 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -32,9 +32,9 @@ ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* return RETURN_OK; } -ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, // DeviceCommandId_t - const uint8_t* commandData, size_t commandDataLen) { +ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t* commandData, + size_t commandDataLen) { using namespace scex; auto cmdTyped = static_cast(deviceCommand); @@ -52,7 +52,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( {nullptr, 0}); return RETURN_OK; } - case (FRAM): { + case (EXP_STATUS_CMD): { prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; @@ -67,6 +67,11 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( {nullptr, 0}); return RETURN_OK; } + case (FRAM): { + prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandDataLen - 1}); + return RETURN_OK; + } case (ONE_CELL): { prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}); @@ -77,11 +82,6 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand( {commandData + 1, commandDataLen - 1}); return RETURN_OK; } - case (EXP_STATUS_CMD): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {nullptr, 0}); - return RETURN_OK; - } } return RETURN_OK; } @@ -106,13 +106,9 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai const uint8_t* helperPtr = decodedPacket; ReturnValue_t result = helper.deSerialize(&helperPtr, &len); - if (result == ScexHelper::INVALID_CRC) { - sif::warning << "CRC invalid" << std::endl; - } - // crc check if (result == ScexHelper::INVALID_CRC) { - sif::warning << "CRC invalid" << std::endl; + sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl; return result; } *foundId = helper.getCmd(); @@ -142,29 +138,36 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons return RETURN_OK; }; auto multiFileHandler = [&](std::string cmdName) { - if (helper.getPacketCounter() == 1) { + if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { // countdown starten finishCountdown.resetTimer(); + fileId = random_string(6); std::ostringstream oss("/tmp/scex-"); oss << cmdName << fileId << ".bin"; fileName = oss.str(); - ofstream out(fileName, - ofstream::binary); // neues file anlegen + fileNameSet = true; + ofstream out(fileName, ofstream::binary); + if (out.bad()) { + sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName + << std::endl; + return RETURN_FAILED; + } } else { ofstream out(fileName, - ofstream::binary | ofstream::app); // an bestehendes file appenden + ofstream::binary | ofstream::app); // append if (debugMode) { out << helper; } + + if (finishCountdown.hasTimedOut()) { + triggerEvent(scex::EXPERIMENT_TIMEDOUT, id, 0); + reader.finish(); + sif::warning << "ScexDeviceHandler::interpretDiviceReply: Reader timeout" << std::endl; + fileNameSet = false; + } } - if (finishCountdown.hasTimedOut()) { - triggerEvent(scex::EXPERIMENT_TIMEDOUT, id, 0); - reader.finish(); - sif::warning << "ScexDeviceHandler: Reader timeout" << std::endl; - // cmdDone = true; - fileNameSet = false; - } + return RETURN_OK; }; switch (id) { @@ -193,17 +196,14 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons // Unknown DeviceCommand return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { reader.finish(); - sif::info << "Reader is finished" << std::endl; - // cmdDone = true; - fileNameSet = false; - if (helper.getCmd() == scex::Cmds::PING) { - // cmdSent = false; - fileNameSet = true; // to not generate everytime new file + if (id != PING) { + sif::info << "Reader is finished" << std::endl; + fileNameSet = false; } } + return RETURN_OK; } -- 2.43.0 From 44d36587aa2d1435fc85f8adfaa9bd20f7317083 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Wed, 25 May 2022 10:51:22 +0200 Subject: [PATCH 28/48] precised printouts --- linux/boardtest/UartTestClass.cpp | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 469081cd..8361ba86 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -64,13 +64,13 @@ void UartTestClass::gpsInit() { #if RPI_TEST_GPS_HANDLER == 1 int result = lwgps_init(&gpsData); if (result == 0) { - sif::warning << "lwgps_init error: " << result << std::endl; + sif::warning << "UartTestClass::gpsInit: lwgps_init error: " << result << std::endl; } /* Get file descriptor */ serialPort = open("/dev/serial0", O_RDWR); if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + sif::warning << "UartTestClass::gpsInit: open call failed with error [" << errno << ", " << strerror(errno) << std::endl; } /* Setting up UART parameters */ @@ -99,7 +99,7 @@ void UartTestClass::gpsInit() { cfsetispeed(&tty, B9600); cfsetospeed(&tty, B9600); if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + sif::warning << "UartTestClass::gpsInit: tcsetattr call failed with error [" << errno << ", " << strerror(errno) << std::endl; ; } @@ -115,11 +115,11 @@ void UartTestClass::gpsPeriodic() { bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), static_cast(recBuf.size())); if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno + sif::warning << "UartTestClass::gpsPeriodic: read call failed with error [" << errno << ", " << strerror(errno) << "]" << std::endl; break; } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: " + sif::debug << "UartTestClass::gpsPeriodic: " "recv buffer might not be large enough" << std::endl; } else if (bytesRead > 0) { @@ -129,7 +129,7 @@ void UartTestClass::gpsPeriodic() { #endif int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); if (result == 0) { - sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl; + sif::warning << "UartTestClass::gpsPeriodic: lwgps_process error" << std::endl; } recvCnt++; if (recvCnt == 6) { @@ -163,7 +163,7 @@ void UartTestClass::scexInit() { reader->setDebugMode(false); ReturnValue_t result = reader->initializeInterface(uartCookie); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader " + sif::warning << "UartTestClass::scexInit: Initializing SCEX reader " "UART IF failed" << std::endl; } @@ -199,7 +199,7 @@ void UartTestClass::scexPeriodic() { const uint8_t* helperPtr = decodedPacket; result = helper.deSerialize(&helperPtr, &len); if (result == ScexHelper::INVALID_CRC) { - sif::warning << "CRC invalid" << std::endl; + sif::warning << "UartTestClass::scexPeriodic: CRC invalid" << std::endl; } sif::info << helper << endl; @@ -238,7 +238,7 @@ void UartTestClass::scexPeriodic() { if (finishCountdown.hasTimedOut()) { triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); reader->finish(); - sif::warning << "Reader timeout" << endl; + sif::warning << "UartTestClass::scexPeriodic: Reader timeout" << endl; cmdDone = true; fileNameSet = false; } @@ -246,7 +246,7 @@ void UartTestClass::scexPeriodic() { if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { reader->finish(); - sif::info << "Reader is finished" << endl; + sif::info << "UartTestClass::scexPeriodic: Reader is finished" << endl; cmdDone = true; fileNameSet = false; if (helper.getCmd() == scex::Cmds::PING) { @@ -268,7 +268,7 @@ void UartTestClass::scexSimpleInit() { /* Get file descriptor */ serialPort = open(devname.c_str(), O_RDWR); if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + sif::warning << "UartTestClass::scexSimpleInit: Open call failed with error [" << errno << ", " << strerror(errno) << std::endl; return; } @@ -291,12 +291,12 @@ void UartTestClass::scexSimpleInit() { // Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here. #if !defined(XIPHOS_Q7S) if (cfsetispeed(&tty, B57600) != 0) { - sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl; + sif::warning << "UartTestClass::scexSimpleInit: Setting baud rate failed" << std::endl; } #endif if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) + sif::warning << "UartTestClass::scexSimpleInit: tcsetattr call failed with error [" << errno << ", " << strerror(errno) << std::endl; } // Flush received and unread data @@ -315,7 +315,7 @@ void UartTestClass::scexSimplePeriodic() { prepareScexCmd(currCmd, false, tmpCmdBuf, &len); result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + sif::warning << "UartTestClass::scexSimplePeriodic: Encoding failed" << std::endl; return; } if (result != 0) { @@ -323,7 +323,7 @@ void UartTestClass::scexSimplePeriodic() { }; size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen); if (bytesWritten != encodedLen) { - sif::warning << "Sending command to solar experiment failed" << std::endl; + sif::warning << "UartTestClass::scexSimplePeriodic: Sending command to solar experiment failed" << std::endl; } cmdSent = true; cmdDone = false; @@ -335,13 +335,13 @@ void UartTestClass::scexSimplePeriodic() { bytesRead = read(serialPort, reinterpret_cast(recBuf.data()), static_cast(recBuf.size())); if (bytesRead == 0) { - sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl; + sif::warning << "UartTestClass::scexSimplePeriodic: Reading SCEX: Timeout or no bytes read" << std::endl; } else if (bytesRead < 0) { - sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" + sif::warning << "UartTestClass::scexSimplePeriodic: read call failed with error [" << errno << ", " << strerror(errno) << "]" << std::endl; break; } else if (bytesRead >= static_cast(recBuf.size())) { - sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large " + sif::debug << "UartTestClass::scexSimplePeriodic: recv buffer might not be large " "enough, bytes read:" << bytesRead << std::endl; } else if (bytesRead > 0) { @@ -383,7 +383,7 @@ void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) { } void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { - sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; + sif::info << "UartTestClass::handleFoundDlePacket: Detected DLE encoded packet with decoded size " << len << std::endl; } std::string UartTestClass::random_string(std::string::size_type length) { -- 2.43.0 From 1276cc2dc6b81582827c1e021b83c69e4e3fdee9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 May 2022 12:04:27 +0200 Subject: [PATCH 29/48] scex additions --- bsp_linux_board/InitMission.cpp | 26 ++++++++++++++++++++++++++ bsp_linux_board/OBSWConfig.h.in | 7 +++++++ bsp_linux_board/ObjectFactory.cpp | 4 ++++ bsp_linux_board/definitions.h | 6 ++++++ common/config/commonObjects.h | 1 + linux/ObjectFactory.cpp | 5 +++++ linux/ObjectFactory.h | 2 ++ linux/obc/PdecHandler.cpp | 1 + 8 files changed, 52 insertions(+) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 0fa7a4f6..27a435b4 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -1,3 +1,4 @@ +#include #include "InitMission.h" #include @@ -77,6 +78,28 @@ void initmission::initTasks() { sif::error << "Add component TMTC Polling failed" << std::endl; } +#if OBSW_ADD_SCEX == 1 + PeriodicTaskIF* scexDevHandler = factory->createPeriodicTask( + "SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); + result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); +#endif + /* PUS Services */ std::vector pusTasks; createPusTasks(*factory, missedDeadlineFunc, pusTasks); @@ -109,6 +132,9 @@ void initmission::initTasks() { #endif /* OBSW_ADD_TEST_CODE == 1 */ taskStarter(pstTasks, "PST Tasks"); +#if OBSW_ADD_SCEX == 1 + scexDevHandler->startTask(); +#endif #if OBSW_ADD_TEST_PST == 1 if (startTestPst) { pstTestTask->startTask(); diff --git a/bsp_linux_board/OBSWConfig.h.in b/bsp_linux_board/OBSWConfig.h.in index d8a981bd..398cf19e 100644 --- a/bsp_linux_board/OBSWConfig.h.in +++ b/bsp_linux_board/OBSWConfig.h.in @@ -28,6 +28,7 @@ #define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_PL_PCDU 0 #define OBSW_ADD_TMP_DEVICES 0 +#define OBSW_ADD_SCEX 1 #define OBSW_ADD_RAD_SENSORS 0 #define OBSW_ADD_SYRLINKS 0 #define OBSW_STAR_TRACKER_GROUND_CONFIG 1 @@ -102,6 +103,12 @@ /*******************************************************************/ #cmakedefine EIVE_BUILD_GPSD_GPS_HANDLER +#define OBSW_USE_CCSDS_IP_CORE 0 +// Set to 1 if all telemetry should be sent to the PTME IP Core +#define OBSW_TM_TO_PTME 0 +// Set to 1 if telecommands are received via the PDEC IP Core +#define OBSW_TC_FROM_PDEC 0 + #cmakedefine LIBGPS_VERSION_MAJOR @LIBGPS_VERSION_MAJOR@ #cmakedefine LIBGPS_VERSION_MINOR @LIBGPS_VERSION_MINOR@ diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 47f80936..6ff4947b 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -82,6 +82,10 @@ void ObjectFactory::produce(void* args) { #endif #endif +#if OBSW_ADD_SCEX == 1 + createScexComponents(uart::DEV, pwrSwitcher); +#endif + #if OBSW_ADD_SUN_SENSORS == 1 createSunSensorComponents(gpioIF, spiComIF, pwrSwitcher, spi::DEV); #endif diff --git a/bsp_linux_board/definitions.h b/bsp_linux_board/definitions.h index 1b6814f4..83aeb847 100644 --- a/bsp_linux_board/definitions.h +++ b/bsp_linux_board/definitions.h @@ -13,6 +13,12 @@ static constexpr char DEV[] = "/dev/spidev0.1"; } +namespace uart { + +static constexpr char DEV[] = "/dev/serial0"; + +} + /* Adapt these values accordingly */ namespace gpio { static constexpr uint8_t MGM_0_BCM_PIN = 17; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 4a4594f4..1fcd6aaa 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -57,6 +57,7 @@ enum commonObjects : uint32_t { PLOC_MPSOC_HANDLER = 0x44330015, PLOC_SUPERVISOR_HANDLER = 0x44330016, PLOC_SUPERVISOR_HELPER = 0x44330017, + SCEX = 0x44330032, SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, HEATER_HANDLER = 0x444100A4, diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index f84cf52f..8192d215 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -319,8 +319,13 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, #endif // OBSW_ADD_RTD_DEVICES == 1 } +void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF *pwrSwitcher) { +} + +du findest void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl; } } + diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index a5642729..41040fe7 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -15,6 +15,8 @@ void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitc void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher, SpiComIF* comIF); +void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher); + void gpioChecker(ReturnValue_t result, std::string output); } // namespace ObjectFactory diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 4c8beeed..9bc95fb8 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,4 +1,5 @@ #include "PdecHandler.h" +#include "OBSWConfig.h" #include #include -- 2.43.0 From 5c91697cf19092bee579bf043e5d205a63db6724 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 May 2022 12:09:01 +0200 Subject: [PATCH 30/48] removed accidental typed stuff --- linux/ObjectFactory.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 8192d215..cc5e7079 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -322,7 +322,6 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF *pwrSwitcher) { } -du findest void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl; -- 2.43.0 From b306116eaca2a7684b538fc0bb7a922038335d17 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 May 2022 12:09:36 +0200 Subject: [PATCH 31/48] remove duplicate declarations --- linux/fsfwconfig/objects/systemObjectList.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index 3e9653d6..165df2d4 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -52,11 +52,6 @@ enum sourceObjects : uint32_t { SCEX_UART_READER = 0x49010006, /* Custom device handler */ - PCDU_HANDLER = 0x442000A1, - SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, - SYRLINKS_HK_HANDLER = 0x445300A3, - HEATER_HANDLER = 0x444100A4, - RAD_SENSOR = 0x443200A5, SPI_RW_COM_IF = 0x49020005, SPI_RTD_COM_IF = 0x49020006, -- 2.43.0 From 1f616a101de88c0c8abd709e607debaf9f27bdcc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 May 2022 12:10:56 +0200 Subject: [PATCH 32/48] add scex preproc define to OBSWConfig.h.in --- CMakeLists.txt | 3 +++ bsp_q7s/OBSWConfig.h.in | 1 + 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef87352e..77379956 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,6 +119,9 @@ set(OBSW_ADD_GOMSPACE_PCDU set(OBSW_ADD_RW ${INIT_VAL} CACHE STRING "Add RW modules") +set(OBSW_ADD_SCEX_DEVICE + ${INIT_VAL} + CACHE STRING "Add Solar Cell Experiment module") # ############################################################################## # Pre-Sources preparation diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index ed321f8c..fc9cefca 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -33,6 +33,7 @@ #define OBSW_ADD_ACS_HANDLERS @OBSW_ADD_ACS_HANDLERS@ #define OBSW_ADD_RW @OBSW_ADD_RW@ #define OBSW_ADD_RTD_DEVICES @OBSW_ADD_RTD_DEVICES@ +#define OBSW_ADD_SCEX_DEVICE @OBSW_ADD_SCEX_DEVICE@ #define OBSW_ADD_TMP_DEVICES @OBSW_ADD_TMP_DEVICES@ #define OBSW_ADD_RAD_SENSORS @OBSW_ADD_RAD_SENSORS@ #define OBSW_ADD_PL_PCDU @OBSW_ADD_PL_PCDU@ -- 2.43.0 From 24cb5558494ddf3123fd4a3a8e4ff1d9389a5b94 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 29 May 2022 17:52:13 +0200 Subject: [PATCH 33/48] update --- bsp_linux_board/InitMission.cpp | 2 +- linux/ObjectFactory.cpp | 10 +++++++-- linux/devices/ScexDleParser.cpp | 7 +++--- linux/devices/ScexDleParser.h | 12 ++++++++-- linux/obc/PdecHandler.cpp | 2 +- mission/devices/ScexDeviceHandler.cpp | 22 ++++++++++++++++++- .../devicedefinitions/ScexDefinitions.cpp | 4 ++-- .../devicedefinitions/ScexDefinitions.h | 3 ++- 8 files changed, 48 insertions(+), 14 deletions(-) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index ea44c399..db8dd80f 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -1,6 +1,6 @@ -#include #include "InitMission.h" +#include #include #include #include diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index cc5e7079..bb8b183f 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -319,7 +320,13 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, #endif // OBSW_ADD_RTD_DEVICES == 1 } -void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF *pwrSwitcher) { +void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher) { + // objekte anlegen + SdCardMountedIF* sdcMan = nullptr; + CookieIF* cookie = new CookieIF; + + auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER); + new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, sdcMan); } void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { @@ -327,4 +334,3 @@ void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl; } } - diff --git a/linux/devices/ScexDleParser.cpp b/linux/devices/ScexDleParser.cpp index 3a95e497..43405fc5 100644 --- a/linux/devices/ScexDleParser.cpp +++ b/linux/devices/ScexDleParser.cpp @@ -1,6 +1,5 @@ #include "ScexDleParser.h" -ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, - BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, - void *args) - : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args) {} +ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, + void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args) {}; +ScexDleParser::~ScexDleParser() {}; diff --git a/linux/devices/ScexDleParser.h b/linux/devices/ScexDleParser.h index eab7e9c1..7fbd73db 100644 --- a/linux/devices/ScexDleParser.h +++ b/linux/devices/ScexDleParser.h @@ -3,10 +3,18 @@ #include + class ScexDleParser : public DleParser { public: - ScexDleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPair encodedBuf, - BufPair decodedBuf, UserHandler handler, void* args); + ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, + BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, + void *args); +// ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, +// BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, +// void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args){} + + virtual ~ScexDleParser(); + private: }; #endif /* LINUX_DEVICES_SCEXDLEPARSER_H_ */ diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 9bc95fb8..48816512 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,5 +1,4 @@ #include "PdecHandler.h" -#include "OBSWConfig.h" #include #include @@ -7,6 +6,7 @@ #include #include +#include "OBSWConfig.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 6c3aa17b..de4b63d0 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -8,6 +8,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "mission/devices/devicedefinitions/ScexDefinitions.h" +#include using std::ofstream; @@ -47,7 +48,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic switch (deviceCommand) { case (PING): { - rawPacket = cmdBuf.data(); + //rawPacket = cmdBuf.data(); prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; @@ -220,4 +221,23 @@ ReturnValue_t ScexDeviceHandler::initializeLocalDataPool(localpool::DataPool& lo return RETURN_OK; } +std::string ScexDeviceHandler::random_string(std::string::size_type length) { + static auto& chrs = + "0123456789" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + thread_local static std::mt19937 rg{std::random_device{}()}; + thread_local static std::uniform_int_distribution pick(0, + sizeof(chrs) - 2); + + std::string s; + + s.reserve(length); + + while (length--) s += chrs[pick(rg)]; + + return s; +} + void ScexDeviceHandler::modeChanged() {} diff --git a/mission/devices/devicedefinitions/ScexDefinitions.cpp b/mission/devices/devicedefinitions/ScexDefinitions.cpp index c202dd5c..7b8f49dd 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.cpp +++ b/mission/devices/devicedefinitions/ScexDefinitions.cpp @@ -8,7 +8,7 @@ uint8_t scex::createCmdByte(Cmds cmd, bool tempCheck) { return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; } -ReturnValue_t scex::prepareScexCmd(scex::Cmds cmd, bool tempCheck, +ReturnValue_t scex::prepareScexCmd(Cmds cmd, bool tempCheck, std::pair cmdBufPair, size_t& cmdLen, std::pair usrDataPair) { using namespace scex; @@ -20,7 +20,7 @@ ReturnValue_t scex::prepareScexCmd(scex::Cmds cmd, bool tempCheck, cmdLen = 0; return HasReturnvaluesIF::RETURN_FAILED; } - cmdBuf[0] = scex::createCmdByte(cmd, tempCheck); + cmdBuf[0] = createCmdByte(cmd, tempCheck); // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each // telecommand so far cmdBuf[1] = 1; diff --git a/mission/devices/devicedefinitions/ScexDefinitions.h b/mission/devices/devicedefinitions/ScexDefinitions.h index 70426085..55264f3e 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.h +++ b/mission/devices/devicedefinitions/ScexDefinitions.h @@ -39,7 +39,8 @@ static constexpr uint8_t IDLE_BIT_0_DEF_STATE = 0; static constexpr uint8_t IDLE_BIT_1_DEF_STATE = 1; uint8_t createCmdByte(Cmds cmd, bool tempCheck); -ReturnValue_t prepareScexCmd(scex::Cmds cmd, bool tempCheck, std::pair cmdBufPair, + +ReturnValue_t prepareScexCmd(Cmds cmd, bool tempCheck, std::pair cmdBufPair, size_t& cmdLen, std::pair usrDataPair); } // namespace scex -- 2.43.0 From f5ee21334cd8a428da35aaf795532afb65ea8509 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Sun, 29 May 2022 17:54:17 +0200 Subject: [PATCH 34/48] formatted --- linux/devices/ScexDleParser.cpp | 8 +++++--- linux/devices/ScexDleParser.h | 14 +++++++------- mission/devices/ScexDeviceHandler.cpp | 4 ++-- .../devices/devicedefinitions/ScexDefinitions.cpp | 5 ++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/linux/devices/ScexDleParser.cpp b/linux/devices/ScexDleParser.cpp index 43405fc5..ac1828dc 100644 --- a/linux/devices/ScexDleParser.cpp +++ b/linux/devices/ScexDleParser.cpp @@ -1,5 +1,7 @@ #include "ScexDleParser.h" -ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, - void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args) {}; -ScexDleParser::~ScexDleParser() {}; +ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, + BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, + void *args) + : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args){}; +ScexDleParser::~ScexDleParser(){}; diff --git a/linux/devices/ScexDleParser.h b/linux/devices/ScexDleParser.h index 7fbd73db..ef87abb7 100644 --- a/linux/devices/ScexDleParser.h +++ b/linux/devices/ScexDleParser.h @@ -3,17 +3,17 @@ #include - class ScexDleParser : public DleParser { public: - ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, - BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, - void *args); -// ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, -// BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, -// void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args){} + ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, BufPair encodedBuf, + BufPair decodedBuf, UserHandler handler, void *args); + // ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, + // BufPair encodedBuf, BufPair decodedBuf, UserHandler handler, + // void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, + // args){} virtual ~ScexDleParser(); + private: }; diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index de4b63d0..f732447f 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -5,10 +5,10 @@ #include #include +#include #include "fsfw/globalfunctions/CRC.h" #include "mission/devices/devicedefinitions/ScexDefinitions.h" -#include using std::ofstream; @@ -48,7 +48,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic switch (deviceCommand) { case (PING): { - //rawPacket = cmdBuf.data(); + // rawPacket = cmdBuf.data(); prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}); return RETURN_OK; diff --git a/mission/devices/devicedefinitions/ScexDefinitions.cpp b/mission/devices/devicedefinitions/ScexDefinitions.cpp index 7b8f49dd..68bf0d76 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.cpp +++ b/mission/devices/devicedefinitions/ScexDefinitions.cpp @@ -8,9 +8,8 @@ uint8_t scex::createCmdByte(Cmds cmd, bool tempCheck) { return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; } -ReturnValue_t scex::prepareScexCmd(Cmds cmd, bool tempCheck, - std::pair cmdBufPair, size_t& cmdLen, - std::pair usrDataPair) { +ReturnValue_t scex::prepareScexCmd(Cmds cmd, bool tempCheck, std::pair cmdBufPair, + size_t& cmdLen, std::pair usrDataPair) { using namespace scex; uint8_t* cmdBuf = cmdBufPair.first; const uint8_t* userData = usrDataPair.first; -- 2.43.0 From 521b17a8f8453021878956e13b5a50746121f01c Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Mon, 30 May 2022 20:52:45 +0200 Subject: [PATCH 35/48] initmission --- bsp_linux_board/InitMission.cpp | 14 ++++++++++++++ linux/devices/ScexUartReader.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index db8dd80f..3611524c 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -100,6 +100,20 @@ void initmission::initTasks() { result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); #endif +#if OBSW_ADD_SCEX_READER == 1 + result = HasReturnvaluesIF::RETURN_OK; + PeriodicTaskIF* scexReaderTask = factory->createPeriodicTask( + "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = scexReaderTask->addComponent(objects::SCEX_UART_READER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); + } + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + tmtcBridgeTask->startTask(); + tmtcPollingTask->startTask(); +#endif + /* PUS Services */ std::vector pusTasks; createPusTasks(*factory, missedDeadlineFunc, pusTasks); diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 517ee4a1..a33040a8 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -165,7 +165,7 @@ void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) { if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); } else { - DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); + DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); } } -- 2.43.0 From 005e548059053b67add4e1c43d495176c67b7592 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 21 Jun 2022 16:44:14 +0200 Subject: [PATCH 36/48] comntinued scex handler --- bsp_linux_board/InitMission.cpp | 36 ++++++------- common/config/devConf.h | 1 + fsfw | 2 +- linux/ObjectFactory.cpp | 6 ++- linux/devices/ScexDleParser.h | 5 +- linux/devices/ScexUartReader.cpp | 31 ++++++----- linux/devices/ScexUartReader.h | 5 +- mission/devices/CMakeLists.txt | 2 + mission/devices/ScexDeviceHandler.cpp | 54 ++++++++++--------- mission/devices/ScexDeviceHandler.h | 1 - .../devicedefinitions/ScexDefinitions.cpp | 4 +- .../devicedefinitions/ScexDefinitions.h | 6 +-- scripts/rpi-port.sh | 4 +- tmtc | 2 +- 14 files changed, 82 insertions(+), 77 deletions(-) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 3611524c..16fac3f6 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -81,37 +81,31 @@ void initmission::initTasks() { #if OBSW_ADD_SCEX == 1 PeriodicTaskIF* scexDevHandler = factory->createPeriodicTask( "SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); - result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("SCEX_DEV", objects::SCEX); } - result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("SCEX_DEV", objects::SCEX); } - result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("SCEX_DEV", objects::SCEX); } - result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("SCEX_DEV", objects::SCEX); } - result = tmtcPollingTask->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); -#endif + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); -#if OBSW_ADD_SCEX_READER == 1 result = HasReturnvaluesIF::RETURN_OK; - PeriodicTaskIF* scexReaderTask = factory->createPeriodicTask( - "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); - result = scexReaderTask->addComponent(objects::SCEX_UART_READER); - if (result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); - } - sif::info << "Starting tasks.." << std::endl; - tmTcDistributor->startTask(); - tmtcBridgeTask->startTask(); - tmtcPollingTask->startTask(); + PeriodicTaskIF* scexReaderTask = factory->createPeriodicTask( + "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = scexReaderTask->addComponent(objects::SCEX_UART_READER); + if (result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); + } #endif /* PUS Services */ @@ -148,6 +142,7 @@ void initmission::initTasks() { #if OBSW_ADD_SCEX == 1 scexDevHandler->startTask(); + scexReaderTask->startTask(); #endif #if OBSW_ADD_TEST_PST == 1 if (startTestPst) { @@ -235,9 +230,12 @@ void initmission::createPstTasks(TaskFactory& factory, "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + } else { + taskVec.push_back(spiPst); } - taskVec.push_back(spiPst); #endif } diff --git a/common/config/devConf.h b/common/config/devConf.h index 51da9011..68a3e199 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -55,6 +55,7 @@ namespace uart { static constexpr size_t HYPERION_GPS_REPLY_MAX_BUFFER = 1024; static constexpr UartBaudRate SYRLINKS_BAUD = UartBaudRate::RATE_38400; +static constexpr UartBaudRate SCEX_BAUD = UartBaudRate::RATE_57600; static constexpr UartBaudRate GNSS_BAUD = UartBaudRate::RATE_9600; static constexpr UartBaudRate PLOC_MPSOC_BAUD = UartBaudRate::RATE_115200; static constexpr UartBaudRate PLOC_SUPV_BAUD = UartBaudRate::RATE_115200; diff --git a/fsfw b/fsfw index ebbe0863..1910a783 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit ebbe08639caae43667829d2cc2bcbdf91260e175 +Subproject commit 1910a7838c712f1cf34031d2a8b53e2f7cd24f66 diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index bb8b183f..6424dd00 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -323,10 +324,11 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher) { // objekte anlegen SdCardMountedIF* sdcMan = nullptr; - CookieIF* cookie = new CookieIF; + auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096); auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER); - new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, sdcMan); + auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, sdcMan); + scexHandler->setStartUpImmediately(); } void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) { diff --git a/linux/devices/ScexDleParser.h b/linux/devices/ScexDleParser.h index ef87abb7..a8b04ca7 100644 --- a/linux/devices/ScexDleParser.h +++ b/linux/devices/ScexDleParser.h @@ -1,5 +1,4 @@ -#ifndef LINUX_DEVICES_SCEXDLEPARSER_H_ -#define LINUX_DEVICES_SCEXDLEPARSER_H_ +#pragma once #include @@ -16,5 +15,3 @@ class ScexDleParser : public DleParser { private: }; - -#endif /* LINUX_DEVICES_SCEXDLEPARSER_H_ */ diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index a33040a8..f7a65f12 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include // write(), read(), close() #include // Error integer and strerror() function @@ -21,7 +20,7 @@ ScexUartReader::ScexUartReader(object_id_t objectId) ipcRingBuf(200 * 2048, true), ipcQueue(200), dleParser(decodeRingBuf, dleEncoder, {encodedBuf.data(), encodedBuf.size()}, - {decodedBuf.data(), decodedBuf.size()}, &foundDlePacketHandler, this) { + {decodedBuf.data(), decodedBuf.size()}, &foundDlePacketHandler, (void *)this) { semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); semaphore->acquire(); lock = MutexFactory::instance()->createMutex(); @@ -80,8 +79,8 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { /* Get file descriptor */ serialPort = open(devname.c_str(), O_RDWR); if (serialPort < 0) { - sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) - << std::endl; + sif::warning << "ScexUartReader::initializeInterface: open call failed with error [" << errno + << ", " << strerror(errno) << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } // Setting up UART parameters @@ -107,8 +106,8 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { #endif if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { - sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno) - << std::endl; + sif::warning << "ScexUartReader::initializeInterface: tcsetattr call failed with error [" + << errno << ", " << strerror(errno) << std::endl; } // Flush received and unread data tcflush(serialPort, TCIOFLUSH); @@ -117,6 +116,9 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { + if (sendData == nullptr or sendLen == 0) { + return HasReturnvaluesIF::RETURN_FAILED; + } lock->lockMutex(); if (state == States::NOT_READY or state == States::RUNNING) { lock->unlockMutex(); @@ -128,17 +130,18 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD ReturnValue_t result = dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; + sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl; return RETURN_FAILED; } size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen); if (bytesWritten != encodedLen) { - sif::warning << "Sending ping command to solar experiment failed" << std::endl; + sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed" + << std::endl; return RETURN_FAILED; } result = semaphore->release(); if (result != HasReturnvaluesIF::RETURN_OK) { - std::cout << "ScexUartReader::sendMessag: Releasing semaphore failed" << std::endl; + std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl; } return RETURN_OK; } @@ -160,12 +163,12 @@ ReturnValue_t ScexUartReader::finish() { return RETURN_OK; } -void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) { +void ScexUartReader::foundDlePacketHandler(const ScexDleParser::Context &ctx) { ScexUartReader *obj = reinterpret_cast(ctx.userArgs); - if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) { + if (ctx.getType() == ScexDleParser::ContextType::PACKET_FOUND) { obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second); } else { - DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); + ScexDleParser::defaultErrorHandler(ctx.error.first, ctx.error.second); } } @@ -175,11 +178,11 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { MutexGuard mg(lock); ReturnValue_t result = ipcQueue.insert(len); if (result != RETURN_OK) { - sif::warning << "IPCQueue error" << std::endl; + sif::warning << "ScexUartReader::handleFoundDlePacket: IPCQueue error" << std::endl; } result = ipcRingBuf.writeData(packet, len); if (result != RETURN_OK) { - sif::warning << "IPCRingBuf error" << std::endl; + sif::warning << "ScexUartReader::handleFoundDlePacket: IPCRingBuf error" << std::endl; } // sif::info << "DLE handler done" << std::endl; } diff --git a/linux/devices/ScexUartReader.h b/linux/devices/ScexUartReader.h index 4abbfd86..bdce5b65 100644 --- a/linux/devices/ScexUartReader.h +++ b/linux/devices/ScexUartReader.h @@ -1,5 +1,4 @@ -#ifndef LINUX_DEVICES_SCEXUARTREADER_H_ -#define LINUX_DEVICES_SCEXUARTREADER_H_ +#pragma once #include #include @@ -58,5 +57,3 @@ class ScexUartReader : public SystemObject, // strg+shift+n ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) override; }; - -#endif /* LINUX_DEVICES_SCEXUARTREADER_H_ */ diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 3efb68ab..56184ea4 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -21,3 +21,5 @@ target_sources( PayloadPcduHandler.cpp SolarArrayDeploymentHandler.cpp ScexDeviceHandler.cpp) + +add_subdirectory(devicedefinitions) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index f732447f..be280365 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -14,7 +14,7 @@ using std::ofstream; ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie, SdCardMountedIF* sdcMan) - : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), reader(reader), sdcMan(sdcMan) {} + : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {} ScexDeviceHandler::~ScexDeviceHandler() {} @@ -42,48 +42,52 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic if (std::find(VALID_CMDS.begin(), VALID_CMDS.end(), deviceCommand) == VALID_CMDS.end()) { return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - if (commandDataLen < 1) { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; + bool tempCheck = false; + if (commandDataLen == 1) { + tempCheck = commandData[0]; } switch (deviceCommand) { case (PING): { - // rawPacket = cmdBuf.data(); - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {nullptr, 0}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, + tempCheck); + break; } case (EXP_STATUS_CMD): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {nullptr, 0}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, + tempCheck); + break; } case (ION_CMD): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {nullptr, 0}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, + tempCheck); + break; } case (TEMP_CMD): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {nullptr, 0}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, + tempCheck); + break; } case (FRAM): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {commandData + 1, commandDataLen - 1}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandDataLen - 1}, tempCheck); + break; } case (ONE_CELL): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {commandData + 1, commandDataLen - 1}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandDataLen - 1}, tempCheck); + break; } case (ALL_CELLS_CMD): { - prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, - {commandData + 1, commandDataLen - 1}); - return RETURN_OK; + prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, + {commandData + 1, commandDataLen - 1}, tempCheck); + break; + } + default: { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } } + rawPacket = cmdBuf.data(); return RETURN_OK; } diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index a719fc49..ad549e68 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -9,7 +9,6 @@ class SdCardMountedIF; class ScexDeviceHandler : public DeviceHandlerBase { public: - // ctor vervollständigen ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie, SdCardMountedIF *sdcMan); virtual ~ScexDeviceHandler(); diff --git a/mission/devices/devicedefinitions/ScexDefinitions.cpp b/mission/devices/devicedefinitions/ScexDefinitions.cpp index 68bf0d76..8685862e 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.cpp +++ b/mission/devices/devicedefinitions/ScexDefinitions.cpp @@ -8,8 +8,8 @@ uint8_t scex::createCmdByte(Cmds cmd, bool tempCheck) { return (IDLE_BIT_0_DEF_STATE << 7) | (IDLE_BIT_1_DEF_STATE << 6) | (cmd << 1) | tempCheck; } -ReturnValue_t scex::prepareScexCmd(Cmds cmd, bool tempCheck, std::pair cmdBufPair, - size_t& cmdLen, std::pair usrDataPair) { +ReturnValue_t scex::prepareScexCmd(Cmds cmd, std::pair cmdBufPair, size_t& cmdLen, + std::pair usrDataPair, bool tempCheck) { using namespace scex; uint8_t* cmdBuf = cmdBufPair.first; const uint8_t* userData = usrDataPair.first; diff --git a/mission/devices/devicedefinitions/ScexDefinitions.h b/mission/devices/devicedefinitions/ScexDefinitions.h index 55264f3e..685f0cc0 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.h +++ b/mission/devices/devicedefinitions/ScexDefinitions.h @@ -38,10 +38,10 @@ static constexpr uint8_t CRC_LEN = 2; static constexpr uint8_t IDLE_BIT_0_DEF_STATE = 0; static constexpr uint8_t IDLE_BIT_1_DEF_STATE = 1; -uint8_t createCmdByte(Cmds cmd, bool tempCheck); +uint8_t createCmdByte(Cmds cmd, bool tempCheck = false); -ReturnValue_t prepareScexCmd(Cmds cmd, bool tempCheck, std::pair cmdBufPair, - size_t& cmdLen, std::pair usrDataPair); +ReturnValue_t prepareScexCmd(Cmds cmd, std::pair cmdBufPair, size_t& cmdLen, + std::pair usrDataPair, bool tempCheck = false); } // namespace scex diff --git a/scripts/rpi-port.sh b/scripts/rpi-port.sh index 5801fb50..e8832c89 100755 --- a/scripts/rpi-port.sh +++ b/scripts/rpi-port.sh @@ -1,8 +1,10 @@ #!/bin/bash echo "-L 1538:raspberrypi.local:1538 for Raspberry Pi connect with TCF agent" echo "-L 1539:raspberrypi.local:22 for Raspberry Pi file transfers" +echo "-L 7301:raspberrypi.local:7301 for Raspberry Pi TMTC Commands" ssh -L 1538:raspberrypi.local:1534 \ -L 1539:raspberrypi.local:22 \ - eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \ + -L 7301:raspberrypi.local:7301 \ + eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \ -t 'CONSOLE_PREFIX="[RPi Tunnel]" /bin/bash' diff --git a/tmtc b/tmtc index ef349856..7012a6c4 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ef349856d614be7a408ffadf0c27c677d8be3157 +Subproject commit 7012a6c41f6e211c060f583c21061fe7ca3f4c45 -- 2.43.0 From 2584e51bb420e23bab54e60aa2fcdcaa92c566b2 Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 21 Jun 2022 16:49:26 +0200 Subject: [PATCH 37/48] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 7012a6c4..67500e88 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7012a6c41f6e211c060f583c21061fe7ca3f4c45 +Subproject commit 67500e88edbf684e79775333c69735ac88b31fd0 -- 2.43.0 From 20328f89ae4344f5440ab437abce54586f601baa Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Tue, 21 Jun 2022 17:46:59 +0200 Subject: [PATCH 38/48] ping cmd working --- mission/devices/ScexDeviceHandler.cpp | 59 +++++++++++++++++---------- mission/devices/ScexDeviceHandler.h | 7 +++- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index be280365..e18292c0 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -46,6 +46,9 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic if (commandDataLen == 1) { tempCheck = commandData[0]; } + if (commandActive) { + return DeviceHandlerIF::BUSY; + } switch (deviceCommand) { case (PING): { @@ -87,12 +90,13 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } } + commandActive = true; rawPacket = cmdBuf.data(); return RETURN_OK; } void ScexDeviceHandler::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(scex::Cmds::PING, 3); + insertInCommandAndReplyMap(scex::Cmds::PING, 5); insertInCommandAndReplyMap(scex::Cmds::ION_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); @@ -106,11 +110,8 @@ void ScexDeviceHandler::fillCommandAndReplyMap() { ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { - uint8_t* decodedPacket = nullptr; - size_t len = 0; - - const uint8_t* helperPtr = decodedPacket; - ReturnValue_t result = helper.deSerialize(&helperPtr, &len); + size_t len = remainingSize; + ReturnValue_t result = helper.deSerialize(&start, &len); if (result == ScexHelper::INVALID_CRC) { sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl; @@ -126,8 +127,12 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons // cmd auswertung (in file reinschreiben) using namespace scex; + ReturnValue_t status = RETURN_OK; auto oneFileHandler = [&](std::string cmdName) { fileId = random_string(6); + finishCountdown.setTimeout(SHORT_CD); + // countdown starten + finishCountdown.resetTimer(); std::ostringstream oss("/tmp/scex-"); oss << cmdName << fileId << ".bin"; fileName = oss.str(); @@ -144,6 +149,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons }; auto multiFileHandler = [&](std::string cmdName) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { + finishCountdown.setTimeout(LONG_CD); // countdown starten finishCountdown.resetTimer(); @@ -164,38 +170,38 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons if (debugMode) { out << helper; } - - if (finishCountdown.hasTimedOut()) { - triggerEvent(scex::EXPERIMENT_TIMEDOUT, id, 0); - reader.finish(); - sif::warning << "ScexDeviceHandler::interpretDiviceReply: Reader timeout" << std::endl; - fileNameSet = false; - } } return RETURN_OK; }; switch (id) { case (PING): { - return oneFileHandler("ping_"); + status = oneFileHandler("ping_"); + break; } case (ION_CMD): { - return oneFileHandler("ion_"); + status = oneFileHandler("ion_"); + break; } case (TEMP_CMD): { - return oneFileHandler("temp_"); + status = oneFileHandler("temp_"); + break; } case (EXP_STATUS_CMD): { - return oneFileHandler("exp_status_"); + status = oneFileHandler("exp_status_"); + break; } case (FRAM): { - return multiFileHandler("fram_"); + status = multiFileHandler("fram_"); + break; } case (ONE_CELL): { - return multiFileHandler("one_cell_"); + status = multiFileHandler("one_cell_"); + break; } case (ALL_CELLS_CMD): { - return multiFileHandler("all_cell_"); + status = multiFileHandler("all_cell_"); + break; } default: // Unknown DeviceCommand @@ -203,13 +209,24 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons } if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { reader.finish(); + commandActive = false; if (id != PING) { sif::info << "Reader is finished" << std::endl; fileNameSet = false; } } - return RETURN_OK; + return status; +} + +void ScexDeviceHandler::performOperationHook() { + if (commandActive and finishCountdown.hasTimedOut()) { + triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); + reader.finish(); + sif::warning << "ScexDeviceHandler::interpretDiviceReply: Reader timeout" << std::endl; + fileNameSet = false; + commandActive = false; + } } uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index ad549e68..eeaac755 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -14,16 +14,19 @@ class ScexDeviceHandler : public DeviceHandlerBase { virtual ~ScexDeviceHandler(); private: + static constexpr uint32_t LONG_CD = 180 * 1000; + static constexpr uint32_t SHORT_CD = 7000; std::array cmdBuf = {}; std::string fileId = ""; std::string fileName = ""; bool fileNameSet = false; + bool commandActive = false; bool debugMode = true; scex::Cmds currCmd = scex::Cmds::PING; SdCardMountedIF *sdcMan = nullptr; - Countdown finishCountdown = Countdown(180 * 1000); + Countdown finishCountdown = Countdown(LONG_CD); std::string random_string(std::string::size_type length); @@ -32,6 +35,8 @@ class ScexDeviceHandler : public DeviceHandlerBase { void doShutDown() override; ScexHelper helper; ScexUartReader &reader; + + void performOperationHook() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, -- 2.43.0 From 5a92b9e6160c2c4852e31a5ce4d198d4f97aff6f Mon Sep 17 00:00:00 2001 From: Irini Kosmidou Date: Thu, 30 Jun 2022 21:53:02 +0200 Subject: [PATCH 39/48] tmtc --- linux/devices/ScexUartReader.cpp | 1 - mission/devices/ScexDeviceHandler.cpp | 4 ++-- tmtc | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index f7a65f12..b4e48612 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -184,7 +184,6 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { if (result != RETURN_OK) { sif::warning << "ScexUartReader::handleFoundDlePacket: IPCRingBuf error" << std::endl; } - // sif::info << "DLE handler done" << std::endl; } ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index e18292c0..7417ca0d 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -150,7 +150,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons auto multiFileHandler = [&](std::string cmdName) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { finishCountdown.setTimeout(LONG_CD); - // countdown starten + // countdown starts finishCountdown.resetTimer(); fileId = random_string(6); @@ -223,7 +223,7 @@ void ScexDeviceHandler::performOperationHook() { if (commandActive and finishCountdown.hasTimedOut()) { triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); reader.finish(); - sif::warning << "ScexDeviceHandler::interpretDiviceReply: Reader timeout" << std::endl; + sif::warning << "ScexDeviceHandler::performOperationHook: Reader timeout" << std::endl; fileNameSet = false; commandActive = false; } diff --git a/tmtc b/tmtc index 67500e88..dbae41cb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 67500e88edbf684e79775333c69735ac88b31fd0 +Subproject commit dbae41cb5810c45ee783080dd0c0f5580e258876 -- 2.43.0 From a462677ed26fbe3d58483f1995a3c31a603be6c2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 16:39:07 +0200 Subject: [PATCH 40/48] smaller fixes, always download ETL --- CMakeLists.txt | 26 +++++++++++++------------- bsp_linux_board/ObjectFactory.cpp | 2 +- fsfw | 2 +- tmtc | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e18fa588..7317b5a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,20 +374,20 @@ add_subdirectory(${UNITTEST_PATH}) # This should have already been downloaded by the FSFW Still include it to be # safe -find_package(etl ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) +# find_package(etl ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) # Not installed, so use FetchContent to download and provide etl -if(NOT etl_FOUND) - message( - STATUS - "No ETL installation was found with find_package. Installing and providing " - "etl with FindPackage") - include(FetchContent) - FetchContent_Declare( - etl - GIT_REPOSITORY https://github.com/ETLCPP/etl - GIT_TAG ${FSFW_ETL_LIB_VERSION}) - list(APPEND FSFW_FETCH_CONTENT_TARGETS etl) -endif() +# if(NOT etl_FOUND) +message( + STATUS + "No ETL installation was found with find_package. Installing and providing " + "etl with FindPackage") +include(FetchContent) +FetchContent_Declare( + etl + GIT_REPOSITORY https://github.com/ETLCPP/etl + GIT_TAG ${FSFW_ETL_LIB_VERSION}) +list(APPEND FSFW_FETCH_CONTENT_TARGETS etl) +# endif() # Use same Catch2 version as framework if(NOT (TGT_BSP MATCHES "arm/te0720-1cfa") diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 5ac79123..19a00647 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -20,7 +20,7 @@ #include "mission/core/GenericFactory.h" #include "mission/devices/GPSHyperionHandler.h" #include "mission/devices/GyroADIS1650XHandler.h" -#include "mission/utility/TmFunnel.h" +#include "mission/tmtc/TmFunnel.h" #include "objects/systemObjectList.h" #include "tmtc/apid.h" #include "tmtc/pusIds.h" diff --git a/fsfw b/fsfw index 6a62cf7f..904ae2cc 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 6a62cf7f1e47d627346916f3605829118ffd8357 +Subproject commit 904ae2cc0ef61706a385d498942154da4f923a18 diff --git a/tmtc b/tmtc index 87d539d4..370d6c2f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 87d539d46eba64569e550f5873e176f31fce1542 +Subproject commit 370d6c2fa4e9c84d96d23cbae6711cdf68cdd465 -- 2.43.0 From 57f97de58e530882324cbbdf1632ddf8fc069548 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 16:46:27 +0200 Subject: [PATCH 41/48] rerun generator scripts --- generators/bsp_q7s_events.csv | 1 + generators/bsp_q7s_objects.csv | 2 + generators/bsp_q7s_returnvalues.csv | 518 +++++++++--------- generators/events/translateEvents.cpp | 7 +- generators/objects/translateObjects.cpp | 10 +- linux/fsfwconfig/events/translateEvents.cpp | 7 +- linux/fsfwconfig/objects/translateObjects.cpp | 10 +- tmtc | 2 +- 8 files changed, 289 insertions(+), 268 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 7adf38da..cd0116df 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -208,3 +208,4 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h 13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h 13703;0x3587;REBOOT_HW;MEDIUM;;bsp_q7s/core/CoreController.h +13800;0x35e8;EXPERIMENT_TIMEDOUT;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index 09a96584..098b0b08 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -46,6 +46,7 @@ 0x44330015;PLOC_MPSOC_HANDLER 0x44330016;PLOC_SUPERVISOR_HANDLER 0x44330017;PLOC_SUPERVISOR_HELPER +0x44330032;SCEX 0x444100A2;SOLAR_ARRAY_DEPL_HANDLER 0x444100A4;HEATER_HANDLER 0x44420004;TMP1075_HANDLER_1 @@ -69,6 +70,7 @@ 0x445300A3;SYRLINKS_HK_HANDLER 0x49000000;ARDUINO_COM_IF 0x49010005;GPIO_IF +0x49010006;SCEX_UART_READER 0x49020004;SPI_MAIN_COM_IF 0x49020005;SPI_RW_COM_IF 0x49020006;SPI_RTD_COM_IF diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index a74cfaa2..147a9ea4 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -1,25 +1,13 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x0000;OK;System-wide code for ok.;0;HasReturnvaluesIF;fsfw/returnvalues/HasReturnvaluesIF.h 0x0001;Failed;Unspecified system-wide code for failed.;1;HasReturnvaluesIF;fsfw/returnvalues/HasReturnvaluesIF.h +0x64a0;CCSDS_CommandNotImplemented;Received action message with unknown action id;160;CCSDS_HANDLER;mission/tmtc/CCSDSHandler.h 0x6100;GOMS_PacketTooLong;;0;GOM_SPACE_HANDLER;mission/devices/GomspaceDeviceHandler.h 0x6101;GOMS_InvalidTableId;;1;GOM_SPACE_HANDLER;mission/devices/GomspaceDeviceHandler.h 0x6102;GOMS_InvalidAddress;;2;GOM_SPACE_HANDLER;mission/devices/GomspaceDeviceHandler.h 0x6103;GOMS_InvalidParamSize;;3;GOM_SPACE_HANDLER;mission/devices/GomspaceDeviceHandler.h 0x6104;GOMS_InvalidPayloadSize;;4;GOM_SPACE_HANDLER;mission/devices/GomspaceDeviceHandler.h 0x6105;GOMS_UnknownReplyId;;5;GOM_SPACE_HANDLER;mission/devices/GomspaceDeviceHandler.h -0x53a1;HEATER_CommandNotSupported;;161;HEATER_HANDLER;mission/devices/HeaterHandler.h -0x53a2;HEATER_InitFailed;;162;HEATER_HANDLER;mission/devices/HeaterHandler.h -0x53a3;HEATER_InvalidSwitchNr;;163;HEATER_HANDLER;mission/devices/HeaterHandler.h -0x53a4;HEATER_MainSwitchSetTimeout;;164;HEATER_HANDLER;mission/devices/HeaterHandler.h -0x53a5;HEATER_CommandAlreadyWaiting;;165;HEATER_HANDLER;mission/devices/HeaterHandler.h -0x55a0;IMTQ_InvalidCommandCode;;160;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a1;IMTQ_ParameterMissing;;161;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a2;IMTQ_ParameterInvalid;;162;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a3;IMTQ_CcUnavailable;;163;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a4;IMTQ_InternalProcessingError;;164;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a5;IMTQ_RejectedWithoutReason;;165;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a6;IMTQ_CmdErrUnknown;;166;IMTQ_HANDLER;mission/devices/IMTQHandler.h -0x55a7;IMTQ_UnexpectedSelfTestReply;The status reply to a self test command was received but no self test command has been sent. This should normally never happen.;167;IMTQ_HANDLER;mission/devices/IMTQHandler.h 0x56b0;RWHA_SpiWriteFailure;;176;RW_HANDLER;mission/devices/RwHandler.h 0x56b1;RWHA_SpiReadFailure;Used by the spi send function to tell a failing read call;177;RW_HANDLER;mission/devices/RwHandler.h 0x56b2;RWHA_MissingStartSign;Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E;178;RW_HANDLER;mission/devices/RwHandler.h @@ -32,13 +20,21 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x56a2;RWHA_SetSpeedCommandInvalidLength;Received set speed command has invalid length. Should be 6.;162;RW_HANDLER;mission/devices/RwHandler.h 0x56a3;RWHA_ExecutionFailed;Command execution failed;163;RW_HANDLER;mission/devices/RwHandler.h 0x56a4;RWHA_CrcError;Reaction wheel reply has invalid crc;164;RW_HANDLER;mission/devices/RwHandler.h -0x6aa0;SADPL_CommandNotSupported;;160;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h -0x6aa1;SADPL_DeploymentAlreadyExecuting;;161;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h -0x6aa2;SADPL_MainSwitchTimeoutFailure;;162;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h -0x6aa3;SADPL_SwitchingDeplSa1Failed;;163;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h -0x6aa4;SADPL_SwitchingDeplSa2Failed;;164;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h +0x53a1;HEATER_CommandNotSupported;;161;HEATER_HANDLER;mission/devices/HeaterHandler.h +0x53a2;HEATER_InitFailed;;162;HEATER_HANDLER;mission/devices/HeaterHandler.h +0x53a3;HEATER_InvalidSwitchNr;;163;HEATER_HANDLER;mission/devices/HeaterHandler.h +0x53a4;HEATER_MainSwitchSetTimeout;;164;HEATER_HANDLER;mission/devices/HeaterHandler.h +0x53a5;HEATER_CommandAlreadyWaiting;;165;HEATER_HANDLER;mission/devices/HeaterHandler.h 0x5ca0;SUSS_ErrorUnlockMutex;;160;SUS_HANDLER;mission/devices/SusHandler.h 0x5ca1;SUSS_ErrorLockMutex;;161;SUS_HANDLER;mission/devices/SusHandler.h +0x55a0;IMTQ_InvalidCommandCode;;160;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a1;IMTQ_ParameterMissing;;161;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a2;IMTQ_ParameterInvalid;;162;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a3;IMTQ_CcUnavailable;;163;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a4;IMTQ_InternalProcessingError;;164;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a5;IMTQ_RejectedWithoutReason;;165;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a6;IMTQ_CmdErrUnknown;;166;IMTQ_HANDLER;mission/devices/IMTQHandler.h +0x55a7;IMTQ_UnexpectedSelfTestReply;The status reply to a self test command was received but no self test command has been sent. This should normally never happen.;167;IMTQ_HANDLER;mission/devices/IMTQHandler.h 0x54a0;SYRLINKS_CrcFailure;;160;SYRLINKS_HANDLER;mission/devices/SyrlinksHkHandler.h 0x54a1;SYRLINKS_UartFraminOrParityErrorAck;;161;SYRLINKS_HANDLER;mission/devices/SyrlinksHkHandler.h 0x54a2;SYRLINKS_BadCharacterAck;;162;SYRLINKS_HANDLER;mission/devices/SyrlinksHkHandler.h @@ -48,8 +44,18 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x54a6;SYRLINKS_BadCrcAck;;166;SYRLINKS_HANDLER;mission/devices/SyrlinksHkHandler.h 0x54a7;SYRLINKS_ReplyWrongSize;;167;SYRLINKS_HANDLER;mission/devices/SyrlinksHkHandler.h 0x54a8;SYRLINKS_MissingStartFrameCharacter;;168;SYRLINKS_HANDLER;mission/devices/SyrlinksHkHandler.h +0x6aa0;SADPL_CommandNotSupported;;160;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h +0x6aa1;SADPL_DeploymentAlreadyExecuting;;161;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h +0x6aa2;SADPL_MainSwitchTimeoutFailure;;162;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h +0x6aa3;SADPL_SwitchingDeplSa1Failed;;163;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h +0x6aa4;SADPL_SwitchingDeplSa2Failed;;164;SA_DEPL_HANDLER;mission/devices/SolarArrayDeploymentHandler.h 0x67a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NVMParameterBase.h -0x64a0;CCSDS_CommandNotImplemented;Received action message with unknown action id;160;CCSDS_HANDLER;mission/tmtc/CCSDSHandler.h +0x4400;HSPI_HalTimeoutRetval;;0;HAL_SPI;fsfw/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4401;HSPI_HalBusyRetval;;1;HAL_SPI;fsfw/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4402;HSPI_HalErrorRetval;;2;HAL_SPI;fsfw/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4501;HURT_UartReadFailure;;1;HAL_UART;fsfw/hal/src/fsfw_hal/linux/uart/UartComIF.h +0x4502;HURT_UartReadSizeMissmatch;;2;HAL_UART;fsfw/hal/src/fsfw_hal/linux/uart/UartComIF.h +0x4503;HURT_UartRxBufferTooSmall;;3;HAL_UART;fsfw/hal/src/fsfw_hal/linux/uart/UartComIF.h 0x4701;HGIO_UnknownGpioId;;1;HAL_GPIO;fsfw/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h 0x4702;HGIO_DriveGpioFailure;;2;HAL_GPIO;fsfw/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h 0x4703;HGIO_GpioTypeFailure;;3;HAL_GPIO;fsfw/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -57,48 +63,12 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x4705;HGIO_GpioDuplicateDetected;;5;HAL_GPIO;fsfw/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h 0x4706;HGIO_GpioInitFailed;;6;HAL_GPIO;fsfw/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h 0x4707;HGIO_GpioGetValueFailed;;7;HAL_GPIO;fsfw/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h -0x4400;HSPI_HalTimeoutRetval;;0;HAL_SPI;fsfw/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4401;HSPI_HalBusyRetval;;1;HAL_SPI;fsfw/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4402;HSPI_HalErrorRetval;;2;HAL_SPI;fsfw/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4501;HURT_UartReadFailure;;1;HAL_UART;fsfw/hal/src/fsfw_hal/linux/uart/UartComIF.h -0x4502;HURT_UartReadSizeMissmatch;;2;HAL_UART;fsfw/hal/src/fsfw_hal/linux/uart/UartComIF.h -0x4503;HURT_UartRxBufferTooSmall;;3;HAL_UART;fsfw/hal/src/fsfw_hal/linux/uart/UartComIF.h 0x4300;UXOS_ExecutionFinished;Execution of the current command has finished;0;LINUX_OSAL;fsfw/hal/src/fsfw_hal/linux/CommandExecutor.h 0x4301;UXOS_CommandPending;Command is pending. This will also be returned if the user tries to load another command but a command is still pending;1;LINUX_OSAL;fsfw/hal/src/fsfw_hal/linux/CommandExecutor.h 0x4302;UXOS_BytesRead;Some bytes have been read from the executing process;2;LINUX_OSAL;fsfw/hal/src/fsfw_hal/linux/CommandExecutor.h 0x4303;UXOS_CommandError;Command execution failed;3;LINUX_OSAL;fsfw/hal/src/fsfw_hal/linux/CommandExecutor.h 0x4304;UXOS_NoCommandLoadedOrPending;;4;LINUX_OSAL;fsfw/hal/src/fsfw_hal/linux/CommandExecutor.h 0x4306;UXOS_PcloseCallError;;6;LINUX_OSAL;fsfw/hal/src/fsfw_hal/linux/CommandExecutor.h -0x3101;CF_ObjectHasNoFunctions;;1;COMMANDS_ACTIONS_IF;fsfw/src/fsfw/action/CommandsActionsIF.h -0x3102;CF_AlreadyCommanding;;2;COMMANDS_ACTIONS_IF;fsfw/src/fsfw/action/CommandsActionsIF.h -0x3201;HF_IsBusy;;1;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h -0x3202;HF_InvalidParameters;;2;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h -0x3203;HF_ExecutionFinished;;3;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h -0x3204;HF_InvalidActionId;;4;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h -0x3501;CFDP_InvalidTlvType;;1;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3502;CFDP_InvalidDirectiveFields;;2;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3503;CFDP_InvalidPduDatafieldLen;;3;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3504;CFDP_InvalidAckDirectiveFields;;4;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3505;CFDP_MetadataCantParseOptions;;5;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3506;CFDP_FinishedCantParseFsResponses;;6;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3508;CFDP_FilestoreRequiresSecondFile;;8;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x3509;CFDP_FilestoreResponseCantParseFsMessage;;9;CFDP;fsfw/src/fsfw/cfdp/definitions.h -0x1101;AL_Full;;1;ARRAY_LIST;fsfw/src/fsfw/container/ArrayList.h -0x1801;FF_Full;;1;FIFO_CLASS;fsfw/src/fsfw/container/FIFOBase.h -0x1802;FF_Empty;;2;FIFO_CLASS;fsfw/src/fsfw/container/FIFOBase.h -0x1501;FM_KeyAlreadyExists;;1;FIXED_MAP;fsfw/src/fsfw/container/FixedMap.h -0x1502;FM_MapFull;;2;FIXED_MAP;fsfw/src/fsfw/container/FixedMap.h -0x1503;FM_KeyDoesNotExist;;3;FIXED_MAP;fsfw/src/fsfw/container/FixedMap.h -0x1601;FMM_MapFull;;1;FIXED_MULTIMAP;fsfw/src/fsfw/container/FixedOrderedMultimap.h -0x1602;FMM_KeyDoesNotExist;;2;FIXED_MULTIMAP;fsfw/src/fsfw/container/FixedOrderedMultimap.h -0x37a1;SGP4_InvalidEccentricity;;161;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37a2;SGP4_InvalidMeanMotion;;162;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37a3;SGP4_InvalidPerturbationElements;;163;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37a4;SGP4_InvalidSemiLatusRectum;;164;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37a5;SGP4_InvalidEpochElements;;165;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37a6;SGP4_SatelliteHasDecayed;;166;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37b1;SGP4_TleTooOld;;177;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h -0x37b2;SGP4_TleNotInitialized;;178;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h 0x2b01;CCS_BcIsSetVrCommand;;1;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2b02;CCS_BcIsUnlockCommand;;2;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2bb0;CCS_BcIllegalCommand;;176;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h @@ -128,154 +98,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x2bd1;CCS_ShorterThanHeader;;209;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2bd2;CCS_TooShortBlockedPacket;;210;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2bd3;CCS_TooShortMapExtraction;;211;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h -0x0801;DPS_InvalidParameterDefinition;;1;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h -0x0802;DPS_SetWasAlreadyRead;;2;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h -0x0803;DPS_CommitingWithoutReading;;3;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h -0x0804;DPS_DataSetUninitialised;;4;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h -0x0805;DPS_DataSetFull;;5;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h -0x0806;DPS_PoolVarNull;;6;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h -0x3ca0;PVA_InvalidReadWriteMode;;160;POOL_VARIABLE_IF;fsfw/src/fsfw/datapool/PoolVariableIF.h -0x3ca1;PVA_InvalidPoolEntry;;161;POOL_VARIABLE_IF;fsfw/src/fsfw/datapool/PoolVariableIF.h -0x3d00;HKM_QueueOrDestinationInvalid;;0;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h -0x3d01;HKM_WrongHkPacketType;;1;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h -0x3d02;HKM_ReportingStatusUnchanged;;2;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h -0x3d03;HKM_PeriodicHelperInvalid;;3;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h -0x3d04;HKM_PoolobjectNotFound;;4;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h -0x3d05;HKM_DatasetNotFound;;5;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h -0x3b00;LPIF_PoolEntryNotFound;;0;LOCAL_POOL_OWNER_IF;fsfw/src/fsfw/datapoollocal/localPoolDefinitions.h -0x3b01;LPIF_PoolEntryTypeConflict;;1;LOCAL_POOL_OWNER_IF;fsfw/src/fsfw/datapoollocal/localPoolDefinitions.h -0x1201;AB_NeedSecondStep;;1;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h -0x1202;AB_NeedToReconfigure;;2;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h -0x1203;AB_ModeFallback;;3;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h -0x1204;AB_ChildNotCommandable;;4;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h -0x1205;AB_NeedToChangeHealth;;5;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h -0x12a1;AB_NotEnoughChildrenInCorrectState;;161;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h -0x3301;DC_NoReplyReceived;;1;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h -0x3302;DC_ProtocolError;;2;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h -0x3303;DC_Nullpointer;;3;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h -0x3304;DC_InvalidCookieType;;4;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h -0x3305;DC_NotActive;;5;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h -0x3306;DC_TooMuchData;;6;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h -0x03a0;DHB_InvalidChannel;;160;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03b0;DHB_AperiodicReply;;176;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03b1;DHB_IgnoreReplyData;;177;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03b2;DHB_IgnoreFullPacket;;178;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03c0;DHB_NothingToSend;;192;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03c2;DHB_CommandMapError;;194;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03d0;DHB_NoSwitch;;208;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03e0;DHB_ChildTimeout;;224;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x03e1;DHB_SwitchFailed;;225;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h -0x26a0;DHI_NoCommandData;;160;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a1;DHI_CommandNotSupported;;161;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a2;DHI_CommandAlreadySent;;162;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a3;DHI_CommandWasNotSent;;163;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a4;DHI_CantSwitchAddress;;164;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a5;DHI_WrongModeForCommand;;165;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a6;DHI_Timeout;;166;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a7;DHI_Busy;;167;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a8;DHI_NoReplyExpected;;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26a9;DHI_NonOpTemperature;;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26aa;DHI_CommandNotImplemented;;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26b0;DHI_ChecksumError;;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26b1;DHI_LengthMissmatch;;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26b2;DHI_InvalidData;;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26b3;DHI_ProtocolError;;179;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26c0;DHI_DeviceDidNotExecute;;192;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26c1;DHI_DeviceReportedError;;193;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26c2;DHI_UnknownDeviceReply;;194;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26c3;DHI_DeviceReplyInvalid;;195;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26d0;DHI_InvalidCommandParameter;;208;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x26d1;DHI_InvalidNumberOrLengthOfParameters;;209;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h -0x2401;EV_ListenerNotFound;;1;EVENT_MANAGER_IF;fsfw/src/fsfw/events/EventManagerIF.h -0x2500;FDI_YourFault;;0;HANDLES_FAILURES_IF;fsfw/src/fsfw/fdir/ConfirmsFailuresIF.h -0x2501;FDI_MyFault;;1;HANDLES_FAILURES_IF;fsfw/src/fsfw/fdir/ConfirmsFailuresIF.h -0x2502;FDI_ConfirmLater;;2;HANDLES_FAILURES_IF;fsfw/src/fsfw/fdir/ConfirmsFailuresIF.h -0x2301;MT_TooDetailedRequest;;1;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h -0x2302;MT_TooGeneralRequest;;2;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h -0x2303;MT_NoMatch;;3;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h -0x2304;MT_Full;;4;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h -0x2305;MT_NewNodeCreated;;5;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h -0x2e01;ASC_TooLongForTargetType;;1;ASCII_CONVERTER;fsfw/src/fsfw/globalfunctions/AsciiConverter.h -0x2e02;ASC_InvalidCharacters;;2;ASCII_CONVERTER;fsfw/src/fsfw/globalfunctions/AsciiConverter.h -0x2e03;ASC_BufferTooSmall;;3;ASCII_CONVERTER;fsfw/src/fsfw/globalfunctions/AsciiConverter.h -0x3e01;DLEE_StreamTooShort;;1;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h -0x3e02;DLEE_DecodingError;;2;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h -0x1701;HHI_ObjectNotHealthy;;1;HAS_HEALTH_IF;fsfw/src/fsfw/health/HasHealthIF.h -0x1702;HHI_InvalidHealthState;;2;HAS_HEALTH_IF;fsfw/src/fsfw/health/HasHealthIF.h -0x1703;HHI_IsExternallyControlled;;3;HAS_HEALTH_IF;fsfw/src/fsfw/health/HasHealthIF.h -0x0f01;CM_UnknownCommand;;1;COMMAND_MESSAGE;fsfw/src/fsfw/ipc/CommandMessageIF.h -0x3901;MQI_Empty;;1;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h -0x3902;MQI_Full;No space left for more messages;2;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h -0x3903;MQI_NoReplyPartner;Returned if a reply method was called without partner;3;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h -0x3904;MQI_DestinationInvalid;Returned if the target destination is invalid.;4;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h -0x3801;MUX_NotEnoughResources;;1;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3802;MUX_InsufficientMemory;;2;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3803;MUX_NoPrivilege;;3;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3804;MUX_WrongAttributeSetting;;4;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3805;MUX_MutexAlreadyLocked;;5;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3806;MUX_MutexNotFound;;6;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3807;MUX_MutexMaxLocks;;7;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3808;MUX_CurrThreadAlreadyOwnsMutex;;8;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x3809;MUX_CurrThreadDoesNotOwnMutex;;9;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x380a;MUX_MutexTimeout;;10;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x380b;MUX_MutexInvalidId;;11;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x380c;MUX_MutexDestroyedWhileWaiting;;12;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h -0x4200;FILS_GenericFileError;;0;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x4201;FILS_IsBusy;;1;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x4202;FILS_InvalidParameters;;2;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x4205;FILS_FileDoesNotExist;;5;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x4206;FILS_FileAlreadyExists;;6;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x4207;FILS_FileLocked;;7;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x420a;FILS_DirectoryDoesNotExist;;10;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x420b;FILS_DirectoryAlreadyExists;;11;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x420c;FILS_DirectoryNotEmpty;;12;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x420f;FILS_SequencePacketMissingWrite;;15;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x4210;FILS_SequencePacketMissingRead;;16;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h -0x0601;PP_DoItMyself;;1;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0602;PP_PointsToVariable;;2;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0603;PP_PointsToMemory;;3;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0604;PP_ActivityCompleted;;4;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0605;PP_PointsToVectorUint8;;5;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0606;PP_PointsToVectorUint16;;6;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0607;PP_PointsToVectorUint32;;7;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x0608;PP_PointsToVectorFloat;;8;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x06a0;PP_DumpNotSupported;;160;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x06e0;PP_InvalidSize;;224;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x06e1;PP_InvalidAddress;;225;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x06e2;PP_InvalidContent;;226;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x06e3;PP_UnalignedAccess;;227;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x06e4;PP_WriteProtected;;228;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h -0x13e0;MH_UnknownCmd;;224;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h -0x13e1;MH_InvalidAddress;;225;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h -0x13e2;MH_InvalidSize;;226;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h -0x13e3;MH_StateMismatch;;227;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h -0x0e01;HM_InvalidMode;;1;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h -0x0e02;HM_TransNotAllowed;;2;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h -0x0e03;HM_InTransition;;3;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h -0x0e04;HM_InvalidSubmode;;4;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h -0x3001;LIM_Unchecked;;1;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x3002;LIM_Invalid;;2;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x3003;LIM_Unselected;;3;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x3004;LIM_BelowLowLimit;;4;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x3005;LIM_AboveHighLimit;;5;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x3006;LIM_UnexpectedValue;;6;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x3007;LIM_OutOfRange;;7;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x30a0;LIM_FirstSample;;160;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x30e0;LIM_InvalidSize;;224;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x30e1;LIM_WrongType;;225;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x30e2;LIM_WrongPid;;226;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x30e3;LIM_WrongLimitId;;227;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x30ee;LIM_MonitorNotFound;;238;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h -0x1a01;TRC_NotEnoughSensors;;1;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h -0x1a02;TRC_LowestValueOol;;2;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h -0x1a03;TRC_HighestValueOol;;3;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h -0x1a04;TRC_BothValuesOol;;4;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h -0x1a05;TRC_DuplexOol;;5;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h -0x0201;OM_InsertionFailed;;1;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h -0x0202;OM_NotFound;;2;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h -0x0203;OM_ChildInitFailed;;3;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h -0x0204;OM_InternalErrReporterUninit;;4;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h -0x0200;OM_ConnBroken;;0;OBJECT_MANAGER_IF;fsfw/src/fsfw/osal/common/TcpTmTcServer.h +0x3a00;SPH_ConnBroken;;0;SEMAPHORE_IF;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x2901;IEC_NoConfigurationTable;;1;INTERNAL_ERROR_CODES;fsfw/src/fsfw/osal/InternalErrorCodes.h 0x2902;IEC_NoCpuTable;;2;INTERNAL_ERROR_CODES;fsfw/src/fsfw/osal/InternalErrorCodes.h 0x2903;IEC_InvalidWorkspaceAddress;;3;INTERNAL_ERROR_CODES;fsfw/src/fsfw/osal/InternalErrorCodes.h @@ -297,6 +120,10 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x2913;IEC_ImplementationBlockingOperationCancel;;19;INTERNAL_ERROR_CODES;fsfw/src/fsfw/osal/InternalErrorCodes.h 0x2914;IEC_MutexObtainFromBadState;;20;INTERNAL_ERROR_CODES;fsfw/src/fsfw/osal/InternalErrorCodes.h 0x2915;IEC_UnlimitedAndMaximumIs0;;21;INTERNAL_ERROR_CODES;fsfw/src/fsfw/osal/InternalErrorCodes.h +0x0e01;HM_InvalidMode;;1;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h +0x0e02;HM_TransNotAllowed;;2;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h +0x0e03;HM_InTransition;;3;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h +0x0e04;HM_InvalidSubmode;;4;HAS_MODES_IF;fsfw/src/fsfw/modes/HasModesIF.h 0x2d01;HPA_InvalidIdentifierId;;1;HAS_PARAMETERS_IF;fsfw/src/fsfw/parameters/HasParametersIF.h 0x2d02;HPA_InvalidDomainId;;2;HAS_PARAMETERS_IF;fsfw/src/fsfw/parameters/HasParametersIF.h 0x2d03;HPA_InvalidValue;;3;HAS_PARAMETERS_IF;fsfw/src/fsfw/parameters/HasParametersIF.h @@ -309,16 +136,53 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x2c06;PAW_OutOfBounds;;6;PARAMETER_WRAPPER;fsfw/src/fsfw/parameters/ParameterWrapper.h 0x2c07;PAW_NotSet;;7;PARAMETER_WRAPPER;fsfw/src/fsfw/parameters/ParameterWrapper.h 0x2c08;PAW_ColumnOrRowsZero;;8;PARAMETER_WRAPPER;fsfw/src/fsfw/parameters/ParameterWrapper.h -0x2f01;POS_InPowerTransition;;1;POWER_SWITCHER;fsfw/src/fsfw/power/PowerSwitcher.h -0x2f02;POS_SwitchStateMismatch;;2;POWER_SWITCHER;fsfw/src/fsfw/power/PowerSwitcher.h -0x0501;PS_SwitchOn;;1;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h -0x0500;PS_SwitchOff;;0;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h -0x0502;PS_SwitchTimeout;;2;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h -0x0503;PS_FuseOn;;3;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h -0x0504;PS_FuseOff;;4;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h -0x4101;PUS11_InvalidTypeTimeWindow;;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h -0x4102;PUS11_TimeshiftingNotPossible;;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h -0x4103;PUS11_InvalidRelativeTime;;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x3101;CF_ObjectHasNoFunctions;;1;COMMANDS_ACTIONS_IF;fsfw/src/fsfw/action/CommandsActionsIF.h +0x3102;CF_AlreadyCommanding;;2;COMMANDS_ACTIONS_IF;fsfw/src/fsfw/action/CommandsActionsIF.h +0x3201;HF_IsBusy;;1;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h +0x3202;HF_InvalidParameters;;2;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h +0x3203;HF_ExecutionFinished;;3;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h +0x3204;HF_InvalidActionId;;4;HAS_ACTIONS_IF;fsfw/src/fsfw/action/HasActionsIF.h +0x0201;OM_InsertionFailed;;1;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h +0x0202;OM_NotFound;;2;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h +0x0203;OM_ChildInitFailed;;3;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h +0x0204;OM_InternalErrReporterUninit;;4;OBJECT_MANAGER_IF;fsfw/src/fsfw/objectmanager/ObjectManagerIF.h +0x2500;FDI_YourFault;;0;HANDLES_FAILURES_IF;fsfw/src/fsfw/fdir/ConfirmsFailuresIF.h +0x2501;FDI_MyFault;;1;HANDLES_FAILURES_IF;fsfw/src/fsfw/fdir/ConfirmsFailuresIF.h +0x2502;FDI_ConfirmLater;;2;HANDLES_FAILURES_IF;fsfw/src/fsfw/fdir/ConfirmsFailuresIF.h +0x2101;TMF_Busy;;1;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2102;TMF_LastPacketFound;;2;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2103;TMF_StopFetch;;3;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2104;TMF_Timeout;;4;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2105;TMF_TmChannelFull;;5;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2106;TMF_NotStored;;6;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2107;TMF_AllDeleted;;7;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2108;TMF_InvalidData;;8;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2109;TMF_NotReady;;9;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h +0x2001;TMB_Busy;;1;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2002;TMB_Full;;2;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2003;TMB_Empty;;3;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2004;TMB_NullRequested;;4;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2005;TMB_TooLarge;;5;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2006;TMB_NotReady;;6;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2007;TMB_DumpError;;7;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2008;TMB_CrcError;;8;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x2009;TMB_Timeout;;9;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x200a;TMB_IdlePacketFound;;10;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x200b;TMB_TelecommandFound;;11;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x200c;TMB_NoPusATm;;12;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x200d;TMB_TooSmall;;13;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x200e;TMB_BlockNotFound;;14;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x200f;TMB_InvalidRequest;;15;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h +0x1c01;TCD_PacketLost;;1;PACKET_DISTRIBUTION;fsfw/src/fsfw/tcdistribution/TcDistributor.h +0x1c02;TCD_DestinationNotFound;;2;PACKET_DISTRIBUTION;fsfw/src/fsfw/tcdistribution/TcDistributor.h +0x1c03;TCD_ServiceIdAlreadyExists;;3;PACKET_DISTRIBUTION;fsfw/src/fsfw/tcdistribution/TcDistributor.h +0x1b00;TCC_IllegalApid;;0;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h +0x1b01;TCC_IncompletePacket;;1;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h +0x1b02;TCC_IncorrectChecksum;;2;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h +0x1b03;TCC_IllegalPacketType;;3;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h +0x1b04;TCC_IllegalPacketSubtype;;4;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h +0x1b05;TCC_IncorrectPrimaryHeader;;5;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h +0x1b06;TCC_IncorrectSecondaryHeader;;6;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h 0x04e1;RMP_CommandNoDescriptorsAvailable;;225;RMAP_CHANNEL;fsfw/src/fsfw/rmap/RMAP.h 0x04e2;RMP_CommandBufferFull;;226;RMAP_CHANNEL;fsfw/src/fsfw/rmap/RMAP.h 0x04e3;RMP_CommandChannelOutOfRange;;227;RMAP_CHANNEL;fsfw/src/fsfw/rmap/RMAP.h @@ -359,15 +223,61 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x040a;RMP_ReplyCommandNotImplementedOrNotAuthorised;;10;RMAP_CHANNEL;fsfw/src/fsfw/rmap/RMAP.h 0x040b;RMP_ReplyRmwDataLengthError;;11;RMAP_CHANNEL;fsfw/src/fsfw/rmap/RMAP.h 0x040c;RMP_ReplyInvalidTargetLogicalAddress;;12;RMAP_CHANNEL;fsfw/src/fsfw/rmap/RMAP.h -0x1401;SE_BufferTooShort;;1;SERIALIZE_IF;fsfw/src/fsfw/serialize/SerializeIF.h -0x1402;SE_StreamTooShort;;2;SERIALIZE_IF;fsfw/src/fsfw/serialize/SerializeIF.h -0x1403;SE_TooManyElements;;3;SERIALIZE_IF;fsfw/src/fsfw/serialize/SerializeIF.h 0x2701;SM_DataTooLarge;;1;STORAGE_MANAGER_IF;fsfw/src/fsfw/storagemanager/StorageManagerIF.h 0x2702;SM_DataStorageFull;;2;STORAGE_MANAGER_IF;fsfw/src/fsfw/storagemanager/StorageManagerIF.h 0x2703;SM_IllegalStorageId;;3;STORAGE_MANAGER_IF;fsfw/src/fsfw/storagemanager/StorageManagerIF.h 0x2704;SM_DataDoesNotExist;;4;STORAGE_MANAGER_IF;fsfw/src/fsfw/storagemanager/StorageManagerIF.h 0x2705;SM_IllegalAddress;;5;STORAGE_MANAGER_IF;fsfw/src/fsfw/storagemanager/StorageManagerIF.h 0x2706;SM_PoolTooLarge;;6;STORAGE_MANAGER_IF;fsfw/src/fsfw/storagemanager/StorageManagerIF.h +0x37a1;SGP4_InvalidEccentricity;;161;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37a2;SGP4_InvalidMeanMotion;;162;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37a3;SGP4_InvalidPerturbationElements;;163;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37a4;SGP4_InvalidSemiLatusRectum;;164;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37a5;SGP4_InvalidEpochElements;;165;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37a6;SGP4_SatelliteHasDecayed;;166;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37b1;SGP4_TleTooOld;;177;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x37b2;SGP4_TleNotInitialized;;178;SGP4PROPAGATOR_CLASS;fsfw/src/fsfw/coordinates/Sgp4Propagator.h +0x2301;MT_TooDetailedRequest;;1;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h +0x2302;MT_TooGeneralRequest;;2;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h +0x2303;MT_NoMatch;;3;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h +0x2304;MT_Full;;4;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h +0x2305;MT_NewNodeCreated;;5;MATCH_TREE_CLASS;fsfw/src/fsfw/globalfunctions/matching/MatchTree.h +0x3e01;DLEE_StreamTooShort;;1;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h +0x3e02;DLEE_DecodingError;;2;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h +0x2e01;ASC_TooLongForTargetType;;1;ASCII_CONVERTER;fsfw/src/fsfw/globalfunctions/AsciiConverter.h +0x2e02;ASC_InvalidCharacters;;2;ASCII_CONVERTER;fsfw/src/fsfw/globalfunctions/AsciiConverter.h +0x2e03;ASC_BufferTooSmall;;3;ASCII_CONVERTER;fsfw/src/fsfw/globalfunctions/AsciiConverter.h +0x0f01;CM_UnknownCommand;;1;COMMAND_MESSAGE;fsfw/src/fsfw/ipc/CommandMessageIF.h +0x3901;MQI_Empty;;1;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h +0x3902;MQI_Full;No space left for more messages;2;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h +0x3903;MQI_NoReplyPartner;Returned if a reply method was called without partner;3;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h +0x3904;MQI_DestinationInvalid;Returned if the target destination is invalid.;4;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h +0x3801;MUX_NotEnoughResources;;1;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3802;MUX_InsufficientMemory;;2;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3803;MUX_NoPrivilege;;3;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3804;MUX_WrongAttributeSetting;;4;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3805;MUX_MutexAlreadyLocked;;5;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3806;MUX_MutexNotFound;;6;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3807;MUX_MutexMaxLocks;;7;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3808;MUX_CurrThreadAlreadyOwnsMutex;;8;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3809;MUX_CurrThreadDoesNotOwnMutex;;9;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x380a;MUX_MutexTimeout;;10;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x380b;MUX_MutexInvalidId;;11;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x380c;MUX_MutexDestroyedWhileWaiting;;12;MUTEX_IF;fsfw/src/fsfw/ipc/MutexIF.h +0x3a01;SPH_SemaphoreTimeout;;1;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h +0x3a02;SPH_SemaphoreNotOwned;;2;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h +0x3a03;SPH_SemaphoreInvalid;;3;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h +0x3501;CFDP_InvalidTlvType;;1;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3502;CFDP_InvalidDirectiveFields;;2;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3503;CFDP_InvalidPduDatafieldLen;;3;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3504;CFDP_InvalidAckDirectiveFields;;4;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3505;CFDP_MetadataCantParseOptions;;5;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3506;CFDP_FinishedCantParseFsResponses;;6;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3508;CFDP_FilestoreRequiresSecondFile;;8;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x3509;CFDP_FilestoreResponseCantParseFsMessage;;9;CFDP;fsfw/src/fsfw/cfdp/definitions.h +0x2801;TC_InvalidTargetState;;1;THERMAL_COMPONENT_IF;fsfw/src/fsfw/thermal/ThermalComponentIF.h +0x28f1;TC_AboveOperationalLimit;;241;THERMAL_COMPONENT_IF;fsfw/src/fsfw/thermal/ThermalComponentIF.h +0x28f2;TC_BelowOperationalLimit;;242;THERMAL_COMPONENT_IF;fsfw/src/fsfw/thermal/ThermalComponentIF.h 0x0c02;MS_InvalidEntry;;2;MODE_STORE_IF;fsfw/src/fsfw/subsystem/modes/ModeStoreIF.h 0x0c03;MS_TooManyElements;;3;MODE_STORE_IF;fsfw/src/fsfw/subsystem/modes/ModeStoreIF.h 0x0c04;MS_CantStoreEmpty;;4;MODE_STORE_IF;fsfw/src/fsfw/subsystem/modes/ModeStoreIF.h @@ -390,22 +300,22 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x0b03;SB_ChildDoesntHaveModes;;3;SUBSYSTEM_BASE;fsfw/src/fsfw/subsystem/SubsystemBase.h 0x0b04;SB_CouldNotInsertChild;;4;SUBSYSTEM_BASE;fsfw/src/fsfw/subsystem/SubsystemBase.h 0x0b05;SB_TableContainsInvalidObjectId;;5;SUBSYSTEM_BASE;fsfw/src/fsfw/subsystem/SubsystemBase.h -0x3a01;SPH_SemaphoreTimeout;;1;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h -0x3a02;SPH_SemaphoreNotOwned;;2;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h -0x3a03;SPH_SemaphoreInvalid;;3;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h -0x1c01;TCD_PacketLost;;1;PACKET_DISTRIBUTION;fsfw/src/fsfw/tcdistribution/TcDistributor.h -0x1c02;TCD_DestinationNotFound;;2;PACKET_DISTRIBUTION;fsfw/src/fsfw/tcdistribution/TcDistributor.h -0x1c03;TCD_ServiceIdAlreadyExists;;3;PACKET_DISTRIBUTION;fsfw/src/fsfw/tcdistribution/TcDistributor.h -0x1b00;TCC_IllegalApid;;0;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x1b01;TCC_IncompletePacket;;1;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x1b02;TCC_IncorrectChecksum;;2;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x1b03;TCC_IllegalPacketType;;3;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x1b04;TCC_IllegalPacketSubtype;;4;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x1b05;TCC_IncorrectPrimaryHeader;;5;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x1b06;TCC_IncorrectSecondaryHeader;;6;TC_PACKET_CHECK;fsfw/src/fsfw/tcdistribution/TcPacketCheckPUS.h -0x2801;TC_InvalidTargetState;;1;THERMAL_COMPONENT_IF;fsfw/src/fsfw/thermal/ThermalComponentIF.h -0x28f1;TC_AboveOperationalLimit;;241;THERMAL_COMPONENT_IF;fsfw/src/fsfw/thermal/ThermalComponentIF.h -0x28f2;TC_BelowOperationalLimit;;242;THERMAL_COMPONENT_IF;fsfw/src/fsfw/thermal/ThermalComponentIF.h +0x3d00;HKM_QueueOrDestinationInvalid;;0;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h +0x3d01;HKM_WrongHkPacketType;;1;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h +0x3d02;HKM_ReportingStatusUnchanged;;2;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h +0x3d03;HKM_PeriodicHelperInvalid;;3;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h +0x3d04;HKM_PoolobjectNotFound;;4;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h +0x3d05;HKM_DatasetNotFound;;5;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h +0x3b00;LPIF_PoolEntryNotFound;;0;LOCAL_POOL_OWNER_IF;fsfw/src/fsfw/datapoollocal/localPoolDefinitions.h +0x3b01;LPIF_PoolEntryTypeConflict;;1;LOCAL_POOL_OWNER_IF;fsfw/src/fsfw/datapoollocal/localPoolDefinitions.h +0x3ca0;PVA_InvalidReadWriteMode;;160;POOL_VARIABLE_IF;fsfw/src/fsfw/datapool/PoolVariableIF.h +0x3ca1;PVA_InvalidPoolEntry;;161;POOL_VARIABLE_IF;fsfw/src/fsfw/datapool/PoolVariableIF.h +0x0801;DPS_InvalidParameterDefinition;;1;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h +0x0802;DPS_SetWasAlreadyRead;;2;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h +0x0803;DPS_CommitingWithoutReading;;3;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h +0x0804;DPS_DataSetUninitialised;;4;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h +0x0805;DPS_DataSetFull;;5;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h +0x0806;DPS_PoolVarNull;;6;DATA_SET_CLASS;fsfw/src/fsfw/datapool/DataSetIF.h 0x1000;TIM_UnsupportedTimeFormat;;0;CCSDS_TIME_HELPER_CLASS;fsfw/src/fsfw/timemanager/CCSDSTime.h 0x1001;TIM_NotEnoughInformationForTargetFormat;;1;CCSDS_TIME_HELPER_CLASS;fsfw/src/fsfw/timemanager/CCSDSTime.h 0x1002;TIM_LengthMismatch;;2;CCSDS_TIME_HELPER_CLASS;fsfw/src/fsfw/timemanager/CCSDSTime.h @@ -413,35 +323,13 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x1004;TIM_InvalidDayOfYear;;4;CCSDS_TIME_HELPER_CLASS;fsfw/src/fsfw/timemanager/CCSDSTime.h 0x1005;TIM_TimeDoesNotFitFormat;;5;CCSDS_TIME_HELPER_CLASS;fsfw/src/fsfw/timemanager/CCSDSTime.h 0x3601;TSI_BadTimestamp;;1;TIME_STAMPER_IF;fsfw/src/fsfw/timemanager/TimeStamperIF.h -0x2001;TMB_Busy;;1;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2002;TMB_Full;;2;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2003;TMB_Empty;;3;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2004;TMB_NullRequested;;4;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2005;TMB_TooLarge;;5;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2006;TMB_NotReady;;6;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2007;TMB_DumpError;;7;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2008;TMB_CrcError;;8;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2009;TMB_Timeout;;9;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x200a;TMB_IdlePacketFound;;10;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x200b;TMB_TelecommandFound;;11;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x200c;TMB_NoPusATm;;12;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x200d;TMB_TooSmall;;13;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x200e;TMB_BlockNotFound;;14;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x200f;TMB_InvalidRequest;;15;TM_STORE_BACKEND_IF;fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h -0x2101;TMF_Busy;;1;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2102;TMF_LastPacketFound;;2;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2103;TMF_StopFetch;;3;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2104;TMF_Timeout;;4;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2105;TMF_TmChannelFull;;5;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2106;TMF_NotStored;;6;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2107;TMF_AllDeleted;;7;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2108;TMF_InvalidData;;8;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h -0x2109;TMF_NotReady;;9;TM_STORE_FRONTEND_IF;fsfw/src/fsfw/tmstorage/TmStoreFrontendIF.h 0x1d01;PUS_ActivityStarted;;1;ACCEPTS_TELECOMMANDS_IF;fsfw/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h 0x1d02;PUS_InvalidSubservice;;2;ACCEPTS_TELECOMMANDS_IF;fsfw/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h 0x1d03;PUS_IllegalApplicationData;;3;ACCEPTS_TELECOMMANDS_IF;fsfw/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h 0x1d04;PUS_SendTmFailed;;4;ACCEPTS_TELECOMMANDS_IF;fsfw/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h 0x1d05;PUS_Timeout;;5;ACCEPTS_TELECOMMANDS_IF;fsfw/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h +0x4b00;SPPA_NoPacketFound;;0;SPACE_PACKET_PARSER;fsfw/src/fsfw/tmtcservices/SpacePacketParser.h +0x4b01;SPPA_SplitPacket;;1;SPACE_PACKET_PARSER;fsfw/src/fsfw/tmtcservices/SpacePacketParser.h 0x1f01;CSB_ExecutionComplete;;1;COMMAND_SERVICE_BASE;fsfw/src/fsfw/tmtcservices/CommandingServiceBase.h 0x1f02;CSB_NoStepMessage;;2;COMMAND_SERVICE_BASE;fsfw/src/fsfw/tmtcservices/CommandingServiceBase.h 0x1f03;CSB_ObjectBusy;;3;COMMAND_SERVICE_BASE;fsfw/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -449,11 +337,122 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x1f05;CSB_InvalidTc;;5;COMMAND_SERVICE_BASE;fsfw/src/fsfw/tmtcservices/CommandingServiceBase.h 0x1f06;CSB_InvalidObject;;6;COMMAND_SERVICE_BASE;fsfw/src/fsfw/tmtcservices/CommandingServiceBase.h 0x1f07;CSB_InvalidReply;;7;COMMAND_SERVICE_BASE;fsfw/src/fsfw/tmtcservices/CommandingServiceBase.h -0x4b00;SPPA_NoPacketFound;;0;SPACE_PACKET_PARSER;fsfw/src/fsfw/tmtcservices/SpacePacketParser.h -0x4b01;SPPA_SplitPacket;;1;SPACE_PACKET_PARSER;fsfw/src/fsfw/tmtcservices/SpacePacketParser.h +0x1101;AL_Full;;1;ARRAY_LIST;fsfw/src/fsfw/container/ArrayList.h +0x1801;FF_Full;;1;FIFO_CLASS;fsfw/src/fsfw/container/FIFOBase.h +0x1802;FF_Empty;;2;FIFO_CLASS;fsfw/src/fsfw/container/FIFOBase.h +0x1601;FMM_MapFull;;1;FIXED_MULTIMAP;fsfw/src/fsfw/container/FixedOrderedMultimap.h +0x1602;FMM_KeyDoesNotExist;;2;FIXED_MULTIMAP;fsfw/src/fsfw/container/FixedOrderedMultimap.h +0x1501;FM_KeyAlreadyExists;;1;FIXED_MAP;fsfw/src/fsfw/container/FixedMap.h +0x1502;FM_MapFull;;2;FIXED_MAP;fsfw/src/fsfw/container/FixedMap.h +0x1503;FM_KeyDoesNotExist;;3;FIXED_MAP;fsfw/src/fsfw/container/FixedMap.h +0x2401;EV_ListenerNotFound;;1;EVENT_MANAGER_IF;fsfw/src/fsfw/events/EventManagerIF.h +0x1701;HHI_ObjectNotHealthy;;1;HAS_HEALTH_IF;fsfw/src/fsfw/health/HasHealthIF.h +0x1702;HHI_InvalidHealthState;;2;HAS_HEALTH_IF;fsfw/src/fsfw/health/HasHealthIF.h +0x1703;HHI_IsExternallyControlled;;3;HAS_HEALTH_IF;fsfw/src/fsfw/health/HasHealthIF.h +0x2f01;POS_InPowerTransition;;1;POWER_SWITCHER;fsfw/src/fsfw/power/PowerSwitcher.h +0x2f02;POS_SwitchStateMismatch;;2;POWER_SWITCHER;fsfw/src/fsfw/power/PowerSwitcher.h +0x0501;PS_SwitchOn;;1;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h +0x0500;PS_SwitchOff;;0;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h +0x0502;PS_SwitchTimeout;;2;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h +0x0503;PS_FuseOn;;3;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h +0x0504;PS_FuseOff;;4;POWER_SWITCH_IF;fsfw/src/fsfw/power/PowerSwitchIF.h +0x1a01;TRC_NotEnoughSensors;;1;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h +0x1a02;TRC_LowestValueOol;;2;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h +0x1a03;TRC_HighestValueOol;;3;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h +0x1a04;TRC_BothValuesOol;;4;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h +0x1a05;TRC_DuplexOol;;5;TRIPLE_REDUNDACY_CHECK;fsfw/src/fsfw/monitoring/TriplexMonitor.h +0x3001;LIM_Unchecked;;1;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x3002;LIM_Invalid;;2;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x3003;LIM_Unselected;;3;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x3004;LIM_BelowLowLimit;;4;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x3005;LIM_AboveHighLimit;;5;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x3006;LIM_UnexpectedValue;;6;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x3007;LIM_OutOfRange;;7;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x30a0;LIM_FirstSample;;160;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x30e0;LIM_InvalidSize;;224;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x30e1;LIM_WrongType;;225;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x30e2;LIM_WrongPid;;226;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x30e3;LIM_WrongLimitId;;227;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x30ee;LIM_MonitorNotFound;;238;LIMITS_IF;fsfw/src/fsfw/monitoring/MonitoringIF.h +0x4101;PUS11_InvalidTypeTimeWindow;;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4102;PUS11_TimeshiftingNotPossible;;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4103;PUS11_InvalidRelativeTime;;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4200;FILS_GenericFileError;;0;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x4201;FILS_IsBusy;;1;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x4202;FILS_InvalidParameters;;2;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x4205;FILS_FileDoesNotExist;;5;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x4206;FILS_FileAlreadyExists;;6;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x4207;FILS_FileLocked;;7;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x420a;FILS_DirectoryDoesNotExist;;10;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x420b;FILS_DirectoryAlreadyExists;;11;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x420c;FILS_DirectoryNotEmpty;;12;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x420f;FILS_SequencePacketMissingWrite;;15;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x4210;FILS_SequencePacketMissingRead;;16;FILE_SYSTEM;fsfw/src/fsfw/memory/HasFileSystemIF.h +0x0601;PP_DoItMyself;;1;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0602;PP_PointsToVariable;;2;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0603;PP_PointsToMemory;;3;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0604;PP_ActivityCompleted;;4;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0605;PP_PointsToVectorUint8;;5;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0606;PP_PointsToVectorUint16;;6;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0607;PP_PointsToVectorUint32;;7;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x0608;PP_PointsToVectorFloat;;8;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x06a0;PP_DumpNotSupported;;160;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x06e0;PP_InvalidSize;;224;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x06e1;PP_InvalidAddress;;225;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x06e2;PP_InvalidContent;;226;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x06e3;PP_UnalignedAccess;;227;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x06e4;PP_WriteProtected;;228;HAS_MEMORY_IF;fsfw/src/fsfw/memory/HasMemoryIF.h +0x13e0;MH_UnknownCmd;;224;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h +0x13e1;MH_InvalidAddress;;225;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h +0x13e2;MH_InvalidSize;;226;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h +0x13e3;MH_StateMismatch;;227;MEMORY_HELPER;fsfw/src/fsfw/memory/MemoryHelper.h +0x1201;AB_NeedSecondStep;;1;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h +0x1202;AB_NeedToReconfigure;;2;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h +0x1203;AB_ModeFallback;;3;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h +0x1204;AB_ChildNotCommandable;;4;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h +0x1205;AB_NeedToChangeHealth;;5;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h +0x12a1;AB_NotEnoughChildrenInCorrectState;;161;ASSEMBLY_BASE;fsfw/src/fsfw/devicehandlers/AssemblyBase.h +0x03a0;DHB_InvalidChannel;;160;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03b0;DHB_AperiodicReply;;176;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03b1;DHB_IgnoreReplyData;;177;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03b2;DHB_IgnoreFullPacket;;178;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03c0;DHB_NothingToSend;;192;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03c2;DHB_CommandMapError;;194;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03d0;DHB_NoSwitch;;208;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03e0;DHB_ChildTimeout;;224;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x03e1;DHB_SwitchFailed;;225;DEVICE_HANDLER_BASE;fsfw/src/fsfw/devicehandlers/DeviceHandlerBase.h +0x3301;DC_NoReplyReceived;;1;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h +0x3302;DC_ProtocolError;;2;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h +0x3303;DC_Nullpointer;;3;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h +0x3304;DC_InvalidCookieType;;4;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h +0x3305;DC_NotActive;;5;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h +0x3306;DC_TooMuchData;;6;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h +0x26a0;DHI_NoCommandData;;160;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a1;DHI_CommandNotSupported;;161;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a2;DHI_CommandAlreadySent;;162;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a3;DHI_CommandWasNotSent;;163;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a4;DHI_CantSwitchAddress;;164;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a5;DHI_WrongModeForCommand;;165;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a6;DHI_Timeout;;166;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a7;DHI_Busy;;167;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a8;DHI_NoReplyExpected;;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26a9;DHI_NonOpTemperature;;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26aa;DHI_CommandNotImplemented;;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26b0;DHI_ChecksumError;;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26b1;DHI_LengthMissmatch;;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26b2;DHI_InvalidData;;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26b3;DHI_ProtocolError;;179;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26c0;DHI_DeviceDidNotExecute;;192;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26c1;DHI_DeviceReportedError;;193;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26c2;DHI_UnknownDeviceReply;;194;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26c3;DHI_DeviceReplyInvalid;;195;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26d0;DHI_InvalidCommandParameter;;208;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x26d1;DHI_InvalidNumberOrLengthOfParameters;;209;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x1401;SE_BufferTooShort;;1;SERIALIZE_IF;fsfw/src/fsfw/serialize/SerializeIF.h +0x1402;SE_StreamTooShort;;2;SERIALIZE_IF;fsfw/src/fsfw/serialize/SerializeIF.h +0x1403;SE_TooManyElements;;3;SERIALIZE_IF;fsfw/src/fsfw/serialize/SerializeIF.h 0x68a0;FSHLP_SdNotMounted;SD card specified with path string not mounted;160;FILE_SYSTEM_HELPER;bsp_q7s/memory/FilesystemHelper.h 0x68a1;FSHLP_FileNotExists;Specified file does not exist on filesystem;161;FILE_SYSTEM_HELPER;bsp_q7s/memory/FilesystemHelper.h -0x7400;SCBU_KeyNotFound;;0;SCRATCH_BUFFER;bsp_q7s/memory/scratchApi.h 0x7300;SDMA_OpOngoing;;0;SD_CARD_MANAGER;bsp_q7s/memory/SdCardManager.h 0x7301;SDMA_AlreadyOn;;1;SD_CARD_MANAGER;bsp_q7s/memory/SdCardManager.h 0x7302;SDMA_AlreadyMounted;;2;SD_CARD_MANAGER;bsp_q7s/memory/SdCardManager.h @@ -464,3 +463,4 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x730d;SDMA_UnmountError;;13;SD_CARD_MANAGER;bsp_q7s/memory/SdCardManager.h 0x730e;SDMA_SystemCallError;;14;SD_CARD_MANAGER;bsp_q7s/memory/SdCardManager.h 0x730f;SDMA_PopenCallError;;15;SD_CARD_MANAGER;bsp_q7s/memory/SdCardManager.h +0x7400;SCBU_KeyNotFound;;0;SCRATCH_BUFFER;bsp_q7s/memory/scratchApi.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 7f9cfc78..bf0954cd 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 209 translations. + * @brief Auto-generated event translation file. Contains 210 translations. * @details - * Generated on: 2022-06-27 09:14:37 + * Generated on: 2022-07-08 16:45:10 */ #include "translateEvents.h" @@ -210,6 +210,7 @@ const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_HW_STRING = "REBOOT_HW"; +const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT"; const char *translateEvents(Event event) { switch ((event & 0xFFFF)) { @@ -623,6 +624,8 @@ const char *translateEvents(Event event) { return REBOOT_MECHANISM_TRIGGERED_STRING; case (13703): return REBOOT_HW_STRING; + case (13800): + return EXPERIMENT_TIMEDOUT_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 2b6dc330..0868cdb0 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 132 translations. - * Generated on: 2022-06-27 09:14:34 + * Contains 134 translations. + * Generated on: 2022-07-08 16:45:09 */ #include "translateObjects.h" @@ -54,6 +54,7 @@ const char *PTME_CONFIG_STRING = "PTME_CONFIG"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *PLOC_SUPERVISOR_HELPER_STRING = "PLOC_SUPERVISOR_HELPER"; +const char *SCEX_STRING = "SCEX"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; @@ -77,6 +78,7 @@ const char *RTD_15_IC18_IMTQ_STRING = "RTD_15_IC18_IMTQ"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; const char *GPIO_IF_STRING = "GPIO_IF"; +const char *SCEX_UART_READER_STRING = "SCEX_UART_READER"; const char *SPI_MAIN_COM_IF_STRING = "SPI_MAIN_COM_IF"; const char *SPI_RW_COM_IF_STRING = "SPI_RW_COM_IF"; const char *SPI_RTD_COM_IF_STRING = "SPI_RTD_COM_IF"; @@ -237,6 +239,8 @@ const char *translateObject(object_id_t object) { return PLOC_SUPERVISOR_HANDLER_STRING; case 0x44330017: return PLOC_SUPERVISOR_HELPER_STRING; + case 0x44330032: + return SCEX_STRING; case 0x444100A2: return SOLAR_ARRAY_DEPL_HANDLER_STRING; case 0x444100A4: @@ -283,6 +287,8 @@ const char *translateObject(object_id_t object) { return ARDUINO_COM_IF_STRING; case 0x49010005: return GPIO_IF_STRING; + case 0x49010006: + return SCEX_UART_READER_STRING; case 0x49020004: return SPI_MAIN_COM_IF_STRING; case 0x49020005: diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 7f9cfc78..bf0954cd 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 209 translations. + * @brief Auto-generated event translation file. Contains 210 translations. * @details - * Generated on: 2022-06-27 09:14:37 + * Generated on: 2022-07-08 16:45:10 */ #include "translateEvents.h" @@ -210,6 +210,7 @@ const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_HW_STRING = "REBOOT_HW"; +const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT"; const char *translateEvents(Event event) { switch ((event & 0xFFFF)) { @@ -623,6 +624,8 @@ const char *translateEvents(Event event) { return REBOOT_MECHANISM_TRIGGERED_STRING; case (13703): return REBOOT_HW_STRING; + case (13800): + return EXPERIMENT_TIMEDOUT_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 2b6dc330..0868cdb0 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 132 translations. - * Generated on: 2022-06-27 09:14:34 + * Contains 134 translations. + * Generated on: 2022-07-08 16:45:09 */ #include "translateObjects.h" @@ -54,6 +54,7 @@ const char *PTME_CONFIG_STRING = "PTME_CONFIG"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *PLOC_SUPERVISOR_HELPER_STRING = "PLOC_SUPERVISOR_HELPER"; +const char *SCEX_STRING = "SCEX"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; @@ -77,6 +78,7 @@ const char *RTD_15_IC18_IMTQ_STRING = "RTD_15_IC18_IMTQ"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; const char *GPIO_IF_STRING = "GPIO_IF"; +const char *SCEX_UART_READER_STRING = "SCEX_UART_READER"; const char *SPI_MAIN_COM_IF_STRING = "SPI_MAIN_COM_IF"; const char *SPI_RW_COM_IF_STRING = "SPI_RW_COM_IF"; const char *SPI_RTD_COM_IF_STRING = "SPI_RTD_COM_IF"; @@ -237,6 +239,8 @@ const char *translateObject(object_id_t object) { return PLOC_SUPERVISOR_HANDLER_STRING; case 0x44330017: return PLOC_SUPERVISOR_HELPER_STRING; + case 0x44330032: + return SCEX_STRING; case 0x444100A2: return SOLAR_ARRAY_DEPL_HANDLER_STRING; case 0x444100A4: @@ -283,6 +287,8 @@ const char *translateObject(object_id_t object) { return ARDUINO_COM_IF_STRING; case 0x49010005: return GPIO_IF_STRING; + case 0x49010006: + return SCEX_UART_READER_STRING; case 0x49020004: return SPI_MAIN_COM_IF_STRING; case 0x49020005: diff --git a/tmtc b/tmtc index 370d6c2f..1a73fa1f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 370d6c2fa4e9c84d96d23cbae6711cdf68cdd465 +Subproject commit 1a73fa1ff126466c9444664f1825e7c34a27453f -- 2.43.0 From fc639a3e3fc7becc1714c8552b82020ab5682172 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 16:57:40 +0200 Subject: [PATCH 42/48] move countdown reset --- mission/devices/ScexDeviceHandler.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 7417ca0d..85fbdc3a 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -52,36 +52,57 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic switch (deviceCommand) { case (PING): { + finishCountdown.setTimeout(SHORT_CD); + // countdown starten + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, tempCheck); break; } case (EXP_STATUS_CMD): { + finishCountdown.setTimeout(SHORT_CD); + // countdown starten + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, tempCheck); break; } case (ION_CMD): { + finishCountdown.setTimeout(SHORT_CD); + // countdown starten + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, tempCheck); break; } case (TEMP_CMD): { + finishCountdown.setTimeout(SHORT_CD); + // countdown starten + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {nullptr, 0}, tempCheck); break; } case (FRAM): { + finishCountdown.setTimeout(SHORT_CD); + // countdown starten + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); break; } case (ONE_CELL): { + finishCountdown.setTimeout(LONG_CD); + // countdown starts + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); break; } case (ALL_CELLS_CMD): { + finishCountdown.setTimeout(LONG_CD); + // countdown starts + finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); break; @@ -130,9 +151,6 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons ReturnValue_t status = RETURN_OK; auto oneFileHandler = [&](std::string cmdName) { fileId = random_string(6); - finishCountdown.setTimeout(SHORT_CD); - // countdown starten - finishCountdown.resetTimer(); std::ostringstream oss("/tmp/scex-"); oss << cmdName << fileId << ".bin"; fileName = oss.str(); @@ -149,9 +167,6 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons }; auto multiFileHandler = [&](std::string cmdName) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { - finishCountdown.setTimeout(LONG_CD); - // countdown starts - finishCountdown.resetTimer(); fileId = random_string(6); std::ostringstream oss("/tmp/scex-"); -- 2.43.0 From 303f5380761ee8a04721d4692c70757ec9369acd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 17:11:21 +0200 Subject: [PATCH 43/48] countdown based reply handling --- mission/devices/ScexDeviceHandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 85fbdc3a..4c84b40d 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -122,9 +122,12 @@ void ScexDeviceHandler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); - insertInCommandMap(scex::Cmds::ALL_CELLS_CMD); - insertInCommandMap(scex::Cmds::ONE_CELL); - insertInCommandMap(scex::Cmds::FRAM); + insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, false, false, + DeviceHandlerIF::UNKNOWN_DEVICE_REPLY, &finishCountdown); + insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false, + DeviceHandlerIF::UNKNOWN_DEVICE_REPLY, &finishCountdown); + insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, false, false, + DeviceHandlerIF::UNKNOWN_DEVICE_REPLY, &finishCountdown); insertInReplyMap(scex::Cmds::ERROR_REPLY, 3); } -- 2.43.0 From d1bfc512ec9adde8b30cc29a99d2e0a49ae778b0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Jul 2022 10:32:41 +0200 Subject: [PATCH 44/48] update .cproject file --- misc/eclipse/.cproject | 24 ++++++++++++------------ tmtc | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index d30ef1ec..19c18545 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -57,7 +57,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -187,7 +187,7 @@ - + @@ -255,7 +255,7 @@ - + @@ -418,7 +418,7 @@ - + @@ -580,7 +580,7 @@ - + @@ -750,7 +750,7 @@ - + @@ -917,7 +917,7 @@ - + @@ -1084,7 +1084,7 @@ - + @@ -1149,7 +1149,7 @@ - + @@ -1317,7 +1317,7 @@ - + @@ -1386,7 +1386,7 @@ - + diff --git a/tmtc b/tmtc index 1a73fa1f..70435736 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1a73fa1ff126466c9444664f1825e7c34a27453f +Subproject commit 704357369e6374dc7cf8c88d71fd24bce3b772e0 -- 2.43.0 From 8b39f65472280ed5f9da6df62cd527519f41c5d7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Jul 2022 11:25:53 +0200 Subject: [PATCH 45/48] modify oss to append at end --- bsp_q7s/memory/scratchApi.cpp | 8 ++++---- bsp_q7s/memory/scratchApi.h | 4 ++-- mission/devices/ScexDeviceHandler.cpp | 5 +++-- tmtc | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/memory/scratchApi.cpp b/bsp_q7s/memory/scratchApi.cpp index 83bc8239..1948ece3 100644 --- a/bsp_q7s/memory/scratchApi.cpp +++ b/bsp_q7s/memory/scratchApi.cpp @@ -1,8 +1,8 @@ #include "scratchApi.h" ReturnValue_t scratch::writeString(std::string name, std::string string) { - std::ostringstream oss; - oss << "xsc_scratch write " << name << " \"" << string << "\""; + std::ostringstream oss("xsc_scratch write ", std::ostringstream::ate); + oss << name << " \"" << string << "\""; int result = std::system(oss.str().c_str()); if (result != 0) { utility::handleSystemError(result, "scratch::writeString"); @@ -39,8 +39,8 @@ ReturnValue_t scratch::readString(std::string key, std::string &string) { } ReturnValue_t scratch::clearValue(std::string key) { - std::ostringstream oss; - oss << "xsc_scratch clear " << key; + std::ostringstream oss("xsc_scratch clear ", std::ostringstream::ate); + oss << key; int result = std::system(oss.str().c_str()); if (result != 0) { utility::handleSystemError(result, "scratch::clearValue"); diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index cd76fca1..b78fef7f 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -94,8 +94,8 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil template ::value>::type> inline ReturnValue_t writeNumber(std::string key, T num) noexcept { - std::ostringstream oss; - oss << "xsc_scratch write " << key << " " << std::to_string(num); + std::ostringstream oss("xsc_scratch write ", std::ostringstream::ate); + oss << key << " " << std::to_string(num); int result = std::system(oss.str().c_str()); if (result != 0) { utility::handleSystemError(result, "scratch::writeNumber"); diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 4c84b40d..5cc11d7c 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -154,9 +154,10 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons ReturnValue_t status = RETURN_OK; auto oneFileHandler = [&](std::string cmdName) { fileId = random_string(6); - std::ostringstream oss("/tmp/scex-"); + std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); oss << cmdName << fileId << ".bin"; fileName = oss.str(); + std::cout << fileName << std::endl; ofstream out(fileName, ofstream::binary); if (out.bad()) { sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName @@ -172,7 +173,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { fileId = random_string(6); - std::ostringstream oss("/tmp/scex-"); + std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); oss << cmdName << fileId << ".bin"; fileName = oss.str(); fileNameSet = true; diff --git a/tmtc b/tmtc index 70435736..0a655f51 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 704357369e6374dc7cf8c88d71fd24bce3b772e0 +Subproject commit 0a655f51d4803d5561911101823e611d1f4a19ad -- 2.43.0 From 8a236154627a730af48090cf2932230abd01bc18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Jul 2022 12:02:32 +0200 Subject: [PATCH 46/48] added printout in scex uart reader --- linux/boardtest/UartTestClass.cpp | 3 ++- linux/devices/ScexUartReader.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 86404c44..d771fe37 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -29,6 +29,7 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; scexMode = ScexModes::READER_TASK; + // No one-cell and all-cell support implemented yet currCmd = scex::Cmds::FRAM; if (scexMode == ScexModes::SIMPLE) { auto encodingBuf = new std::array; @@ -213,7 +214,7 @@ void UartTestClass::scexPeriodic() { out << helper; } // fram - // packetcounter eins höher, wenn mehr packet verloren -> merkt sich welches packet fehlt + // packetcounter eins h�her, wenn mehr packet verloren -> merkt sich welches packet fehlt // was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit // finish false wird? // countdown (max 2min), wenn nicht if (helper.getPacketCounter() == diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index b4e48612..31fc4bf1 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -133,6 +133,7 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl; return RETURN_FAILED; } + arrayprinter::print(cmdbuf.data(), encodedLen); size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen); if (bytesWritten != encodedLen) { sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed" -- 2.43.0 From 201ef9cb0c9ced2b60bad8ea41dbc56f7d0a7ab0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Jul 2022 15:51:21 +0200 Subject: [PATCH 47/48] smaller bugfixes --- mission/devices/ScexDeviceHandler.cpp | 8 ++++---- tmtc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 5cc11d7c..edd9e6e9 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -84,7 +84,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic break; } case (FRAM): { - finishCountdown.setTimeout(SHORT_CD); + finishCountdown.setTimeout(LONG_CD); // countdown starten finishCountdown.resetTimer(); prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, @@ -123,11 +123,11 @@ void ScexDeviceHandler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, false, false, - DeviceHandlerIF::UNKNOWN_DEVICE_REPLY, &finishCountdown); + scex::Cmds::ALL_CELLS_CMD, &finishCountdown); insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false, - DeviceHandlerIF::UNKNOWN_DEVICE_REPLY, &finishCountdown); + scex::Cmds::ONE_CELL, &finishCountdown); insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, false, false, - DeviceHandlerIF::UNKNOWN_DEVICE_REPLY, &finishCountdown); + scex::Cmds::FRAM, &finishCountdown); insertInReplyMap(scex::Cmds::ERROR_REPLY, 3); } diff --git a/tmtc b/tmtc index 0a655f51..937eb482 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 0a655f51d4803d5561911101823e611d1f4a19ad +Subproject commit 937eb4829883b17e3a7a842528675c3609e24768 -- 2.43.0 From 86337d8f4705872d282784f29a890fd64e6f38ea Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 16:05:05 +0200 Subject: [PATCH 48/48] retval replacements --- linux/boardtest/UartTestClass.cpp | 24 +++++----- linux/boardtest/UartTestClass.h | 2 +- linux/devices/ScexHelper.cpp | 8 ++-- linux/devices/ScexHelper.h | 8 ++-- linux/devices/ScexUartReader.cpp | 44 ++++++++++--------- mission/devices/ScexDeviceHandler.cpp | 25 ++++++----- .../devicedefinitions/ScexDefinitions.cpp | 4 +- 7 files changed, 57 insertions(+), 58 deletions(-) diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index ec243c4f..9843baa5 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -25,6 +25,8 @@ #define RPI_TEST_GPS_HANDLER 0 #endif +using namespace returnvalue; + UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) : TestTask(objectId), reader(reader) { mode = TestModes::SCEX; @@ -163,7 +165,7 @@ void UartTestClass::scexInit() { uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); reader->setDebugMode(false); ReturnValue_t result = reader->initializeInterface(uartCookie); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != OK) { sif::warning << "UartTestClass::scexInit: Initializing SCEX reader " "UART IF failed" << std::endl; @@ -306,7 +308,7 @@ void UartTestClass::scexSimpleInit() { void UartTestClass::scexSimplePeriodic() { using namespace scex; - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = OK; if (not cmdSent) { // Flush received and unread data tcflush(serialPort, TCIFLUSH); @@ -315,7 +317,7 @@ void UartTestClass::scexSimplePeriodic() { sif::info << "UartTestClass::scexSimplePeriodic: Sending command to SCEX" << std::endl; prepareScexCmd(currCmd, false, tmpCmdBuf, &len); result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != OK) { sif::warning << "UartTestClass::scexSimplePeriodic: Encoding failed" << std::endl; return; } @@ -368,17 +370,11 @@ int UartTestClass::prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBu cmdBuf[1] = 1; cmdBuf[2] = 1; uint16_t userDataLen = 0; - tmpCmdBuf[3] = (userDataLen >> 8) & 0xff; - tmpCmdBuf[4] = userDataLen & 0xff; - uint16_t crc = CRC::crc16ccitt(tmpCmdBuf.data(), 5); - tmpCmdBuf[5] = (crc >> 8) & 0xff; - tmpCmdBuf[6] = crc & 0xff; - ReturnValue_t result = - dleEncoder.encode(tmpCmdBuf.data(), 7, cmdBuf.data(), cmdBuf.size(), &encodedLen, true); - if (result != returnvalue::OK) { - sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl; - return -1; - } + cmdBuf[3] = (userDataLen >> 8) & 0xff; + cmdBuf[4] = userDataLen & 0xff; + uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); + cmdBuf[5] = (crc >> 8) & 0xff; + cmdBuf[6] = crc & 0xff; return 0; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index efe15dc1..1c1b9988 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -67,7 +67,7 @@ class UartTestClass : public TestTask { std::array cmdBuf = {}; std::array recBuf = {}; ScexDleParser* dleParser; - scex::Cmds cmdHelper; + scex::Cmds cmdHelper = scex::Cmds::INVALID; uint8_t recvCnt = 0; }; diff --git a/linux/devices/ScexHelper.cpp b/linux/devices/ScexHelper.cpp index 3e61d346..bce5fbda 100644 --- a/linux/devices/ScexHelper.cpp +++ b/linux/devices/ScexHelper.cpp @@ -4,11 +4,13 @@ #include "fsfw/serviceinterface.h" +using namespace returnvalue; + ScexHelper::ScexHelper() {} ReturnValue_t ScexHelper::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { - return RETURN_FAILED; + return FAILED; } size_t ScexHelper::getSerializedSize() const { return totalPacketLen; } @@ -16,7 +18,7 @@ size_t ScexHelper::getSerializedSize() const { return totalPacketLen; } ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return RETURN_FAILED; + return FAILED; } if (*size < 7) { return STREAM_TOO_SHORT; @@ -45,7 +47,7 @@ ReturnValue_t ScexHelper::deSerialize(const uint8_t** buffer, size_t* size, if (CRC::crc16ccitt(start, totalPacketLen) != 0) { return INVALID_CRC; } - return RETURN_OK; + return OK; } scex::Cmds ScexHelper::getCmd() const { return cmd; } diff --git a/linux/devices/ScexHelper.h b/linux/devices/ScexHelper.h index eb258568..f2adf617 100644 --- a/linux/devices/ScexHelper.h +++ b/linux/devices/ScexHelper.h @@ -7,12 +7,10 @@ #include #include #include -// ScexHelper helper; -// helper.deSerialize(data, ...); -// sif::info << helper << std::endl; -class ScexHelper : public HasReturnvaluesIF, public SerializeIF { + +class ScexHelper : public SerializeIF { public: - static const ReturnValue_t INVALID_CRC = HasReturnvaluesIF::makeReturnCode(0, 2); + static const ReturnValue_t INVALID_CRC = returnvalue::makeCode(0, 2); ScexHelper(); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 31fc4bf1..38286a7a 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -14,6 +14,8 @@ #include "OBSWConfig.h" +using namespace returnvalue; + ScexUartReader::ScexUartReader(object_id_t objectId) : SystemObject(objectId), decodeRingBuf(4096, true), @@ -58,7 +60,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { sif::info << "Received " << bytesRead << " bytes from the Solar Cell Experiment:" << std::endl; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != OK) { sif::warning << "ScexUartReader::performOperation: Passing data to DLE parser failed" << std::endl; } @@ -67,13 +69,13 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { // task block comes here sif::info << "task was stopped" << std::endl; } - return RETURN_OK; + return OK; } ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { UartCookie *uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { - return RETURN_FAILED; + return FAILED; } std::string devname = uartCookie->getDeviceFile(); /* Get file descriptor */ @@ -81,7 +83,7 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { if (serialPort < 0) { sif::warning << "ScexUartReader::initializeInterface: open call failed with error [" << errno << ", " << strerror(errno) << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return FAILED; } // Setting up UART parameters tty.c_cflag &= ~PARENB; // Clear parity bit @@ -111,46 +113,46 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { } // Flush received and unread data tcflush(serialPort, TCIOFLUSH); - return RETURN_OK; + return OK; } ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { if (sendData == nullptr or sendLen == 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return FAILED; } lock->lockMutex(); if (state == States::NOT_READY or state == States::RUNNING) { lock->unlockMutex(); - return HasReturnvaluesIF::RETURN_FAILED; + return FAILED; } state = States::RUNNING; lock->unlockMutex(); size_t encodedLen = 0; ReturnValue_t result = dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != OK) { sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl; - return RETURN_FAILED; + return FAILED; } arrayprinter::print(cmdbuf.data(), encodedLen); size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen); if (bytesWritten != encodedLen) { sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed" << std::endl; - return RETURN_FAILED; + return FAILED; } result = semaphore->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != OK) { std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl; } - return RETURN_OK; + return OK; } -ReturnValue_t ScexUartReader::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t ScexUartReader::getSendSuccess(CookieIF *cookie) { return OK; } ReturnValue_t ScexUartReader::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return RETURN_OK; + return OK; } void ScexUartReader::setDebugMode(bool enable) { this->debugMode = enable; } @@ -158,10 +160,10 @@ void ScexUartReader::setDebugMode(bool enable) { this->debugMode = enable; } ReturnValue_t ScexUartReader::finish() { MutexGuard mg(lock); if (state == States::IDLE) { - return HasReturnvaluesIF::RETURN_FAILED; + return FAILED; } state = States::FINISH; - return RETURN_OK; + return OK; } void ScexUartReader::foundDlePacketHandler(const ScexDleParser::Context &ctx) { @@ -178,11 +180,11 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) { // sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; MutexGuard mg(lock); ReturnValue_t result = ipcQueue.insert(len); - if (result != RETURN_OK) { + if (result != OK) { sif::warning << "ScexUartReader::handleFoundDlePacket: IPCQueue error" << std::endl; } result = ipcRingBuf.writeData(packet, len); - if (result != RETURN_OK) { + if (result != OK) { sif::warning << "ScexUartReader::handleFoundDlePacket: IPCRingBuf error" << std::endl; } } @@ -192,13 +194,13 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu MutexGuard mg(lock); if (ipcQueue.empty()) { *size = 0; - return RETURN_OK; + return OK; } ipcQueue.retrieve(size); *buffer = ipcBuffer.data(); ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true); - if (result != RETURN_OK) { + if (result != OK) { sif::warning << "ScexUartReader::readReceivedMessage: Reading RingBuffer failed" << std::endl; } - return RETURN_OK; + return OK; } diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index edd9e6e9..15dd05cb 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -11,6 +11,7 @@ #include "mission/devices/devicedefinitions/ScexDefinitions.h" using std::ofstream; +using namespace returnvalue; ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie, SdCardMountedIF* sdcMan) @@ -26,11 +27,11 @@ void ScexDeviceHandler::doStartUp() { void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - return RETURN_OK; + return OK; } ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - return RETURN_OK; + return OK; } ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, @@ -113,7 +114,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic } commandActive = true; rawPacket = cmdBuf.data(); - return RETURN_OK; + return OK; } void ScexDeviceHandler::fillCommandAndReplyMap() { @@ -144,14 +145,14 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai *foundId = helper.getCmd(); *foundLen = remainingSize; - return RETURN_OK; + return OK; } ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { // cmd auswertung (in file reinschreiben) using namespace scex; - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = OK; auto oneFileHandler = [&](std::string cmdName) { fileId = random_string(6); std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); @@ -162,12 +163,12 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons if (out.bad()) { sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName << std::endl; - return RETURN_FAILED; + return FAILED; } if (debugMode) { out << helper; } - return RETURN_OK; + return OK; }; auto multiFileHandler = [&](std::string cmdName) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { @@ -181,7 +182,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons if (out.bad()) { sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName << std::endl; - return RETURN_FAILED; + return FAILED; } } else { ofstream out(fileName, @@ -191,7 +192,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons } } - return RETURN_OK; + return OK; }; switch (id) { case (PING): { @@ -249,16 +250,16 @@ void ScexDeviceHandler::performOperationHook() { } uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return RETURN_OK; + return OK; } ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { - return RETURN_OK; + return OK; } ReturnValue_t ScexDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - return RETURN_OK; + return OK; } std::string ScexDeviceHandler::random_string(std::string::size_type length) { diff --git a/mission/devices/devicedefinitions/ScexDefinitions.cpp b/mission/devices/devicedefinitions/ScexDefinitions.cpp index 8685862e..c4319876 100644 --- a/mission/devices/devicedefinitions/ScexDefinitions.cpp +++ b/mission/devices/devicedefinitions/ScexDefinitions.cpp @@ -17,7 +17,7 @@ ReturnValue_t scex::prepareScexCmd(Cmds cmd, std::pair cmdBufP if (cmdBuf == nullptr or (cmdBufPair.second < usrDataPair.second + HEADER_LEN + CRC_LEN) or (usrDataPair.second > 0 and userData == nullptr)) { cmdLen = 0; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } cmdBuf[0] = createCmdByte(cmd, tempCheck); // These two fields are the packet counter and the total packet count. Those are 1 and 1 for each @@ -31,5 +31,5 @@ ReturnValue_t scex::prepareScexCmd(Cmds cmd, std::pair cmdBufP cmdBuf[usrDataPair.second + HEADER_LEN] = (crc >> 8) & 0xff; cmdBuf[usrDataPair.second + HEADER_LEN + 1] = crc & 0xff; cmdLen = usrDataPair.second + HEADER_LEN + CRC_LEN; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -- 2.43.0