split up PSTs and add contd GPS handler

This commit is contained in:
Robin Müller 2021-06-24 08:50:46 +02:00 committed by Robin.Mueller
parent 56cabbc117
commit 2331637350
6 changed files with 84 additions and 33 deletions

View File

@ -1,3 +1,6 @@
#include <fsfw_hal/linux/uart/UartComIF.h>
#include <fsfw_hal/linux/uart/UartCookie.h>
#include <mission/devices/GPSHandler.h>
#include "ObjectFactory.h" #include "ObjectFactory.h"
#include "objects/systemObjectList.h" #include "objects/systemObjectList.h"
@ -68,6 +71,8 @@ void ObjectFactory::produce(void* args){
#if RPI_ADD_UART_TEST == 1 #if RPI_ADD_UART_TEST == 1
new UartTestClass(objects::UART_TEST); new UartTestClass(objects::UART_TEST);
#else
new UartComIF(objects::UART_COM_IF);
#endif #endif
#if RPI_LOOPBACK_TEST_GPIO == 1 #if RPI_LOOPBACK_TEST_GPIO == 1
@ -146,4 +151,15 @@ void ObjectFactory::produce(void* args){
auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie);
adisGyroHandler->setStartUpImmediately(); adisGyroHandler->setStartUpImmediately();
#endif /* RPI_TEST_ADIS16507 == 1 */ #endif /* RPI_TEST_ADIS16507 == 1 */
#if RPI_TEST_GPS_HANDLER == 1
UartCookie* uartCookie = new UartCookie(objects::GPS0_HANDLER, "/dev/serial0",
UartModes::CANONICAL, 9600, 1024);
uartCookie->setToFlushInput(true);
uartCookie->setReadCycles(6);
GPSHandler* gpsHandler = new GPSHandler(objects::GPS0_HANDLER,
objects::UART_COM_IF, uartCookie);
gpsHandler->setStartUpImmediately();
#endif
} }

View File

@ -7,6 +7,7 @@
#define RPI_LOOPBACK_TEST_GPIO 0 #define RPI_LOOPBACK_TEST_GPIO 0
#define RPI_TEST_ADIS16507 0 #define RPI_TEST_ADIS16507 0
#define RPI_TEST_GPS_HANDLER 0
// Only one of those 2 should be enabled! // Only one of those 2 should be enabled!
#define RPI_ADD_SPI_TEST 0 #define RPI_ADD_SPI_TEST 0

@ -1 +1 @@
Subproject commit fce40ebf9a4a45bafedaee2fc87e5aa10e49fdcc Subproject commit 2533af3b53804bc68436236370911e013a2b8f64

View File

@ -19,11 +19,11 @@ ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence)
DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
// Radiation sensor // Radiation sensor
// thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE);
// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE);
// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ);
// if (length != 3000) { // if (length != 3000) {
// sif::warning << "pollingSequenceInitDefault: Frequency changed. Make sure timing critical " // sif::warning << "pollingSequenceInitDefault: Frequency changed. Make sure timing critical "
// << "SUS sensors still produce correct values" << std::endl; // << "SUS sensors still produce correct values" << std::endl;
@ -173,7 +173,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
// thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ);
/* Write setup */ /* Write setup */
// thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); // thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE);
// thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE);
@ -192,7 +192,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) {
// thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ);
// thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ);
/* Write setup */ /* Write setup */
// thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION);
// thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); // thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE);
// thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE);
@ -542,7 +542,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) {
uint32_t length = thisSequence->getPeriodMs(); uint32_t length = thisSequence->getPeriodMs();
#if OBSW_ADD_ACS_BOARD == 1 #if OBSW_ADD_ACS_BOARD == 1
thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4, thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4,
@ -563,28 +563,28 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) {
thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8, thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4,
DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6,
DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8, thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION); DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE); DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4,
DeviceHandlerIF::GET_WRITE); DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6,
DeviceHandlerIF::SEND_READ); DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8, thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ); DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0, thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0,
@ -619,6 +619,16 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) {
thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ);
#endif #endif
#if RPI_TEST_GPS_HANDLER == 1
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ);
#endif
static_cast<void>(length); static_cast<void>(length);
if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) {
sif::error << "Test PST initialization failed" << std::endl; sif::error << "Test PST initialization failed" << std::endl;
@ -627,6 +637,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#if TE7020 == 1
ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) {
uint32_t length = thisSequence->getPeriodMs(); uint32_t length = thisSequence->getPeriodMs();
@ -675,4 +686,4 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) {
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#endif /* TE7020 == 1 */

View File

@ -1,7 +1,14 @@
#ifndef POLLINGSEQUENCEFACTORY_H_ #ifndef POLLINGSEQUENCEFACTORY_H_
#define POLLINGSEQUENCEFACTORY_H_ #define POLLINGSEQUENCEFACTORY_H_
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include "OBSWConfig.h"
#if defined(RASPBERRY_PI)
#include "rpiConfig.h"
#elif defined(XIPHOS_Q7S)
#include "q7sConfig.h"
#endif
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
class FixedTimeslotTaskIF; class FixedTimeslotTaskIF;
@ -48,11 +55,13 @@ ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence);
*/ */
ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence);
#if TE7020 == 1
/** /**
* @brief This polling sequence will be created when the software is compiled for the TE0720. * @brief This polling sequence will be created when the software is compiled for the TE0720.
*/ */
ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence);
#endif
} }

View File

@ -50,11 +50,25 @@ ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, size_t *foundLen) { DeviceCommandId_t *foundId, size_t *foundLen) {
// Pass data to GPS library // Pass data to GPS library
if(len > 0) { if(len > 0) {
sif::info << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl;
if (internalState == InternalStates::WAIT_FIRST_MESSAGE) {
// TODO: Check whether data is valid by chcking whether NMEA start string is valid
commandExecuted = true;
}
int result = lwgps_process(&gpsData, start, len); int result = lwgps_process(&gpsData, start, len);
if(result != 0) { if(result != 1) {
sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps"
<< std::endl; << std::endl;
} }
else {
sif::info << "GPS Data" << std::endl;
// Print messages
printf("Valid status: %d\n", gpsData.is_valid);
printf("Latitude: %f degrees\n", gpsData.latitude);
printf("Longitude: %f degrees\n", gpsData.longitude);
printf("Altitude: %f meters\n", gpsData.altitude);
}
*foundLen = len;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;