v1.14.0 #304
@ -21,17 +21,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader)
|
UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader)
|
||||||
: TestTask(objectId), reader(reader) {
|
: TestTask(objectId), reader(reader) {
|
||||||
mode = TestModes::SCEX;
|
mode = TestModes::SCEX;
|
||||||
scexMode = ScexModes::SIMPLE;
|
scexMode = ScexModes::READER_TASK;
|
||||||
currCmd = scex::ScexCmds::FRAM;
|
currCmd = scex::ScexCmds::PING;
|
||||||
if (scexMode == ScexModes::SIMPLE) {
|
if (scexMode == ScexModes::SIMPLE) {
|
||||||
auto encodingBuf = new std::array<uint8_t, 4096>;
|
auto encodingBuf = new std::array<uint8_t, 4096>;
|
||||||
DleParser::BufPair encodingBufPair {encodingBuf->data(), encodingBuf->size()};
|
DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()};
|
||||||
auto decodedBuf = new std::array<uint8_t, 4096>;
|
auto decodedBuf = new std::array<uint8_t, 4096>;
|
||||||
DleParser::BufPair decodingBufPair {decodedBuf->data(), decodedBuf->size()};
|
DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()};
|
||||||
dleParser =
|
dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair,
|
||||||
new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, decodingBufPair, &foundDlePacketHandler, this);
|
decodingBufPair, &foundDlePacketHandler, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,53 +174,55 @@ void UartTestClass::scexPeriodic() {
|
|||||||
if (scexMode == ScexModes::SIMPLE) {
|
if (scexMode == ScexModes::SIMPLE) {
|
||||||
scexSimplePeriodic();
|
scexSimplePeriodic();
|
||||||
} else {
|
} else {
|
||||||
if (not cmdSent){
|
if (not cmdSent) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len);
|
prepareScexCmd(scex::ScexCmds::PING, false, cmdBuf.data(), &len);
|
||||||
reader->sendMessage(uartCookie, cmdBuf.data(), len);
|
reader->sendMessage(uartCookie, cmdBuf.data(), len);
|
||||||
cmdSent = true;
|
cmdSent = true;
|
||||||
cmdDone = false;
|
cmdDone = false;
|
||||||
}
|
}
|
||||||
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);
|
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
|
||||||
|
|
||||||
if(len > 0){
|
if (len > 0) {
|
||||||
sif::info<<"CmdByte: "<<(int)decodedPacket[0]<<endl;
|
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);
|
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];
|
size_t packetCounter = decodedPacket[1];
|
||||||
sif::info<<"PacketCounter: "<<packetCounter<<endl;
|
sif::info << "PacketCounter: " << packetCounter << endl;
|
||||||
size_t totalPacketCounter = decodedPacket[2];
|
size_t totalPacketCounter = decodedPacket[2];
|
||||||
sif::info<<"TotalPacketCount: "<<totalPacketCounter<<endl;
|
sif::info << "TotalPacketCount: " << totalPacketCounter << endl;
|
||||||
uint16_t packetLen = (decodedPacket[3]<< 8) | (decodedPacket[4]);
|
uint16_t packetLen = (decodedPacket[3] << 8) | (decodedPacket[4]);
|
||||||
sif::info<<"PacketLength: "<< packetLen <<endl;
|
sif::info << "PacketLength: " << packetLen << endl;
|
||||||
uint16_t expectedPacketLen = packetLen + 7;
|
uint16_t expectedPacketLen = packetLen + 7;
|
||||||
|
|
||||||
sif::info<<"ExpectedPacketLength: "<< packetLen+7 <<endl;
|
sif::info << "ExpectedPacketLength: " << packetLen + 7 << endl;
|
||||||
if(expectedPacketLen != len){
|
if (expectedPacketLen != len) {
|
||||||
sif::warning<<"ExpectedPacketLength " << expectedPacketLen <<" is not Length"<< len<<endl;
|
sif::warning << "ExpectedPacketLength " << expectedPacketLen << " is not Length" << len
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
if(CRC::crc16ccitt(decodedPacket, expectedPacketLen) != 0){
|
if (CRC::crc16ccitt(decodedPacket, expectedPacketLen) != 0) {
|
||||||
sif::warning<<"CRC invalid"<<endl;
|
sif::warning << "CRC invalid" << endl;
|
||||||
}else{
|
} else {
|
||||||
sif::info<<"CRC valid"<<endl;
|
sif::info << "CRC valid" << endl;
|
||||||
}
|
}
|
||||||
if(packetCounter == totalPacketCounter){
|
if (packetCounter == totalPacketCounter) {
|
||||||
reader->finish();
|
reader->finish();
|
||||||
sif::info<<"Reader is finished" << endl;
|
sif::info << "Reader is finished" << endl;
|
||||||
cmdDone = true;
|
cmdDone = true;
|
||||||
if(cmd == scex::ScexCmds::PING){
|
// TODO: Bug in firmware, other command will be returned
|
||||||
cmdSent = false;
|
cmdSent = false;
|
||||||
|
// if (cmd == scex::ScexCmds::PING) {
|
||||||
|
// cmdSent = false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UartTestClass::scexSimpleInit() {
|
void UartTestClass::scexSimpleInit() {
|
||||||
@ -249,8 +251,8 @@ void UartTestClass::scexSimpleInit() {
|
|||||||
|
|
||||||
// Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are
|
// Non-blocking mode, read until either line is 0.1 second idle or maximum of 255 bytes are
|
||||||
// received in one go
|
// received in one go
|
||||||
tty.c_cc[VTIME] = 10; // In units of 0.1 seconds
|
tty.c_cc[VTIME] = 0; // In units of 0.1 seconds
|
||||||
tty.c_cc[VMIN] = 255; // Read up to 255 bytes
|
tty.c_cc[VMIN] = 0; // Read up to 255 bytes
|
||||||
|
|
||||||
// Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here.
|
// Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here.
|
||||||
#if !defined(XIPHOS_Q7S)
|
#if !defined(XIPHOS_Q7S)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include <fsfw/ipc/MutexFactory.h>
|
||||||
#include <fsfw/ipc/MutexGuard.h>
|
#include <fsfw/ipc/MutexGuard.h>
|
||||||
#include <fsfw/tasks/SemaphoreFactory.h>
|
#include <fsfw/tasks/SemaphoreFactory.h>
|
||||||
|
#include <fsfw/tasks/TaskFactory.h>
|
||||||
#include <fsfw_hal/linux/uart/UartCookie.h>
|
#include <fsfw_hal/linux/uart/UartCookie.h>
|
||||||
#include <linux/devices/ScexDleParser.h>
|
#include <linux/devices/ScexDleParser.h>
|
||||||
#include <unistd.h> // write(), read(), close()
|
#include <unistd.h> // write(), read(), close()
|
||||||
@ -34,16 +35,17 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
|||||||
semaphore->acquire();
|
semaphore->acquire();
|
||||||
sif::info << "task was started" << std::endl;
|
sif::info << "task was started" << std::endl;
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
while(true) {
|
while (true) {
|
||||||
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
|
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
|
||||||
static_cast<unsigned int>(recBuf.size()));
|
static_cast<unsigned int>(recBuf.size()));
|
||||||
if (bytesRead == 0) {
|
if (bytesRead == 0) {
|
||||||
MutexGuard mg(lock);
|
MutexGuard mg(lock);
|
||||||
States currentState = state;
|
if (state == States::FINISH) {
|
||||||
if (currentState == States::FINISH) {
|
sif::debug << "finish detected" << std::endl;
|
||||||
state = States::IDLE;
|
state = States::IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
TaskFactory::delayTask(1000);
|
||||||
} 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;
|
||||||
@ -63,7 +65,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// task block comes here
|
// task block comes here
|
||||||
std::cout << "done" << std::endl;
|
sif::info << "task was stopped" << std::endl;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
@ -94,8 +96,8 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
|
|||||||
tty.c_lflag &= ~(ICANON | ECHO);
|
tty.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
|
||||||
// Non-blocking mode, use polling
|
// Non-blocking mode, use polling
|
||||||
tty.c_cc[VTIME] = 10; // Read for up to 1 seconds
|
tty.c_cc[VTIME] = 0;
|
||||||
tty.c_cc[VMIN] = 255; // Read as much as there is available
|
tty.c_cc[VMIN] = 0;
|
||||||
|
|
||||||
// Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here.
|
// Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here.
|
||||||
#if !defined(XIPHOS_Q7S)
|
#if !defined(XIPHOS_Q7S)
|
||||||
@ -109,7 +111,7 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
// Flush received and unread data
|
// Flush received and unread data
|
||||||
tcflush(serialPort, TCIFLUSH);
|
tcflush(serialPort, TCIOFLUSH);
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,12 +174,12 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
|||||||
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) {
|
||||||
sif::warning<< "IPCQueue error" << std::endl;
|
sif::warning << "IPCQueue error" << std::endl;
|
||||||
}
|
}
|
||||||
result = ipcRingBuf.writeData(packet, len);
|
result = ipcRingBuf.writeData(packet, 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;
|
||||||
}
|
}
|
||||||
@ -189,7 +191,8 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu
|
|||||||
*size = 0;
|
*size = 0;
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
*size = ipcQueue.pop();
|
sif::info << "returning data" << std::endl;
|
||||||
|
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);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
|
@ -118,7 +118,7 @@ ReturnValue_t IMTQHandler::buildCommandFromCommand(DeviceCommandId_t deviceComma
|
|||||||
case (IMTQ::START_ACTUATION_DIPOLE): {
|
case (IMTQ::START_ACTUATION_DIPOLE): {
|
||||||
/* IMTQ expects low byte first */
|
/* IMTQ expects low byte first */
|
||||||
commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE;
|
commandBuffer[0] = IMTQ::CC::START_ACTUATION_DIPOLE;
|
||||||
if(commandData == nullptr) {
|
if (commandData == nullptr) {
|
||||||
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
|
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
|
||||||
}
|
}
|
||||||
commandBuffer[1] = commandData[1];
|
commandBuffer[1] = commandData[1];
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit ecb973c37fe43954d0be1f19b0735b3546d2ef1b
|
Subproject commit 8a30f669f075c284494d7c1c6618e42e2aec8f15
|
Loading…
Reference in New Issue
Block a user