eive-obsw/linux/boardtest/UartTestClass.h

68 lines
1.8 KiB
C
Raw Normal View History

2021-03-04 18:29:28 +01:00
#ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_
#define LINUX_BOARDTEST_UARTTESTCLASS_H_
2022-04-09 14:43:06 +02:00
#include <fsfw/container/SimpleRingBuffer.h>
2022-02-22 20:13:16 +01:00
#include <fsfw/globalfunctions/DleEncoder.h>
2022-04-09 15:38:09 +02:00
#include <fsfw/globalfunctions/DleParser.h>
2022-04-08 19:12:21 +02:00
#include <fsfw_hal/linux/uart/UartCookie.h>
2022-01-17 13:48:55 +01:00
#include <termios.h> // Contains POSIX terminal control definitions
2021-06-16 18:38:06 +02:00
#include <array>
2021-03-04 18:29:28 +01:00
2022-01-17 13:48:55 +01:00
#include "lwgps/lwgps.h"
2022-04-09 14:43:06 +02:00
#include "mission/devices/devicedefinitions/ScexDefinitions.h"
2022-01-17 13:48:55 +01:00
#include "test/testtasks/TestTask.h"
2021-03-04 18:29:28 +01:00
2022-04-08 19:12:21 +02:00
class ScexUartReader;
2022-04-09 14:43:06 +02:00
class ScexDleParser;
2022-04-08 19:12:21 +02:00
2022-01-17 13:48:55 +01:00
class UartTestClass : public TestTask {
public:
2022-04-08 19:12:21 +02:00
UartTestClass(object_id_t objectId, ScexUartReader* reader);
2021-03-04 18:29:28 +01:00
2022-01-17 13:48:55 +01:00
ReturnValue_t initialize() override;
ReturnValue_t performOneShotAction() override;
ReturnValue_t performPeriodicAction() override;
2021-06-16 18:38:06 +02:00
2022-01-17 13:48:55 +01:00
private:
2022-02-03 13:37:48 +01:00
enum TestModes {
GPS,
// Solar Cell Experiment
2022-02-04 17:48:05 +01:00
SCEX
2022-02-03 13:37:48 +01:00
};
2022-04-08 19:12:21 +02:00
enum ScexModes { SIMPLE, READER_TASK } scexMode;
2022-02-03 13:37:48 +01:00
void gpsInit();
void gpsPeriodic();
2022-02-04 17:48:05 +01:00
void scexInit();
void scexPeriodic();
2022-04-09 01:00:42 +02:00
int prepareScexCmd(scex::ScexCmds cmd, bool tempCheck, uint8_t* cmdBuf, size_t* len);
2022-04-08 21:16:02 +02:00
void scexSimplePeriodic();
void scexSimpleInit();
2022-04-09 15:38:09 +02:00
static void foundDlePacketHandler(const DleParser::Context& ctx);
2022-04-09 14:43:06 +02:00
void handleFoundDlePacket(uint8_t* packet, size_t len);
bool cmdSent = false;
bool cmdDone = false;
2022-04-09 01:00:42 +02:00
scex::ScexCmds currCmd = scex::ScexCmds::PING;
2022-02-03 13:37:48 +01:00
TestModes mode = TestModes::GPS;
2022-02-22 20:13:16 +01:00
DleEncoder dleEncoder = DleEncoder();
2022-04-08 19:12:21 +02:00
UartCookie* uartCookie = nullptr;
2022-02-22 20:13:16 +01:00
size_t encodedLen = 0;
2022-01-17 13:48:55 +01:00
lwgps_t gpsData = {};
struct termios tty = {};
int serialPort = 0;
2022-04-09 14:43:06 +02:00
bool startFound = false;
ScexUartReader* reader = nullptr;
2022-02-04 17:48:05 +01:00
std::array<uint8_t, 64> cmdBuf = {};
2022-04-09 14:43:06 +02:00
std::array<uint8_t, 524> recBuf = {};
ScexDleParser* dleParser;
2022-01-17 13:48:55 +01:00
uint8_t recvCnt = 0;
2021-03-04 18:29:28 +01:00
};
#endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */