This commit is contained in:
parent
c5683afe9f
commit
e11c84a5ed
@ -156,7 +156,7 @@ void UartTestClass::scexInit() {
|
|||||||
std::string devname = "/dev/ul-scex";
|
std::string devname = "/dev/ul-scex";
|
||||||
#endif
|
#endif
|
||||||
uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096);
|
uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096);
|
||||||
reader->setDebugMode(true);
|
reader->setDebugMode(false);
|
||||||
ReturnValue_t result = reader->initializeInterface(uartCookie);
|
ReturnValue_t result = reader->initializeInterface(uartCookie);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader "
|
sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader "
|
||||||
@ -186,9 +186,11 @@ void UartTestClass::scexPeriodic() {
|
|||||||
if (cmdSent and not cmdDone) {
|
if (cmdSent and not cmdDone) {
|
||||||
uint8_t* decodedPacket = nullptr;
|
uint8_t* decodedPacket = nullptr;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
|
do {
|
||||||
|
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
|
||||||
if (len > 0) {
|
if(len == 0){
|
||||||
|
break;
|
||||||
|
}
|
||||||
ScexHelper helper;
|
ScexHelper helper;
|
||||||
const uint8_t* helperPtr = decodedPacket;
|
const uint8_t* helperPtr = decodedPacket;
|
||||||
result = helper.deSerialize(&helperPtr, &len);
|
result = helper.deSerialize(&helperPtr, &len);
|
||||||
@ -197,25 +199,35 @@ void UartTestClass::scexPeriodic() {
|
|||||||
}
|
}
|
||||||
sif::info << helper << endl;
|
sif::info << helper << endl;
|
||||||
|
|
||||||
//ping
|
// ping
|
||||||
//if ping cmd
|
// if ping cmd
|
||||||
if(helper.getCmd() == PING) {
|
if (helper.getCmd() == PING) {
|
||||||
ofstream out("/tmp/scex-ping.bin", ofstream::binary );
|
ofstream out("/tmp/scex-ping.bin", ofstream::binary);
|
||||||
if (out.bad()) {
|
if (out.bad()) {
|
||||||
sif::warning << "bad" <<std::endl;
|
sif::warning << "bad" << std::endl;
|
||||||
|
}
|
||||||
|
out << helper;
|
||||||
}
|
}
|
||||||
out << helper;
|
// fram
|
||||||
}
|
// packetcounter eins höher, wenn mehr packet verloren -> merkt sich welches packet fehlt
|
||||||
//fram
|
//was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit finish false wird?
|
||||||
//packetcounter eins höher, wenn mehr packet verloren ->
|
// countdown (max 2min), wenn nicht if (helper.getPacketCounter() ==
|
||||||
//countdown (max 2min), wenn nicht if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
||||||
if(helper.getCmd() == FRAM) {
|
if (helper.getCmd() == FRAM) {
|
||||||
if(helper.getPacketCounter() == 0) {
|
if (helper.getPacketCounter() == 1) {
|
||||||
ofstream out("/tmp/scex-fram.bin", ofstream::binary ); // neues file anlegen wie oben ping
|
//countdown starten
|
||||||
} else {
|
finishCountdown.resetTimer();
|
||||||
ofstream out("/tmp/scex-fram.bin", ofstream::binary | ofstream::app );// an bestehendes file hinzufügen
|
ofstream out("/tmp/scex-fram.bin",
|
||||||
out << helper;
|
ofstream::binary); // neues file anlegen wie oben ping
|
||||||
}
|
} else {
|
||||||
|
ofstream out("/tmp/scex-fram.bin",
|
||||||
|
ofstream::binary | ofstream::app); // an bestehendes file hinzufügen
|
||||||
|
out << helper;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(finishCountdown.hasTimedOut()){
|
||||||
|
reader->finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
|
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
|
||||||
@ -226,7 +238,7 @@ void UartTestClass::scexPeriodic() {
|
|||||||
cmdSent = false;
|
cmdSent = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (len > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,8 +325,9 @@ void UartTestClass::scexSimplePeriodic() {
|
|||||||
<< errno << ", " << strerror(errno) << "]" << std::endl;
|
<< errno << ", " << strerror(errno) << "]" << std::endl;
|
||||||
break;
|
break;
|
||||||
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
||||||
sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough"
|
sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large "
|
||||||
<< std::endl;
|
"enough, bytes read:"
|
||||||
|
<< bytesRead << std::endl;
|
||||||
} else if (bytesRead > 0) {
|
} else if (bytesRead > 0) {
|
||||||
dleParser->passData(recBuf.data(), bytesRead);
|
dleParser->passData(recBuf.data(), bytesRead);
|
||||||
if (currCmd == ScexCmds::PING) {
|
if (currCmd == ScexCmds::PING) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <fsfw/container/SimpleRingBuffer.h>
|
#include <fsfw/container/SimpleRingBuffer.h>
|
||||||
#include <fsfw/globalfunctions/DleEncoder.h>
|
#include <fsfw/globalfunctions/DleEncoder.h>
|
||||||
#include <fsfw/globalfunctions/DleParser.h>
|
#include <fsfw/globalfunctions/DleParser.h>
|
||||||
|
#include <fsfw/timemanager/Countdown.h>
|
||||||
#include <fsfw_hal/linux/uart/UartCookie.h>
|
#include <fsfw_hal/linux/uart/UartCookie.h>
|
||||||
#include <termios.h> // Contains POSIX terminal control definitions
|
#include <termios.h> // Contains POSIX terminal control definitions
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ class UartTestClass : public TestTask {
|
|||||||
static void foundDlePacketHandler(const DleParser::Context& ctx);
|
static void foundDlePacketHandler(const DleParser::Context& ctx);
|
||||||
void handleFoundDlePacket(uint8_t* packet, size_t len);
|
void handleFoundDlePacket(uint8_t* packet, size_t len);
|
||||||
|
|
||||||
|
Countdown finishCountdown = Countdown(180 * 1000);
|
||||||
bool cmdSent = false;
|
bool cmdSent = false;
|
||||||
bool cmdDone = false;
|
bool cmdDone = false;
|
||||||
scex::ScexCmds currCmd = scex::ScexCmds::PING;
|
scex::ScexCmds currCmd = scex::ScexCmds::PING;
|
||||||
@ -59,7 +61,7 @@ class UartTestClass : public TestTask {
|
|||||||
bool startFound = false;
|
bool startFound = false;
|
||||||
ScexUartReader* reader = nullptr;
|
ScexUartReader* reader = nullptr;
|
||||||
std::array<uint8_t, 64> cmdBuf = {};
|
std::array<uint8_t, 64> cmdBuf = {};
|
||||||
std::array<uint8_t, 524> recBuf = {};
|
std::array<uint8_t, 4096> recBuf = {};
|
||||||
ScexDleParser* dleParser;
|
ScexDleParser* dleParser;
|
||||||
scex::ScexCmds cmdHelper;
|
scex::ScexCmds cmdHelper;
|
||||||
uint8_t recvCnt = 0;
|
uint8_t recvCnt = 0;
|
||||||
|
@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& os, const ScexHelper& h) {
|
|||||||
sif::info << "PacketCounter: " << h.packetCounter << endl;
|
sif::info << "PacketCounter: " << h.packetCounter << endl;
|
||||||
sif::info << "TotalPacketCount: " << h.totalPacketCounter << endl;
|
sif::info << "TotalPacketCount: " << h.totalPacketCounter << endl;
|
||||||
sif::info << "PayloadLength: " << h.payloadLen << endl;
|
sif::info << "PayloadLength: " << h.payloadLen << endl;
|
||||||
sif::info << "TotalPacketLength: " << h.totalPacketLen << endl;
|
sif::info << "TotalPacketLength: " << h.totalPacketLen;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,14 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
|||||||
state = States::IDLE;
|
state = States::IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TaskFactory::delayTask(1000);
|
TaskFactory::delayTask(400);
|
||||||
} else if (bytesRead < 0) {
|
} else if (bytesRead < 0) {
|
||||||
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
|
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
|
||||||
<< ", " << strerror(errno) << "]" << std::endl;
|
<< ", " << strerror(errno) << "]" << std::endl;
|
||||||
break;
|
break;
|
||||||
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
||||||
sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead << " bytes" << std::endl;
|
sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead
|
||||||
|
<< " bytes" << std::endl;
|
||||||
} else if (bytesRead > 0) {
|
} else if (bytesRead > 0) {
|
||||||
ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead);
|
ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead);
|
||||||
if (debugMode) {
|
if (debugMode) {
|
||||||
@ -76,7 +77,6 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
|
|||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
std::string devname = uartCookie->getDeviceFile();
|
std::string devname = uartCookie->getDeviceFile();
|
||||||
sif::info << devname << std::endl;
|
|
||||||
/* Get file descriptor */
|
/* Get file descriptor */
|
||||||
serialPort = open(devname.c_str(), O_RDWR);
|
serialPort = open(devname.c_str(), O_RDWR);
|
||||||
if (serialPort < 0) {
|
if (serialPort < 0) {
|
||||||
@ -171,7 +171,7 @@ void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) {
|
|||||||
|
|
||||||
void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
||||||
// TODO: insert data into IPC ring buffer here
|
// TODO: insert data into IPC ring buffer here
|
||||||
sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
|
// sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
|
||||||
MutexGuard mg(lock);
|
MutexGuard mg(lock);
|
||||||
ReturnValue_t result = ipcQueue.insert(len);
|
ReturnValue_t result = ipcQueue.insert(len);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -181,7 +181,7 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
|||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
sif::warning << "IPCRingBuf error" << std::endl;
|
sif::warning << "IPCRingBuf error" << std::endl;
|
||||||
}
|
}
|
||||||
sif::info << "DLE handler done" << std::endl;
|
// sif::info << "DLE handler done" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||||
@ -191,7 +191,6 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu
|
|||||||
*size = 0;
|
*size = 0;
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
sif::info << "returning data" << std::endl;
|
|
||||||
ipcQueue.retrieve(size);
|
ipcQueue.retrieve(size);
|
||||||
*buffer = ipcBuffer.data();
|
*buffer = ipcBuffer.data();
|
||||||
ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true);
|
ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true);
|
||||||
|
@ -37,7 +37,6 @@ class ScexUartReader : public SystemObject, // strg+shift+n
|
|||||||
DleEncoder dleEncoder = DleEncoder();
|
DleEncoder dleEncoder = DleEncoder();
|
||||||
SimpleRingBuffer decodeRingBuf;
|
SimpleRingBuffer decodeRingBuf;
|
||||||
|
|
||||||
Countdown finishCountdown = Countdown(180 * 1000);
|
|
||||||
std::array<uint8_t, 256> cmdbuf = {};
|
std::array<uint8_t, 256> cmdbuf = {};
|
||||||
std::array<uint8_t, 4096> recBuf = {};
|
std::array<uint8_t, 4096> recBuf = {};
|
||||||
std::array<uint8_t, 4096> encodedBuf = {};
|
std::array<uint8_t, 4096> encodedBuf = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user