bugfix for scex testcode
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Irini Kosmidou
2022-09-27 18:54:48 +02:00
parent a1cc5b0ca7
commit 308a855d8c
16 changed files with 56 additions and 55 deletions

View File

@ -27,12 +27,11 @@
using namespace returnvalue;
UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader)
: TestTask(objectId), reader(reader) {
UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {
mode = TestModes::SCEX;
scexMode = ScexModes::READER_TASK;
scexMode = ScexModes::SIMPLE;
// No one-cell and all-cell support implemented yet
currCmd = scex::Cmds::FRAM;
currCmd = scex::Cmds::PING;
if (scexMode == ScexModes::SIMPLE) {
auto encodingBuf = new std::array<uint8_t, 4096>;
DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()};
@ -40,6 +39,8 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader)
DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()};
dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair,
decodingBufPair, &foundDlePacketHandler, this);
} else {
reader = new ScexUartReader(objects::SCEX_UART_READER);
}
}
@ -150,13 +151,13 @@ void UartTestClass::gpsPeriodic() {
}
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 defined(RASPBERRY_PI)
std::string devname = "/dev/serial0";
#else
@ -176,13 +177,13 @@ void UartTestClass::scexInit() {
void UartTestClass::scexPeriodic() {
using namespace std;
using namespace scex;
if (reader == nullptr) {
return;
}
if (scexMode == ScexModes::SIMPLE) {
scexSimplePeriodic();
} else {
if (reader == nullptr) {
return;
}
if (not cmdSent) {
size_t len = 0;
prepareScexCmd(currCmd, false, cmdBuf.data(), &len);
@ -375,6 +376,7 @@ int UartTestClass::prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBu
uint16_t crc = CRC::crc16ccitt(cmdBuf, 5);
cmdBuf[5] = (crc >> 8) & 0xff;
cmdBuf[6] = crc & 0xff;
*len = 7;
return 0;
}

View File

@ -19,7 +19,7 @@ class ScexDleParser;
class UartTestClass : public TestTask {
public:
UartTestClass(object_id_t objectId, ScexUartReader* reader);
UartTestClass(object_id_t objectId);
ReturnValue_t initialize() override;
ReturnValue_t performOneShotAction() override;