v1.10.0 #220

Merged
meierj merged 592 commits from develop into main 2022-04-22 07:42:20 +02:00
7 changed files with 473 additions and 413 deletions
Showing only changes of commit bd0df3493f - Show all commits

View File

@ -1207,8 +1207,15 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF*
q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE, q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE,
spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED);
// Create device handler components // Create device handler components
auto plPcduHandler = auto plPcduHandler = new PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF,
PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie, gpioComIF); spiCookie, gpioComIF, false);
#if OBSW_TEST_PL_PCDU == 1
plPcduHandler->setStartUpImmediately();
#if OBSW_DEBUG_PL_PCDU == 1
plPcduHandler->setToGoToNormalModeImmediately(true);
plPcduHandler->enablePeriodicPrintout(true, 5);
#endif
#endif
} }
void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {

View File

@ -4,19 +4,18 @@
0x43400001;THERMAL_CONTROLLER 0x43400001;THERMAL_CONTROLLER
0x44120006;MGM_0_LIS3_HANDLER 0x44120006;MGM_0_LIS3_HANDLER
0x44120010;GYRO_0_ADIS_HANDLER 0x44120010;GYRO_0_ADIS_HANDLER
0x44120032;SUS_1 0x44120032;SUS_0
0x44120033;SUS_2 0x44120033;SUS_1
0x44120034;SUS_3 0x44120034;SUS_2
0x44120035;SUS_4 0x44120035;SUS_3
0x44120036;SUS_5 0x44120036;SUS_4
0x44120037;SUS_6 0x44120037;SUS_5
0x44120038;SUS_7 0x44120038;SUS_6
0x44120039;SUS_8 0x44120039;SUS_7
0x44120040;SUS_9 0x44120040;SUS_8
0x44120041;SUS_10 0x44120041;SUS_9
0x44120042;SUS_11 0x44120042;SUS_10
0x44120043;SUS_12 0x44120043;SUS_11
0x44120044;SUS_13
0x44120047;RW1 0x44120047;RW1
0x44120107;MGM_1_RM3100_HANDLER 0x44120107;MGM_1_RM3100_HANDLER
0x44120111;GYRO_1_L3G_HANDLER 0x44120111;GYRO_1_L3G_HANDLER
@ -36,6 +35,7 @@
0x44250002;PDU2_HANDLER 0x44250002;PDU2_HANDLER
0x44250003;ACU_HANDLER 0x44250003;ACU_HANDLER
0x44260000;BPX_BATT_HANDLER 0x44260000;BPX_BATT_HANDLER
0x44300000;PLPCDU_HANDLER
0x443200A5;RAD_SENSOR 0x443200A5;RAD_SENSOR
0x44330000;PLOC_UPDATER 0x44330000;PLOC_UPDATER
0x44330001;PLOC_MEMORY_DUMPER 0x44330001;PLOC_MEMORY_DUMPER
@ -101,6 +101,7 @@
0x53ffffff;FSFW_OBJECTS_END 0x53ffffff;FSFW_OBJECTS_END
0x54000010;SPI_TEST 0x54000010;SPI_TEST
0x54000020;UART_TEST 0x54000020;UART_TEST
0x54000030;I2C_TEST
0x5400AFFE;DUMMY_HANDLER 0x5400AFFE;DUMMY_HANDLER
0x5400CAFE;DUMMY_INTERFACE 0x5400CAFE;DUMMY_INTERFACE
0x54123456;LIBGPIOD_TEST 0x54123456;LIBGPIOD_TEST

1 0x00005060 P60DOCK_TEST_TASK
4 0x43400001 THERMAL_CONTROLLER
5 0x44120006 MGM_0_LIS3_HANDLER
6 0x44120010 GYRO_0_ADIS_HANDLER
7 0x44120032 SUS_0
8 0x44120033 SUS_1
9 0x44120034 SUS_2
10 0x44120035 SUS_3
11 0x44120036 SUS_4
12 0x44120037 SUS_5
13 0x44120038 SUS_6
14 0x44120039 SUS_7
15 0x44120040 SUS_8
16 0x44120041 SUS_9
17 0x44120042 SUS_10
18 0x44120043 SUS_11
0x44120047 RW1
19 0x44120107 0x44120047 MGM_1_RM3100_HANDLER RW1
20 0x44120111 0x44120107 GYRO_1_L3G_HANDLER MGM_1_RM3100_HANDLER
21 0x44120148 0x44120111 RW2 GYRO_1_L3G_HANDLER
35 0x44250003 0x44250002 ACU_HANDLER PDU2_HANDLER
36 0x44260000 0x44250003 BPX_BATT_HANDLER ACU_HANDLER
37 0x44300000 0x44260000 PLPCDU_HANDLER BPX_BATT_HANDLER
38 0x44300000 PLPCDU_HANDLER
39 0x443200A5 RAD_SENSOR
40 0x44330000 PLOC_UPDATER
41 0x44330001 PLOC_MEMORY_DUMPER
101 0x53500010 0x53ffffff TIME_STAMPER FSFW_OBJECTS_END
102 0x53ffffff 0x54000010 FSFW_OBJECTS_END SPI_TEST
103 0x54000010 0x54000020 SPI_TEST UART_TEST
104 0x54000030 I2C_TEST
105 0x54000020 0x5400AFFE UART_TEST DUMMY_HANDLER
106 0x54000030 0x5400CAFE I2C_TEST DUMMY_INTERFACE
107 0x5400AFFE 0x54123456 DUMMY_HANDLER LIBGPIOD_TEST

View File

@ -1,8 +1,8 @@
/** /**
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 110 translations. * Contains 111 translations.
* Generated on: 2022-02-03 12:01:36 * Generated on: 2022-02-21 17:31:37
*/ */
#include "translateObjects.h" #include "translateObjects.h"
@ -12,6 +12,7 @@ const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER";
const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER";
const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER";
const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER";
const char *SUS_0_STRING = "SUS_0";
const char *SUS_1_STRING = "SUS_1"; const char *SUS_1_STRING = "SUS_1";
const char *SUS_2_STRING = "SUS_2"; const char *SUS_2_STRING = "SUS_2";
const char *SUS_3_STRING = "SUS_3"; const char *SUS_3_STRING = "SUS_3";
@ -23,8 +24,6 @@ const char *SUS_8_STRING = "SUS_8";
const char *SUS_9_STRING = "SUS_9"; const char *SUS_9_STRING = "SUS_9";
const char *SUS_10_STRING = "SUS_10"; const char *SUS_10_STRING = "SUS_10";
const char *SUS_11_STRING = "SUS_11"; const char *SUS_11_STRING = "SUS_11";
const char *SUS_12_STRING = "SUS_12";
const char *SUS_13_STRING = "SUS_13";
const char *RW1_STRING = "RW1"; const char *RW1_STRING = "RW1";
const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER";
const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER";
@ -44,6 +43,7 @@ const char *PDU1_HANDLER_STRING = "PDU1_HANDLER";
const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; const char *PDU2_HANDLER_STRING = "PDU2_HANDLER";
const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *ACU_HANDLER_STRING = "ACU_HANDLER";
const char *BPX_BATT_HANDLER_STRING = "BPX_BATT_HANDLER"; const char *BPX_BATT_HANDLER_STRING = "BPX_BATT_HANDLER";
const char *PLPCDU_HANDLER_STRING = "PLPCDU_HANDLER";
const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *RAD_SENSOR_STRING = "RAD_SENSOR";
const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER";
const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER";
@ -109,6 +109,7 @@ const char *TIME_STAMPER_STRING = "TIME_STAMPER";
const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END";
const char *SPI_TEST_STRING = "SPI_TEST"; const char *SPI_TEST_STRING = "SPI_TEST";
const char *UART_TEST_STRING = "UART_TEST"; const char *UART_TEST_STRING = "UART_TEST";
const char *I2C_TEST_STRING = "I2C_TEST";
const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER";
const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE";
const char *LIBGPIOD_TEST_STRING = "LIBGPIOD_TEST"; const char *LIBGPIOD_TEST_STRING = "LIBGPIOD_TEST";
@ -132,31 +133,29 @@ const char* translateObject(object_id_t object) {
case 0x44120010: case 0x44120010:
return GYRO_0_ADIS_HANDLER_STRING; return GYRO_0_ADIS_HANDLER_STRING;
case 0x44120032: case 0x44120032:
return SUS_1_STRING; return SUS_0_STRING;
case 0x44120033: case 0x44120033:
return SUS_2_STRING; return SUS_1_STRING;
case 0x44120034: case 0x44120034:
return SUS_3_STRING; return SUS_2_STRING;
case 0x44120035: case 0x44120035:
return SUS_4_STRING; return SUS_3_STRING;
case 0x44120036: case 0x44120036:
return SUS_5_STRING; return SUS_4_STRING;
case 0x44120037: case 0x44120037:
return SUS_6_STRING; return SUS_5_STRING;
case 0x44120038: case 0x44120038:
return SUS_7_STRING; return SUS_6_STRING;
case 0x44120039: case 0x44120039:
return SUS_8_STRING; return SUS_7_STRING;
case 0x44120040: case 0x44120040:
return SUS_9_STRING; return SUS_8_STRING;
case 0x44120041: case 0x44120041:
return SUS_10_STRING; return SUS_9_STRING;
case 0x44120042: case 0x44120042:
return SUS_11_STRING; return SUS_10_STRING;
case 0x44120043: case 0x44120043:
return SUS_12_STRING; return SUS_11_STRING;
case 0x44120044:
return SUS_13_STRING;
case 0x44120047: case 0x44120047:
return RW1_STRING; return RW1_STRING;
case 0x44120107: case 0x44120107:
@ -195,6 +194,8 @@ const char* translateObject(object_id_t object) {
return ACU_HANDLER_STRING; return ACU_HANDLER_STRING;
case 0x44260000: case 0x44260000:
return BPX_BATT_HANDLER_STRING; return BPX_BATT_HANDLER_STRING;
case 0x44300000:
return PLPCDU_HANDLER_STRING;
case 0x443200A5: case 0x443200A5:
return RAD_SENSOR_STRING; return RAD_SENSOR_STRING;
case 0x44330000: case 0x44330000:
@ -325,6 +326,8 @@ const char* translateObject(object_id_t object) {
return SPI_TEST_STRING; return SPI_TEST_STRING;
case 0x54000020: case 0x54000020:
return UART_TEST_STRING; return UART_TEST_STRING;
case 0x54000030:
return I2C_TEST_STRING;
case 0x5400AFFE: case 0x5400AFFE:
return DUMMY_HANDLER_STRING; return DUMMY_HANDLER_STRING;
case 0x5400CAFE: case 0x5400CAFE:

View File

@ -1,8 +1,8 @@
/** /**
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 110 translations. * Contains 111 translations.
* Generated on: 2022-02-03 12:01:36 * Generated on: 2022-02-21 17:31:37
*/ */
#include "translateObjects.h" #include "translateObjects.h"
@ -12,6 +12,7 @@ const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER";
const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER";
const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER";
const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER";
const char *SUS_0_STRING = "SUS_0";
const char *SUS_1_STRING = "SUS_1"; const char *SUS_1_STRING = "SUS_1";
const char *SUS_2_STRING = "SUS_2"; const char *SUS_2_STRING = "SUS_2";
const char *SUS_3_STRING = "SUS_3"; const char *SUS_3_STRING = "SUS_3";
@ -23,8 +24,6 @@ const char *SUS_8_STRING = "SUS_8";
const char *SUS_9_STRING = "SUS_9"; const char *SUS_9_STRING = "SUS_9";
const char *SUS_10_STRING = "SUS_10"; const char *SUS_10_STRING = "SUS_10";
const char *SUS_11_STRING = "SUS_11"; const char *SUS_11_STRING = "SUS_11";
const char *SUS_12_STRING = "SUS_12";
const char *SUS_13_STRING = "SUS_13";
const char *RW1_STRING = "RW1"; const char *RW1_STRING = "RW1";
const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER";
const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER";
@ -44,6 +43,7 @@ const char *PDU1_HANDLER_STRING = "PDU1_HANDLER";
const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; const char *PDU2_HANDLER_STRING = "PDU2_HANDLER";
const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *ACU_HANDLER_STRING = "ACU_HANDLER";
const char *BPX_BATT_HANDLER_STRING = "BPX_BATT_HANDLER"; const char *BPX_BATT_HANDLER_STRING = "BPX_BATT_HANDLER";
const char *PLPCDU_HANDLER_STRING = "PLPCDU_HANDLER";
const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *RAD_SENSOR_STRING = "RAD_SENSOR";
const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER";
const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER";
@ -109,6 +109,7 @@ const char *TIME_STAMPER_STRING = "TIME_STAMPER";
const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END";
const char *SPI_TEST_STRING = "SPI_TEST"; const char *SPI_TEST_STRING = "SPI_TEST";
const char *UART_TEST_STRING = "UART_TEST"; const char *UART_TEST_STRING = "UART_TEST";
const char *I2C_TEST_STRING = "I2C_TEST";
const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER";
const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE";
const char *LIBGPIOD_TEST_STRING = "LIBGPIOD_TEST"; const char *LIBGPIOD_TEST_STRING = "LIBGPIOD_TEST";
@ -117,8 +118,8 @@ const char *TM_FUNNEL_STRING = "TM_FUNNEL";
const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE";
const char *NO_OBJECT_STRING = "NO_OBJECT"; const char *NO_OBJECT_STRING = "NO_OBJECT";
const char *translateObject(object_id_t object) { const char* translateObject(object_id_t object) {
switch ((object & 0xFFFFFFFF)) { switch( (object & 0xFFFFFFFF) ) {
case 0x00005060: case 0x00005060:
return P60DOCK_TEST_TASK_STRING; return P60DOCK_TEST_TASK_STRING;
case 0x43000003: case 0x43000003:
@ -132,31 +133,29 @@ const char *translateObject(object_id_t object) {
case 0x44120010: case 0x44120010:
return GYRO_0_ADIS_HANDLER_STRING; return GYRO_0_ADIS_HANDLER_STRING;
case 0x44120032: case 0x44120032:
return SUS_1_STRING; return SUS_0_STRING;
case 0x44120033: case 0x44120033:
return SUS_2_STRING; return SUS_1_STRING;
case 0x44120034: case 0x44120034:
return SUS_3_STRING; return SUS_2_STRING;
case 0x44120035: case 0x44120035:
return SUS_4_STRING; return SUS_3_STRING;
case 0x44120036: case 0x44120036:
return SUS_5_STRING; return SUS_4_STRING;
case 0x44120037: case 0x44120037:
return SUS_6_STRING; return SUS_5_STRING;
case 0x44120038: case 0x44120038:
return SUS_7_STRING; return SUS_6_STRING;
case 0x44120039: case 0x44120039:
return SUS_8_STRING; return SUS_7_STRING;
case 0x44120040: case 0x44120040:
return SUS_9_STRING; return SUS_8_STRING;
case 0x44120041: case 0x44120041:
return SUS_10_STRING; return SUS_9_STRING;
case 0x44120042: case 0x44120042:
return SUS_11_STRING; return SUS_10_STRING;
case 0x44120043: case 0x44120043:
return SUS_12_STRING; return SUS_11_STRING;
case 0x44120044:
return SUS_13_STRING;
case 0x44120047: case 0x44120047:
return RW1_STRING; return RW1_STRING;
case 0x44120107: case 0x44120107:
@ -195,6 +194,8 @@ const char *translateObject(object_id_t object) {
return ACU_HANDLER_STRING; return ACU_HANDLER_STRING;
case 0x44260000: case 0x44260000:
return BPX_BATT_HANDLER_STRING; return BPX_BATT_HANDLER_STRING;
case 0x44300000:
return PLPCDU_HANDLER_STRING;
case 0x443200A5: case 0x443200A5:
return RAD_SENSOR_STRING; return RAD_SENSOR_STRING;
case 0x44330000: case 0x44330000:
@ -325,6 +326,8 @@ const char *translateObject(object_id_t object) {
return SPI_TEST_STRING; return SPI_TEST_STRING;
case 0x54000020: case 0x54000020:
return UART_TEST_STRING; return UART_TEST_STRING;
case 0x54000030:
return I2C_TEST_STRING;
case 0x5400AFFE: case 0x5400AFFE:
return DUMMY_HANDLER_STRING; return DUMMY_HANDLER_STRING;
case 0x5400CAFE: case 0x5400CAFE:

View File

@ -5,8 +5,11 @@
#include "devices/gpioIds.h" #include "devices/gpioIds.h"
PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie,
GpioIF* gpioIF) GpioIF* gpioIF, bool periodicPrintout)
: DeviceHandlerBase(objectId, comIF, cookie), adcSet(this), gpioIF(gpioIF) {} : DeviceHandlerBase(objectId, comIF, cookie),
adcSet(this),
periodicPrintout(periodicPrintout),
gpioIF(gpioIF) {}
void PayloadPcduHandler::doStartUp() { void PayloadPcduHandler::doStartUp() {
if ((state != States::PCDU_OFF) and (state != States::ON_TRANS_SSR)) { if ((state != States::PCDU_OFF) and (state != States::ON_TRANS_SSR)) {
@ -25,7 +28,7 @@ void PayloadPcduHandler::doStartUp() {
if (transitionOk) { if (transitionOk) {
transitionOk = false; transitionOk = false;
// We are now in ON mode // We are now in ON mode
setMode(MODE_ON); startTransition(MODE_NORMAL, 0);
adcState = AdcStates::BOOT_DELAY; adcState = AdcStates::BOOT_DELAY;
// The ADC can now be read. If the values are not close to zero, we should not allow // The ADC can now be read. If the values are not close to zero, we should not allow
// transition // transition
@ -36,6 +39,169 @@ void PayloadPcduHandler::doStartUp() {
void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
if (mode == _MODE_TO_NORMAL) { if (mode == _MODE_TO_NORMAL) {
stateMachineToNormal();
}
}
void PayloadPcduHandler::doShutDown() {}
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
switch (adcState) {
case (AdcStates::SEND_SETUP): {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
case (AdcStates::NORMAL): {
*id = plpcdu::READ_WITH_TEMP;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
default: {
break;
}
}
return NOTHING_TO_SEND;
}
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if (adcState == AdcStates::SEND_SETUP) {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
}
return NOTHING_TO_SEND;
}
void PayloadPcduHandler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet);
insertInCommandAndReplyMap(plpcdu::READ_TEMP, 1, &adcSet);
insertInCommandAndReplyMap(plpcdu::READ_WITH_TEMP, 1, &adcSet);
insertInCommandAndReplyMap(plpcdu::SETUP_CMD, 1);
}
ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (plpcdu::SETUP_CMD): {
cmdBuf[0] = plpcdu::SETUP_BYTE;
rawPacket = cmdBuf.data();
rawPacketLen = 1;
break;
}
case (plpcdu::READ_CMD): {
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case (plpcdu::READ_TEMP): {
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case (plpcdu::READ_WITH_TEMP): {
size_t sz = 0;
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz);
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
rawPacketLen = sz;
rawPacket = cmdBuf.data();
}
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
ReturnValue_t PayloadPcduHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
// SPI is full duplex
*foundId = getPendingCommand();
*foundLen = remainingSize;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t* packet) {
using namespace plpcdu;
switch (id) {
case (SETUP_CMD): {
break;
}
case (READ_TEMP): {
uint8_t tempStartIdx = TEMP_REPLY_SIZE - 2;
adcSet.tempC.value =
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
break;
}
case (READ_CMD): {
PoolReadGuard pg(&adcSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
handleExtConvRead(packet);
handlePrintout();
break;
}
case (READ_WITH_TEMP): {
PoolReadGuard pg(&adcSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
handleExtConvRead(packet);
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
adcSet.tempC.value =
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
handlePrintout();
break;
}
default: {
break;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
// 20 minutes transition delay is allowed
return 20 * 60 * 60;
}
ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::CHANNEL_VEC, &channelValues);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC);
return HasReturnvaluesIF::RETURN_OK;
}
void PayloadPcduHandler::setToGoToNormalModeImmediately(bool enable) {
this->goToNormalMode = enable;
}
void PayloadPcduHandler::handleExtConvRead(const uint8_t* bufStart) {
for (uint8_t idx = 0; idx < 12; idx++) {
adcSet.channels[idx] = bufStart[idx * 2 + 1] << 8 | bufStart[idx * 2 + 2];
}
}
void PayloadPcduHandler::handlePrintout() {
if (periodicPrintout) {
if (opDivider.checkAndIncrement()) {
sif::info << "PL PCDU ADC hex [" << std::hex << std::setw(4);
for (uint8_t idx = 0; idx < 12; idx++) {
sif::info << std::setfill('0') << adcSet.channels[idx];
if (idx < 11) {
sif::info << ",";
}
}
sif::info << "] | T[C] " << std::dec << adcSet.tempC.value;
}
}
}
void PayloadPcduHandler::enablePeriodicPrintout(bool enable, uint8_t divider) {
this->periodicPrintout = enable;
opDivider.setDivider(divider);
}
void PayloadPcduHandler::stateMachineToNormal() {
if (adcState == AdcStates::BOOT_DELAY) { if (adcState == AdcStates::BOOT_DELAY) {
if (adcCountdown.hasTimedOut()) { if (adcCountdown.hasTimedOut()) {
adcState = AdcStates::SEND_SETUP; adcState = AdcStates::SEND_SETUP;
@ -45,9 +211,11 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
if (adcState == AdcStates::SEND_SETUP) { if (adcState == AdcStates::SEND_SETUP) {
if (adcCmdExecuted) { if (adcCmdExecuted) {
adcState = AdcStates::NORMAL; adcState = AdcStates::NORMAL;
setMode(MODE_NORMAL, plpcdu::NORMAL_ADC_ONLY);
adcCmdExecuted = false; adcCmdExecuted = false;
} }
} }
if (submode == plpcdu::NORMAL_ALL_ON) {
if (state == States::ON_TRANS_ADC_CLOSE_ZERO) { if (state == States::ON_TRANS_ADC_CLOSE_ZERO) {
if (not commandExecuted) { if (not commandExecuted) {
countdown.resetTimer(); countdown.resetTimer();
@ -128,7 +296,7 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
// ADC values are ok, 5 seconds have elapsed // ADC values are ok, 5 seconds have elapsed
if (transitionOk and countdown.hasTimedOut()) { if (transitionOk and countdown.hasTimedOut()) {
state = States::PCDU_ON; state = States::PCDU_ON;
setMode(MODE_NORMAL); setMode(MODE_NORMAL, plpcdu::NORMAL_ALL_ON);
countdown.resetTimer(); countdown.resetTimer();
commandExecuted = false; commandExecuted = false;
transitionOk = false; transitionOk = false;
@ -136,137 +304,3 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
} }
} }
} }
void PayloadPcduHandler::doShutDown() {}
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
switch (adcState) {
case (AdcStates::SEND_SETUP): {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
case (AdcStates::NORMAL): {
*id = plpcdu::READ_WITH_TEMP;
buildCommandFromCommand(*id, nullptr, 0);
break;
}
default: {
break;
}
}
return NOTHING_TO_SEND;
}
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if (adcState == AdcStates::SEND_SETUP) {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
}
return HasReturnvaluesIF::RETURN_OK;
}
void PayloadPcduHandler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet);
insertInCommandAndReplyMap(plpcdu::READ_TEMP, 1, &adcSet);
insertInCommandAndReplyMap(plpcdu::READ_WITH_TEMP, 1, &adcSet);
insertInCommandAndReplyMap(plpcdu::SETUP_CMD, 1);
}
ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (plpcdu::SETUP_CMD): {
cmdBuf[0] = plpcdu::SETUP_BYTE;
rawPacket = cmdBuf.data();
rawPacketLen = 1;
break;
}
case (plpcdu::READ_CMD): {
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case (plpcdu::READ_TEMP): {
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen);
rawPacket = cmdBuf.data();
break;
}
case (plpcdu::READ_WITH_TEMP): {
size_t sz = 0;
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz);
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
rawPacketLen = sz;
rawPacket = cmdBuf.data();
}
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
ReturnValue_t PayloadPcduHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
// SPI is full duplex
*foundId = getPendingCommand();
*foundLen = remainingSize;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t* packet) {
using namespace plpcdu;
switch (id) {
case (SETUP_CMD): {
break;
}
case (READ_TEMP): {
uint8_t tempStartIdx = TEMP_REPLY_SIZE - 2;
adcSet.tempC.value =
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
break;
}
case (READ_CMD): {
PoolReadGuard pg(&adcSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
for (uint8_t idx = 0; idx < 12; idx++) {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
}
break;
}
case (READ_WITH_TEMP): {
PoolReadGuard pg(&adcSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
return pg.getReadResult();
}
for (uint8_t idx = 0; idx < 12; idx++) {
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
}
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
adcSet.tempC.value =
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
break;
}
default: {
break;
}
}
return HasReturnvaluesIF::RETURN_OK;
}
uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
// 20 minutes transition delay is allowed
return 20 * 60 * 60;
}
ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::CHANNEL_VEC, &channelValues);
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC);
return HasReturnvaluesIF::RETURN_OK;
}
void PayloadPcduHandler::setToGoToNormalModeImmediately(bool enable) {
this->goToNormalMode = enable;
}

View File

@ -2,6 +2,7 @@
#define LINUX_DEVICES_PLPCDUHANDLER_H_ #define LINUX_DEVICES_PLPCDUHANDLER_H_
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <fsfw/timemanager/Countdown.h> #include <fsfw/timemanager/Countdown.h>
#include "devicedefinitions/payloadPcduDefinitions.h" #include "devicedefinitions/payloadPcduDefinitions.h"
@ -21,11 +22,13 @@
* - MPA - Medium Power Amplifier * - MPA - Medium Power Amplifier
* - HPA - High Power Amplifier * - HPA - High Power Amplifier
*/ */
class PayloadPcduHandler : DeviceHandlerBase { class PayloadPcduHandler : public DeviceHandlerBase {
public: public:
PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF); PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF,
bool periodicPrintout);
void setToGoToNormalModeImmediately(bool enable); void setToGoToNormalModeImmediately(bool enable);
void enablePeriodicPrintout(bool enable, uint8_t divider);
private: private:
enum class States { enum class States {
@ -61,6 +64,8 @@ class PayloadPcduHandler : DeviceHandlerBase {
bool transitionOk = false; bool transitionOk = false;
bool commandExecuted = false; bool commandExecuted = false;
bool adcCmdExecuted = false; bool adcCmdExecuted = false;
bool periodicPrintout = false;
PeriodicOperationDivider opDivider = PeriodicOperationDivider(5);
uint8_t tempReadDivisor = 1; uint8_t tempReadDivisor = 1;
Countdown countdown = Countdown(5000); Countdown countdown = Countdown(5000);
Countdown adcCountdown = Countdown(50); Countdown adcCountdown = Countdown(50);
@ -83,6 +88,10 @@ class PayloadPcduHandler : DeviceHandlerBase {
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override; LocalDataPoolManager& poolManager) override;
void handleExtConvRead(const uint8_t* bufStart);
void handlePrintout();
void stateMachineToNormal();
}; };
#endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */ #endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */

View File

@ -21,6 +21,9 @@ static constexpr DeviceCommandId_t SETUP_CMD = 1;
static constexpr DeviceCommandId_t READ_TEMP = 2; static constexpr DeviceCommandId_t READ_TEMP = 2;
static constexpr DeviceCommandId_t READ_WITH_TEMP = 3; static constexpr DeviceCommandId_t READ_WITH_TEMP = 3;
static constexpr Submode_t NORMAL_ADC_ONLY = 0;
static constexpr Submode_t NORMAL_ALL_ON = 1;
// 12 ADC values * 2 + trailing zero // 12 ADC values * 2 + trailing zero
static constexpr size_t ADC_REPLY_SIZE = 25; static constexpr size_t ADC_REPLY_SIZE = 25;
// Conversion byte + 24 * zero // Conversion byte + 24 * zero