2022-03-25 17:48:38 +01:00
|
|
|
#ifndef LINUX_DEVICES_SCEXUARTREADER_H_
|
|
|
|
#define LINUX_DEVICES_SCEXUARTREADER_H_
|
2022-04-08 19:12:21 +02:00
|
|
|
|
|
|
|
#include <fsfw/container/DynamicFIFO.h>
|
|
|
|
#include <fsfw/container/SimpleRingBuffer.h>
|
|
|
|
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
|
|
|
#include <fsfw/globalfunctions/DleEncoder.h>
|
2022-03-25 17:48:38 +01:00
|
|
|
#include <fsfw/objectmanager/SystemObject.h>
|
|
|
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
2022-04-08 19:12:21 +02:00
|
|
|
#include <fsfw/timemanager/Countdown.h>
|
2022-04-09 14:43:06 +02:00
|
|
|
#include <linux/devices/ScexDleParser.h>
|
2022-04-08 19:12:21 +02:00
|
|
|
#include <termios.h> // Contains POSIX terminal control definitions
|
2022-03-25 17:48:38 +01:00
|
|
|
|
2022-04-08 19:12:21 +02:00
|
|
|
class SemaphoreIF;
|
|
|
|
class MutexIF;
|
2022-03-25 17:48:38 +01:00
|
|
|
|
2022-04-08 19:12:21 +02:00
|
|
|
class ScexUartReader : public SystemObject, // strg+shift+n
|
|
|
|
public ExecutableObjectIF,
|
|
|
|
public DeviceCommunicationIF {
|
|
|
|
friend class UartTestClass;
|
2022-03-25 17:48:38 +01:00
|
|
|
|
2022-04-08 19:12:21 +02:00
|
|
|
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();
|
2022-04-09 14:43:06 +02:00
|
|
|
SimpleRingBuffer decodeRingBuf;
|
|
|
|
|
2022-04-08 19:12:21 +02:00
|
|
|
Countdown finishCoutdown = Countdown(180 * 1000);
|
|
|
|
std::array<uint8_t, 256> cmdbuf = {};
|
2022-04-09 14:43:06 +02:00
|
|
|
std::array<uint8_t, 524> recBuf = {};
|
|
|
|
std::array<uint8_t, 4096> encodedBuf = {};
|
|
|
|
std::array<uint8_t, 4096> decodedBuf = {};
|
2022-04-08 19:12:21 +02:00
|
|
|
std::array<uint8_t, 4096> ipcBuffer = {};
|
2022-04-09 14:43:06 +02:00
|
|
|
SimpleRingBuffer ipcRingBuf;
|
|
|
|
DynamicFIFO<size_t> ipcQueue;
|
|
|
|
ScexDleParser dleParser;
|
|
|
|
|
|
|
|
static void foundDlePacketHandler(uint8_t *packet, size_t len, void *args);
|
|
|
|
void handleFoundDlePacket(uint8_t *packet, size_t len);
|
2022-04-08 19:12:21 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
2022-03-25 17:48:38 +01:00
|
|
|
|
|
|
|
#endif /* LINUX_DEVICES_SCEXUARTREADER_H_ */
|