eive-obsw/linux/devices/ScexUartReader.h
Irini Kosmidou 01d86a0c7b
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
huge progress
2022-04-08 19:12:21 +02:00

56 lines
1.9 KiB
C++

#ifndef LINUX_DEVICES_SCEXUARTREADER_H_
#define LINUX_DEVICES_SCEXUARTREADER_H_
#include <fsfw/container/DynamicFIFO.h>
#include <fsfw/container/SimpleRingBuffer.h>
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
#include <fsfw/globalfunctions/DleEncoder.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/timemanager/Countdown.h>
#include <termios.h> // Contains POSIX terminal control definitions
class SemaphoreIF;
class MutexIF;
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<size_t> sizesQueue;
Countdown finishCoutdown = Countdown(180 * 1000);
std::array<uint8_t, 256> cmdbuf = {};
std::array<uint8_t, 4096> recBuf = {};
std::array<uint8_t, 4096> 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_ */