This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw_hal/linux/uart/UartCookie.h>
|
||||
#include <linux/devices/ScexDleParser.h>
|
||||
#include <linux/devices/ScexHelper.h>
|
||||
#include <linux/devices/ScexUartReader.h>
|
||||
#include <unistd.h> // write(), read(), close()
|
||||
|
||||
@ -167,6 +168,7 @@ void UartTestClass::scexInit() {
|
||||
|
||||
void UartTestClass::scexPeriodic() {
|
||||
using namespace std;
|
||||
using namespace scex;
|
||||
if (reader == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -187,38 +189,39 @@ void UartTestClass::scexPeriodic() {
|
||||
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
|
||||
|
||||
if (len > 0) {
|
||||
sif::info << "CmdByte: " << std::setw(2) << std::setfill('0') << std::hex
|
||||
<< (int)decodedPacket[0] << std::dec << endl;
|
||||
scex::ScexCmds cmd = static_cast<scex::ScexCmds>((decodedPacket[0] >> 1) & 0b11111);
|
||||
sif::info << "Command: 0x" << std::setw(2) << std::setfill('0') << std::hex
|
||||
<< static_cast<int>(cmd) << std::dec << std::endl;
|
||||
size_t packetCounter = decodedPacket[1];
|
||||
sif::info << "PacketCounter: " << packetCounter << endl;
|
||||
size_t totalPacketCounter = decodedPacket[2];
|
||||
sif::info << "TotalPacketCount: " << totalPacketCounter << endl;
|
||||
uint16_t packetLen = (decodedPacket[3] << 8) | (decodedPacket[4]);
|
||||
sif::info << "PacketLength: " << packetLen << endl;
|
||||
uint16_t expectedPacketLen = packetLen + 7;
|
||||
ScexHelper helper;
|
||||
const uint8_t* helperPtr = decodedPacket;
|
||||
result = helper.deSerialize(&helperPtr, &len);
|
||||
if (result == ScexHelper::INVALID_CRC) {
|
||||
sif::warning << "CRC invalid" << std::endl;
|
||||
}
|
||||
sif::info << helper << endl;
|
||||
|
||||
sif::info << "ExpectedPacketLength: " << packetLen + 7 << endl;
|
||||
if (expectedPacketLen != len) {
|
||||
sif::warning << "ExpectedPacketLength " << expectedPacketLen << " is not Length" << len
|
||||
<< endl;
|
||||
//ping
|
||||
//if ping cmd
|
||||
ofstream out("/tmp/scex-ping.bin", ofstream::binary );
|
||||
if (out.bad()) {
|
||||
sif::warning << "bad" <<std::endl;
|
||||
}
|
||||
if (CRC::crc16ccitt(decodedPacket, expectedPacketLen) != 0) {
|
||||
sif::warning << "CRC invalid" << endl;
|
||||
} else {
|
||||
sif::info << "CRC valid" << endl;
|
||||
//fram
|
||||
//packetcounter eins h<>her, wenn mehr packet verloren ->
|
||||
//countdown (max 2min), wenn nicht if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
||||
if(helper.getCmd() == FRAM) {
|
||||
if(helper.getPacketCounter() == 0) {
|
||||
// neues file anlegen wie oben ping
|
||||
} else {
|
||||
// an bestehendes file hinzuf<75>gen
|
||||
}
|
||||
}
|
||||
if (packetCounter == totalPacketCounter) {
|
||||
out << helper;
|
||||
|
||||
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
|
||||
reader->finish();
|
||||
sif::info << "Reader is finished" << endl;
|
||||
cmdDone = true;
|
||||
// TODO: Bug in firmware, other command will be returned
|
||||
cmdSent = false;
|
||||
// if (cmd == scex::ScexCmds::PING) {
|
||||
// cmdSent = false;
|
||||
// }
|
||||
if (helper.getCmd() == scex::ScexCmds::PING) {
|
||||
cmdSent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user