plocHandler wip

This commit is contained in:
Jakob Meier 2021-04-12 10:16:59 +02:00
parent 400f60c7be
commit 5d4c2bd521
9 changed files with 32 additions and 23 deletions

View File

@ -573,4 +573,10 @@ to install the required GPIO libraries before cloning the system root folder.
When using Eclipse, there are two special build variables in the project properties
→ C/C++ Build → Build Variables called `Q7S_SYSROOT` or `RPI_SYSROOT`. You can set
the sysroot path in those variables to get any additional includes like `gpiod.h` in the
Eclipse indexer.
Eclipse indexer.
## Xilinx UARTLIE
Get info about ttyUL* devices
````
cat /proc/tty/driver
````

View File

@ -321,7 +321,7 @@ void ObjectFactory::produce(){
Max31865PT1000Handler* rtdIc16 = new Max31865PT1000Handler(objects::RTD_IC16, objects::SPI_COM_IF, spiRtdIc16, 0);
Max31865PT1000Handler* rtdIc17 = new Max31865PT1000Handler(objects::RTD_IC17, objects::SPI_COM_IF, spiRtdIc17, 0);
Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18, objects::SPI_COM_IF, spiRtdIc18, 0);
rtdIc10->setStartUpImmediately();
// rtdIc10->setStartUpImmediately();
// rtdIc4->setStartUpImmediately();
I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE,
@ -329,9 +329,8 @@ void ObjectFactory::produce(){
IMTQHandler* imtqHandler = new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie);
imtqHandler->setStartUpImmediately();
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200,
UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200,
PLOC::MAX_REPLY_SIZE);
/* Testing PlocHandler on TE0720-03-1CFA */
PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF,
plocUartCookie);
plocHandler->setStartUpImmediately();

1
fsfw_hal Submodule

@ -0,0 +1 @@
Subproject commit 14fe32572d62db9d19707dc1f9bb6fecb1993b73

View File

@ -19,7 +19,7 @@ debugging. */
#define OBSW_ADD_TEST_CODE 1
#define TEST_LIBGPIOD 0
#define TE0720 1
#define TE0720 0
#define P60DOCK_DEBUG 0
#define PDU1_DEBUG 0

View File

@ -21,7 +21,8 @@ enum: uint8_t {
MGM_RM3100,
PCDU_HANDLER,
HEATER_HANDLER,
SA_DEPL_HANDLER
SA_DEPL_HANDLER,
PLOC_HANDLER
};
}

View File

@ -68,6 +68,7 @@ ReturnValue_t PlocHandler::buildCommandFromCommand(
}
void PlocHandler::fillCommandAndReplyMap() {
this->insertInCommandAndReplyMap(PLOC::TC_MEM_WRITE, 1, nullptr, PLOC::SIZE_ACK_REPORT);
this->insertInCommandAndReplyMap(PLOC::TC_MEM_READ, 1, nullptr, PLOC::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC::ACK_SUCCESS, 1);
this->insertInReplyMap(PLOC::ACK_FAILURE, 1);
@ -78,7 +79,7 @@ ReturnValue_t PlocHandler::scanForReply(const uint8_t *start,
ReturnValue_t result = RETURN_OK;
*foundId = *(start) << 8 | *(start + 1) & APID_MASK;
*foundId = (*(start) << 8 | *(start + 1)) & APID_MASK;
switch(*foundId) {
case(PLOC::ACK_SUCCESS):
@ -100,7 +101,7 @@ ReturnValue_t PlocHandler::scanForReply(const uint8_t *start,
ReturnValue_t PlocHandler::verifyPacket(const uint8_t* start, size_t* foundLen) {
uint16_t receivedCrc = *(start + *foundLen - 2) << 8 | *(start + *foundlen - 1);
uint16_t receivedCrc = *(start + *foundLen - 2) << 8 | *(start + *foundLen - 1);
if (receivedCrc != CRC::crc16ccitt(start, *foundLen, 0)) {
return CRC_FAILURE;
@ -112,8 +113,6 @@ ReturnValue_t PlocHandler::verifyPacket(const uint8_t* start, size_t* foundLen)
ReturnValue_t PlocHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
ReturnValue_t result = RETURN_OK;
switch (id) {
case (PLOC::ACK_SUCCESS):
receiveTm();
@ -133,7 +132,7 @@ ReturnValue_t PlocHandler::interpretDeviceReply(DeviceCommandId_t id,
return RETURN_OK;
}
ReturnValue_t PlocHandler::receiveTm() {
void PlocHandler::receiveTm() {
switch (rememberCommandId) {
case (PLOC::TC_MEM_WRITE):
break;
@ -154,8 +153,8 @@ void PlocHandler::receiveExecutionReport() {
communicationInterface->requestReceiveMessage(comCookie, PLOC::SIZE_EXE_REPORT);
communicationInterface->readReceivedMessage(comCookie, &receivedData, &receivedDataLen);
if(!verifyPacket(receivedData, receivedDataLen)) {
replyRawData(data, len, defaultRawReceiver);
if(!verifyPacket(receivedData, &receivedDataLen)) {
replyRawData(receivedData, receivedDataLen, defaultRawReceiver);
triggerEvent(EXE_RPT_INVALID_CRC);
sif::error << "PlocHandler::receiveExecutionReport: Execution report has invalid crc"
<< std::endl;
@ -167,7 +166,7 @@ void PlocHandler::receiveExecutionReport() {
void PlocHandler::handleExecutionReport(const uint8_t* receivedData, size_t receivedDataLen) {
uint16_t apid = *(start) << 8 | *(start + 1) & APID_MASK;
uint16_t apid = (*(receivedData) << 8 | *(receivedData + 1)) & APID_MASK;
switch (apid) {
case (PLOC::APID_EXE_SUCCESS): {
@ -205,15 +204,15 @@ void PlocHandler::receiveTmMemoryReadReport() {
return;
}
uint16_t apid = *(start) << 8 | *(start + 1) & APID_MASK;
uint16_t apid = (*(receivedData) << 8 | *(receivedData + 1)) & APID_MASK;
if (apid != PLOC::APID_TM_READ_REPORT) {
sif::error << "PlocHandler::receiveTmReadReport: Tm read report has invalid apid"
<< std::endl;
return;
}
if(!verifyPacket(receivedData, receivedDataLen)) {
replyRawData(data, len, defaultRawReceiver);
if(!verifyPacket(receivedData, &receivedDataLen)) {
replyRawData(receivedData, receivedDataLen, defaultRawReceiver);
triggerEvent(TM_READ_RPT_INVALID_CRC);
sif::error << "PlocHandler::receiveTmReadReport: TM read report has invalid crc"
<< std::endl;
@ -239,7 +238,7 @@ void PlocHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCom
return;
}
result = actionHelper.reportData(queueId, replyId, dataSet);
result = actionHelper.reportData(queueId, replyId, data, dataSize);
if (result != RETURN_OK) {
sif::debug << "PlocHandler::handleDeviceTM: Failed to report data" << std::endl;
}

View File

@ -45,6 +45,8 @@ private:
static const ReturnValue_t TC_ACK_FAILURE = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA1);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_HANDLER;
static const Event REQUESTING_TM_READ_REPORT_FAILED = MAKE_EVENT(0, severity::LOW);
static const Event TM_READ_RPT_INVALID_CRC = MAKE_EVENT(1, severity::LOW);
static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
@ -58,7 +60,7 @@ private:
/**
* @brief This function checks wheter a telemetry packet is expected or not.
*/
ReturnValue_t receiveTm();
void receiveTm();
/**
* @brief This function checks the crc of the received PLOC reply.

View File

@ -18,7 +18,7 @@ namespace IMTQ {
static const uint8_t MAX_REPLY_SIZE = SIZE_ENG_HK_DATA_REPLY;
static const uint8_t MAX_COMMAND_SIZE = 9;
static const uint8_t POOL_ENTRIES = 8;
static const uint8_t POOL_ENTRIES = 11;
/**
* Command code definitions. Each command or reply of an IMTQ request will begin with one of

View File

@ -21,6 +21,7 @@ namespace PLOC {
* SpacePacket apids of PLOC telecommands and telemetry.
*/
static const uint16_t APID_TC_MEM_WRITE = 0x714;
static const uint16_t APID_TC_MEM_READ = 0x715;
static const uint16_t APID_TM_READ_REPORT = 0x404;
static const uint16_t APID_EXE_SUCCESS = 0x402;
static const uint16_t APID_EXE_FAILURE = 0x403;
@ -62,7 +63,7 @@ namespace PLOC {
*/
void fillPacketDataField(const uint32_t* memAddrPtr) {
/* Add memAddr to packet data field */
memcpy(this->localData.fields.buffer, memAddrPtr, sizeof(memAddrPtr));
memcpy(this->localData.fields.buffer, memAddrPtr, sizeof(*memAddrPtr));
/* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 0;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 1;
@ -107,13 +108,13 @@ namespace PLOC {
*/
void fillPacketDataField(const uint32_t* memAddrPtr, const uint32_t* memoryDataPtr) {
/* Add memAddr to packet data field */
memcpy(this->localData.fields.buffer, memAddrPtr, sizeof(memAddrPtr));
memcpy(this->localData.fields.buffer, memAddrPtr, sizeof(*memAddrPtr));
/* Add memLen to packet data field */
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 0;
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 1;
/* Add memData to packet data field */
memcpy(this->localData.fields.buffer + OFFSET_MEM_DATA_FIELD, memAddrPtr,
sizeof(memAddrPtr));
sizeof(*memAddrPtr));
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE, 0);
/* Add crc to packet data field of space packet */