WIP: SCEX Init #272

Closed
muellerr wants to merge 62 commits from irini into develop
Showing only changes of commit 44d36587aa - Show all commits

View File

@ -64,13 +64,13 @@ void UartTestClass::gpsInit() {
#if RPI_TEST_GPS_HANDLER == 1
int result = lwgps_init(&gpsData);
if (result == 0) {
sif::warning << "lwgps_init error: " << result << std::endl;
sif::warning << "UartTestClass::gpsInit: lwgps_init error: " << result << std::endl;
}
/* Get file descriptor */
serialPort = open("/dev/serial0", O_RDWR);
if (serialPort < 0) {
sif::warning << "open call failed with error [" << errno << ", " << strerror(errno)
sif::warning << "UartTestClass::gpsInit: open call failed with error [" << errno << ", " << strerror(errno)
<< std::endl;
}
/* Setting up UART parameters */
@ -99,7 +99,7 @@ void UartTestClass::gpsInit() {
cfsetispeed(&tty, B9600);
cfsetospeed(&tty, B9600);
if (tcsetattr(serialPort, TCSANOW, &tty) != 0) {
sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno)
sif::warning << "UartTestClass::gpsInit: tcsetattr call failed with error [" << errno << ", " << strerror(errno)
<< std::endl;
;
}
@ -115,11 +115,11 @@ void UartTestClass::gpsPeriodic() {
bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
static_cast<unsigned int>(recBuf.size()));
if (bytesRead < 0) {
sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << errno
sif::warning << "UartTestClass::gpsPeriodic: read call failed with error [" << errno
<< ", " << strerror(errno) << "]" << std::endl;
break;
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
sif::debug << "UartTestClass::performPeriodicAction: "
sif::debug << "UartTestClass::gpsPeriodic: "
"recv buffer might not be large enough"
<< std::endl;
} else if (bytesRead > 0) {
@ -129,7 +129,7 @@ void UartTestClass::gpsPeriodic() {
#endif
int result = lwgps_process(&gpsData, recBuf.data(), bytesRead);
if (result == 0) {
sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" << std::endl;
sif::warning << "UartTestClass::gpsPeriodic: lwgps_process error" << std::endl;
}
recvCnt++;
if (recvCnt == 6) {
@ -163,7 +163,7 @@ void UartTestClass::scexInit() {
reader->setDebugMode(false);
ReturnValue_t result = reader->initializeInterface(uartCookie);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader "
sif::warning << "UartTestClass::scexInit: Initializing SCEX reader "
"UART IF failed"
<< std::endl;
}
@ -199,7 +199,7 @@ void UartTestClass::scexPeriodic() {
const uint8_t* helperPtr = decodedPacket;
result = helper.deSerialize(&helperPtr, &len);
if (result == ScexHelper::INVALID_CRC) {
sif::warning << "CRC invalid" << std::endl;
sif::warning << "UartTestClass::scexPeriodic: CRC invalid" << std::endl;
}
sif::info << helper << endl;
@ -238,7 +238,7 @@ void UartTestClass::scexPeriodic() {
if (finishCountdown.hasTimedOut()) {
triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0);
reader->finish();
sif::warning << "Reader timeout" << endl;
sif::warning << "UartTestClass::scexPeriodic: Reader timeout" << endl;
cmdDone = true;
fileNameSet = false;
}
@ -246,7 +246,7 @@ void UartTestClass::scexPeriodic() {
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
reader->finish();
sif::info << "Reader is finished" << endl;
sif::info << "UartTestClass::scexPeriodic: Reader is finished" << endl;
cmdDone = true;
fileNameSet = false;
if (helper.getCmd() == scex::Cmds::PING) {
@ -268,7 +268,7 @@ void UartTestClass::scexSimpleInit() {
/* Get file descriptor */
serialPort = open(devname.c_str(), O_RDWR);
if (serialPort < 0) {
sif::warning << "open call failed with error [" << errno << ", " << strerror(errno)
sif::warning << "UartTestClass::scexSimpleInit: Open call failed with error [" << errno << ", " << strerror(errno)
<< std::endl;
return;
}
@ -291,12 +291,12 @@ void UartTestClass::scexSimpleInit() {
// Q7S UART Lite has fixed baud rate. For other linux systems, set baud rate here.
#if !defined(XIPHOS_Q7S)
if (cfsetispeed(&tty, B57600) != 0) {
sif::warning << "UartTestClass::scexInit: Setting baud rate failed" << std::endl;
sif::warning << "UartTestClass::scexSimpleInit: Setting baud rate failed" << std::endl;
}
#endif
if (tcsetattr(serialPort, TCSANOW, &tty) != 0) {
sif::warning << "tcsetattr call failed with error [" << errno << ", " << strerror(errno)
sif::warning << "UartTestClass::scexSimpleInit: tcsetattr call failed with error [" << errno << ", " << strerror(errno)
<< std::endl;
}
// Flush received and unread data
@ -315,7 +315,7 @@ void UartTestClass::scexSimplePeriodic() {
prepareScexCmd(currCmd, false, tmpCmdBuf, &len);
result = dleEncoder.encode(tmpCmdBuf, len, cmdBuf.data(), cmdBuf.size(), &encodedLen, true);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl;
sif::warning << "UartTestClass::scexSimplePeriodic: Encoding failed" << std::endl;
return;
}
if (result != 0) {
@ -323,7 +323,7 @@ void UartTestClass::scexSimplePeriodic() {
};
size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen);
if (bytesWritten != encodedLen) {
sif::warning << "Sending command to solar experiment failed" << std::endl;
sif::warning << "UartTestClass::scexSimplePeriodic: Sending command to solar experiment failed" << std::endl;
}
cmdSent = true;
cmdDone = false;
@ -335,13 +335,13 @@ void UartTestClass::scexSimplePeriodic() {
bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
static_cast<unsigned int>(recBuf.size()));
if (bytesRead == 0) {
sif::warning << "Reading SCEX: Timeout or no bytes read" << std::endl;
sif::warning << "UartTestClass::scexSimplePeriodic: Reading SCEX: Timeout or no bytes read" << std::endl;
} else if (bytesRead < 0) {
sif::warning << "UartTestClass::performPeriodicAction: read call failed with error ["
sif::warning << "UartTestClass::scexSimplePeriodic: read call failed with error ["
<< errno << ", " << strerror(errno) << "]" << std::endl;
break;
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large "
sif::debug << "UartTestClass::scexSimplePeriodic: recv buffer might not be large "
"enough, bytes read:"
<< bytesRead << std::endl;
} else if (bytesRead > 0) {
@ -383,7 +383,7 @@ void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) {
}
void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) {
sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
sif::info << "UartTestClass::handleFoundDlePacket: Detected DLE encoded packet with decoded size " << len << std::endl;
}
std::string UartTestClass::random_string(std::string::size_type length) {