eive-obsw/linux/boardtest/UartTestClass.h

75 lines
2.0 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-27 18:21:32 +02:00
#include <fsfw/timemanager/Countdown.h>
2022-11-10 18:07:59 +01:00
#include <fsfw_hal/linux/serial/SerialCookie.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-11-28 11:35:28 +01:00
#include "test/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-09-27 18:54:48 +02:00
UartTestClass(object_id_t objectId);
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-29 15:46:16 +02:00
int prepareScexCmd(scex::Cmds 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);
2022-04-29 13:31:14 +02:00
std::string random_string(std::string::size_type length);
2022-04-09 14:43:06 +02:00
2022-04-29 12:26:18 +02:00
std::string fileId = "";
std::string fileName = "";
2022-04-29 12:48:13 +02:00
bool fileNameSet = false;
2022-04-27 18:21:32 +02:00
Countdown finishCountdown = Countdown(180 * 1000);
2022-04-09 14:43:06 +02:00
bool cmdSent = false;
bool cmdDone = false;
2022-04-29 15:46:16 +02:00
scex::Cmds currCmd = scex::Cmds::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-11-11 11:41:40 +01:00
SerialCookie* 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-27 18:21:32 +02:00
std::array<uint8_t, 4096> recBuf = {};
2022-04-09 14:43:06 +02:00
ScexDleParser* dleParser;
2022-08-29 16:05:05 +02:00
scex::Cmds cmdHelper = scex::Cmds::INVALID;
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_ */