something is not working yet
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
ee45418f8c
commit
4eb5e8acba
@ -1,4 +1,8 @@
|
||||
#include "InitMission.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
#include <fsfw/objectmanager/ObjectManager.h>
|
||||
#include <fsfw/objectmanager/ObjectManagerIF.h>
|
||||
@ -11,11 +15,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "objects/systemObjectList.h"
|
||||
#include "pollingsequence/pollingSequenceFactory.h"
|
||||
|
||||
ServiceInterfaceStream sif::debug("DEBUG");
|
||||
ServiceInterfaceStream sif::info("INFO");
|
||||
ServiceInterfaceStream sif::warning("WARNING");
|
||||
@ -211,7 +210,7 @@ void initmission::createTestTasks(TaskFactory& factory,
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK);
|
||||
}
|
||||
#if RPI_ADD_SPI_TEST == 1
|
||||
#if OBSW_ADD_SPI_TEST_CODE == 1
|
||||
result = testTask->addComponent(objects::SPI_TEST);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
||||
@ -223,12 +222,13 @@ void initmission::createTestTasks(TaskFactory& factory,
|
||||
initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST);
|
||||
}
|
||||
#endif /* RPI_ADD_GPIO_TEST == 1 */
|
||||
#if RPI_ADD_UART_TEST == 1
|
||||
#if OBSW_ADD_UART_TEST_CODE == 1
|
||||
result = testTask->addComponent(objects::UART_TEST);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("UART_TEST", objects::UART_TEST);
|
||||
}
|
||||
#endif /* RPI_ADD_GPIO_TEST == 1 */
|
||||
taskVec.push_back(testTask);
|
||||
|
||||
bool startTestPst = true;
|
||||
static_cast<void>(startTestPst);
|
||||
|
@ -178,11 +178,11 @@ void ObjectFactory::produce(void* args) {
|
||||
void ObjectFactory::createTestTasks() {
|
||||
new TestTask(objects::TEST_TASK);
|
||||
|
||||
#if RPI_ADD_SPI_TEST == 1
|
||||
#if OBSW_ADD_SPI_TEST_CODE == 1
|
||||
new SpiTestClass(objects::SPI_TEST, gpioIF);
|
||||
#endif
|
||||
|
||||
#if RPI_ADD_UART_TEST == 1
|
||||
#if OBSW_ADD_UART_TEST_CODE == 1
|
||||
new UartTestClass(objects::UART_TEST);
|
||||
#else
|
||||
new UartComIF(objects::UART_COM_IF);
|
||||
|
@ -1,11 +1,6 @@
|
||||
#include "UartTestClass.h"
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#if defined(RASPBERRY_PI)
|
||||
#include "rpiConfig.h"
|
||||
#elif defined(XIPHOS_Q7S)
|
||||
#include "q7sConfig.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h> // Error integer and strerror() function
|
||||
#include <fcntl.h> // Contains file controls like O_RDWR
|
||||
@ -42,7 +37,7 @@ ReturnValue_t UartTestClass::performPeriodicAction() {
|
||||
}
|
||||
|
||||
void UartTestClass::gpsInit() {
|
||||
#if RPI_TEST_GPS_DEVICE == 1
|
||||
#if RPI_TEST_GPS_HANDLER == 1
|
||||
int result = lwgps_init(&gpsData);
|
||||
if (result == 0) {
|
||||
sif::warning << "lwgps_init error: " << result << std::endl;
|
||||
@ -90,7 +85,7 @@ void UartTestClass::gpsInit() {
|
||||
}
|
||||
|
||||
void UartTestClass::gpsPeriodic() {
|
||||
#if RPI_TEST_GPS_DEVICE == 1
|
||||
#if RPI_TEST_GPS_HANDLER == 1
|
||||
int bytesRead = 0;
|
||||
do {
|
||||
bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
|
||||
@ -129,7 +124,7 @@ void UartTestClass::gpsPeriodic() {
|
||||
|
||||
void UartTestClass::scexInit() {
|
||||
#if defined(RASPBERRY_PI)
|
||||
std::string devname = "/dev/ttyUSB1";
|
||||
std::string devname = "/dev/serial0";
|
||||
#else
|
||||
std::string devname = "/dev/ul-scex";
|
||||
#endif
|
||||
@ -165,37 +160,12 @@ void UartTestClass::scexInit() {
|
||||
}
|
||||
|
||||
void UartTestClass::scexPeriodic() {
|
||||
auto dleEncoder = DleEncoder();
|
||||
std::array<uint8_t, 128> tmpCmdBuf = {};
|
||||
// Send ping command
|
||||
tmpCmdBuf[0] = scex::CMD_PING;
|
||||
// These two fields are the packet counter and the total packet count. Those are 1 and 1 for each
|
||||
// telecommand so far
|
||||
tmpCmdBuf[1] = 1;
|
||||
tmpCmdBuf[2] = 1;
|
||||
uint16_t userDataLen = 0;
|
||||
tmpCmdBuf[3] = (userDataLen >> 8) & 0xff;
|
||||
tmpCmdBuf[4] = userDataLen & 0xff;
|
||||
uint16_t crc = CRC::crc16ccitt(tmpCmdBuf.data(), 5);
|
||||
tmpCmdBuf[5] = (crc >> 8) & 0xff;
|
||||
tmpCmdBuf[6] = crc & 0xff;
|
||||
|
||||
size_t encodedLen = 0;
|
||||
ReturnValue_t result =
|
||||
dleEncoder.encode(tmpCmdBuf.data(), 7, cmdBuf.data(), cmdBuf.size(), &encodedLen, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl;
|
||||
sif::info << "UartTestClass::scexInit: Sending ping command to SCEX" << std::endl;
|
||||
int result = prepareScexPing();
|
||||
if(result != 0) {
|
||||
return;
|
||||
}
|
||||
arrayprinter::print(cmdBuf.data(), 9);
|
||||
};
|
||||
size_t bytesWritten = write(serialPort, cmdBuf.data(), encodedLen);
|
||||
|
||||
if (bytesWritten != encodedLen) {
|
||||
sif::warning << "Sending ping command to solar experiment failed" << std::endl;
|
||||
}
|
||||
|
||||
TaskFactory::delayTask(20);
|
||||
bytesWritten = write(serialPort, cmdBuf.data(), encodedLen);
|
||||
if (bytesWritten != encodedLen) {
|
||||
sif::warning << "Sending ping command to solar experiment failed" << std::endl;
|
||||
}
|
||||
@ -210,8 +180,7 @@ void UartTestClass::scexPeriodic() {
|
||||
<< ", " << strerror(errno) << "]" << std::endl;
|
||||
break;
|
||||
} 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 enough"
|
||||
<< std::endl;
|
||||
} else if (bytesRead > 0) {
|
||||
sif::info << "Received " << bytesRead << " from the Solar Cell Experiment:" << std::endl;
|
||||
@ -219,3 +188,26 @@ void UartTestClass::scexPeriodic() {
|
||||
}
|
||||
} while (bytesRead > 0);
|
||||
}
|
||||
|
||||
int UartTestClass::prepareScexPing() {
|
||||
std::array<uint8_t, 128> tmpCmdBuf = {};
|
||||
// Send ping command
|
||||
tmpCmdBuf[0] = scex::CMD_PING;
|
||||
// These two fields are the packet counter and the total packet count. Those are 1 and 1 for each
|
||||
// telecommand so far
|
||||
tmpCmdBuf[1] = 1;
|
||||
tmpCmdBuf[2] = 1;
|
||||
uint16_t userDataLen = 0;
|
||||
tmpCmdBuf[3] = (userDataLen >> 8) & 0xff;
|
||||
tmpCmdBuf[4] = userDataLen & 0xff;
|
||||
uint16_t crc = CRC::crc16ccitt(tmpCmdBuf.data(), 5);
|
||||
tmpCmdBuf[5] = (crc >> 8) & 0xff;
|
||||
tmpCmdBuf[6] = crc & 0xff;
|
||||
ReturnValue_t result =
|
||||
dleEncoder.encode(tmpCmdBuf.data(), 7, cmdBuf.data(), cmdBuf.size(), &encodedLen, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "UartTestClass::scexInit: Encoding failed" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_
|
||||
#define LINUX_BOARDTEST_UARTTESTCLASS_H_
|
||||
|
||||
#include <fsfw/globalfunctions/DleEncoder.h>
|
||||
#include <termios.h> // Contains POSIX terminal control definitions
|
||||
|
||||
#include <array>
|
||||
@ -28,7 +29,10 @@ class UartTestClass : public TestTask {
|
||||
|
||||
void scexInit();
|
||||
void scexPeriodic();
|
||||
int prepareScexPing();
|
||||
TestModes mode = TestModes::GPS;
|
||||
DleEncoder dleEncoder = DleEncoder();
|
||||
size_t encodedLen = 0;
|
||||
lwgps_t gpsData = {};
|
||||
struct termios tty = {};
|
||||
int serialPort = 0;
|
||||
|
@ -443,6 +443,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
|
||||
ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) {
|
||||
// Length of a communication cycle
|
||||
uint32_t length = thisSequence->getPeriodMs();
|
||||
static_cast<void>(length);
|
||||
#if OBSW_ADD_MGT == 1
|
||||
thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
|
||||
thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user