ploc supervisor wip

This commit is contained in:
Jakob.Meier 2021-07-22 08:06:04 +02:00
parent 444f001775
commit 009139ae50
7 changed files with 194 additions and 40 deletions

View File

@ -670,3 +670,22 @@ Rebooting currently running image:
````
xsc_boot_copy -r
````
## Setting time on Q7S
Setting date and time (only timezone UTC available)
````
timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
````
Setting UNIX time
````
date +%s -s @1626337522
````
This only sets the system time and does not updating the time of the real time clock. To harmonize
the system time with the real time clock run
````
hwclock -w
````
Reading the real time clock
````
hwclock --show
````

View File

@ -171,9 +171,7 @@ void ObjectFactory::produce(void* args){
SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR,
std::string("/dev/spidev2.0"), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE,
spi::DEFAULT_MAX_1227_SPEED);
RadiationSensorHandler* radsensor = new RadiationSensorHandler(objects::RAD_SENSOR,
objects::SPI_COM_IF, spiCookieRadSensor);
radsensor->setStartUpImmediately();
new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor);
GpioCookie* gpioCookieSus = new GpioCookie();
@ -404,9 +402,7 @@ void ObjectFactory::produce(void* args){
std::string("/dev/ttyUL0"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE);
syrlinksUartCookie->setParityEven();
SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER,
objects::UART_COM_IF, syrlinksUartCookie);
syrlinksHkHandler->setModeNormal();
new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie);
#if Q7S_ADD_RTD_DEVICES == 1
GpioCookie* rtdGpioCookie = new GpioCookie;
@ -551,9 +547,11 @@ void ObjectFactory::produce(void* args){
std::string("/dev/i2c-0"));
new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
#if ADD_PLOC_MPSOC == 1
UartCookie* plocMpsocCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"),
UartModes::NON_CANONICAL, 115200, PLOC_MPSOC::MAX_REPLY_SIZE);
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie);
#endif
GpioCookie* gpioCookieRw = new GpioCookie;
GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT,
@ -629,6 +627,17 @@ void ObjectFactory::produce(void* args){
new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie);
#endif
#if ADD_PLOC_SUPERVISOR == 1
/* Configuration for MIO0 on TE0720-03-1CFA */
UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER,
std::string("/dev/ttyUL3"), UartModes::NON_CANONICAL, 115200,
PLOC_SPV::MAX_REPLY_SIZE);
PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler(
objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie);
plocSupervisor->setStartUpImmediately();
#endif
#endif /* TE0720 == 0 */
new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR);

View File

@ -30,8 +30,9 @@ debugging. */
#define TEST_CCSDS_BRIDGE 0
#define PERFORM_PTME_TEST 0
#define ADD_PLOC_SUPERVISOR 1
#define ADD_PLOC_MPSOC 0
#define TE0720 1
#define TE0720 0
#define TE0720_HEATER_TEST 0
#define P60DOCK_DEBUG 0
@ -42,13 +43,14 @@ debugging. */
#define IMQT_DEBUG 0
#define ADIS16507_DEBUG 1
#define L3GD20_GYRO_DEBUG 0
#define DEBUG_RAD_SENSOR 1
#define DEBUG_RAD_SENSOR 0
#define DEBUG_SUS 1
#define DEBUG_RTD 1
#define IMTQ_DEBUG 1
#define RW_DEBUG 0
#define START_TRACKER_DEBUG 0
#define PLOC_MPSOC_DEBUG 1
#define PLOC_SUPERVISOR_DEBUG 1
// Leave at one as the BSP is linux. Used by the ADIS16507 device handler
#define OBSW_ADIS16507_LINUX_COM_IF 1

View File

@ -449,8 +449,32 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
// Length of a communication cycle
uint32_t length = thisSequence->getPeriodMs();
#if ADD_PLOC_MPSOC == 1
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6,
DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ);
#endif
#if ADD_PLOC_SUPERVISOR == 1
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.6,
DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ);
#endif
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0,
DeviceHandlerIF::PERFORM_OPERATION);
#if OBSW_ADD_GPS == 1
@ -460,8 +484,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
DeviceHandlerIF::PERFORM_OPERATION);
#endif
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2,
DeviceHandlerIF::SEND_WRITE);
#if OBSW_ADD_GPS == 1
@ -471,8 +493,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
DeviceHandlerIF::SEND_WRITE);
#endif
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4,
DeviceHandlerIF::GET_WRITE);
#if OBSW_ADD_GPS == 1
@ -482,8 +502,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
DeviceHandlerIF::GET_WRITE);
#endif
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6,
DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6,
DeviceHandlerIF::SEND_READ);
#if OBSW_ADD_GPS == 1
@ -493,8 +511,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) {
DeviceHandlerIF::SEND_READ);
#endif
thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8,
DeviceHandlerIF::GET_READ);
#if OBSW_ADD_GPS == 1

View File

@ -62,12 +62,24 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
prepareSelBootImageCmd(commandData);
return RETURN_OK;
}
case(PLOC_SPV::RESET_MPSOC): {
prepareEmptyCmd(PLOC_SPV::APID_RESET_MPSOC);
return RETURN_OK;
}
case(PLOC_SPV::SET_TIME_REF): {
return prepareSetTimeRefCmd();
}
case(PLOC_SPV::SET_BOOT_TIMEOUT): {
prepareSetBootTimeoutCmd(commandData);
return RETURN_OK;
}
case(PLOC_SPV::SET_MAX_RESTART_TRIES): {
prepareRestartTriesCmd(commandData);
return RETURN_OK;
}
case(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION): {
prepareDisableHk();
return RETURN_OK;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
@ -87,6 +99,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES);
this->insertInCommandMap(PLOC_SPV::RESET_MPSOC);
this->insertInCommandMap(PLOC_SPV::SET_TIME_REF);
this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION);
this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT);
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, nullptr, PLOC_SPV::SIZE_HK_REPORT);
@ -299,29 +312,12 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
}
uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET;
hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.nvm0_1_state = *(data + offset);
offset += 1;
hkset.nvm3_state = *(data + offset);
offset += 1;
hkset.missionIoState = *(data + offset);
offset += 1;
hkset.fmcState = *(data + offset);
offset += 1;
hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
@ -334,13 +330,35 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8
| *(data + offset + 3);
offset += 4;
hkset.nvm0_1_state = *(data + offset);
offset += 1;
hkset.nvm3_state = *(data + offset);
offset += 1;
hkset.missionIoState = *(data + offset);
offset += 1;
hkset.fmcState = *(data + offset);
offset += 1;
nextReplyId = PLOC_SPV::EXE_REPORT;
#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_MPSOC_DEBUG == 1
sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl;
#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1
sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: "
<< static_cast<unsigned int>(hkset.nvm0_1_state.value) << std::endl;
@ -350,11 +368,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
<< static_cast<unsigned int>(hkset.missionIoState.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: "
<< static_cast<unsigned int>(hkset.fmcState.value) << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl;
sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl;
#endif
return result;
@ -509,6 +523,14 @@ ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() {
return RETURN_OK;
}
void PlocSupervisorHandler::prepareDisableHk() {
PLOC_SPV::DisablePeriodicHkTransmission packet;
memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = packet.getFullSize();
nextReplyId = PLOC_SPV::ACK_REPORT;
}
void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) {
uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8
| *(commandData + 3);
@ -519,6 +541,15 @@ void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData
nextReplyId = PLOC_SPV::ACK_REPORT;
}
void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData) {
uint8_t restartTries = *(commandData);
PLOC_SPV::SetRestartTries packet(restartTries);
memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = packet.getFullSize();
nextReplyId = PLOC_SPV::ACK_REPORT;
}
void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;

View File

@ -164,6 +164,8 @@ private:
*/
void prepareSelBootImageCmd(const uint8_t * commandData);
void prepareDisableHk();
/**
* @brief This function fills the commandBuffer with the data to update the time of the
* PLOC supervisor.
@ -176,6 +178,8 @@ private:
*/
void prepareSetBootTimeoutCmd(const uint8_t * commandData);
void prepareRestartTriesCmd(const uint8_t * commandData);
/**
* @brief In case an acknowledgment failure reply has been received this function disables
* all previously enabled commands and resets the exepected replies variable of an

View File

@ -19,6 +19,7 @@ static const DeviceCommandId_t SET_BOOT_TIMEOUT = 6;
static const DeviceCommandId_t SET_MAX_RESTART_TRIES = 7;
static const DeviceCommandId_t RESET_MPSOC = 8;
static const DeviceCommandId_t SET_TIME_REF = 9;
static const DeviceCommandId_t DISABLE_PERIOIC_HK_TRANSMISSION = 10;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
@ -64,6 +65,7 @@ static const uint16_t APID_UPDATE_VERIFY = 0xB2;
static const uint16_t APID_WTD_ENABLE = 0xC0;
static const uint16_t APID_WTD_CONFIG_TIMEOUT = 0xC1;
static const uint16_t APID_SET_TIME_REF = 0xC2;
static const uint16_t APID_DISABLE_HK = 0xC3;
static const uint16_t APID_GET_HK_REPORT = 0xC6;
@ -289,6 +291,77 @@ private:
}
};
/**
* @brief This class can be used to generate the space packet to set the maximum boot tries.
*/
class SetRestartTries: public SpacePacket {
public:
/**
* @brief Constructor
*
* @param restartTries Maximum restart tries to set.
*/
SetRestartTries(uint8_t restartTries) :
SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_MAX_RESTART_TRIES, 1), restartTries(
restartTries) {
initPacket();
}
private:
uint8_t restartTries = 0;
/** Restart tries value (uint8_t) and crc (uint16_t) */
static const uint16_t DATA_FIELD_LENGTH = 3;
void initPacket() {
uint8_t* data_field_ptr = this->localData.fields.buffer;
*data_field_ptr = restartTries;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
size_t serializedSize = 0;
uint8_t* crcPtr = data_field_ptr + 1;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPtr, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief With this class the space packet can be generated to disable to periodic transmission
* of housekeeping data. Normally, this will be disabled by default. However, adding this
* command can be useful for debugging.
*/
class DisablePeriodicHkTransmission: public SpacePacket {
public:
/**
* @brief Constructor
*/
DisablePeriodicHkTransmission() :
SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_DISABLE_HK, 1) {
initPacket();
}
private:
uint8_t disableHk = 0;
/** Restart tries value (uint8_t) and crc (uint16_t) */
static const uint16_t DATA_FIELD_LENGTH = 3;
void initPacket() {
uint8_t* data_field_ptr = this->localData.fields.buffer;
*data_field_ptr = disableHk;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
size_t serializedSize = 0;
uint8_t* crcPtr = data_field_ptr + 1;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPtr, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This dataset to store the housekeeping data of the supervisor.
*/