basic structure for ILH PLOC control
This commit is contained in:
@ -156,6 +156,7 @@ ReturnValue_t PlocHandler::prepareTcMemWriteCommand(const uint8_t * commandData,
|
||||
| *(commandData + 2) << 8 | *(commandData + 3);
|
||||
const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16
|
||||
| *(commandData + 6) << 8 | *(commandData + 7);
|
||||
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
PLOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount);
|
||||
if (tcMemWrite.getFullSize() > PLOC::MAX_COMMAND_SIZE) {
|
||||
sif::debug << "PlocHandler::prepareTcMemWriteCommand: Command too big" << std::endl;
|
||||
@ -172,6 +173,7 @@ ReturnValue_t PlocHandler::prepareTcMemReadCommand(const uint8_t * commandData,
|
||||
size_t commandDataLen) {
|
||||
const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16
|
||||
| *(commandData + 2) << 8 | *(commandData + 3);
|
||||
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
PLOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount);
|
||||
if (tcMemRead.getFullSize() > PLOC::MAX_COMMAND_SIZE) {
|
||||
sif::debug << "PlocHandler::prepareTcMemReadCommand: Command too big" << std::endl;
|
||||
@ -482,14 +484,15 @@ void PlocHandler::disableExeReportReply() {
|
||||
}
|
||||
|
||||
ReturnValue_t PlocHandler::checkPacketSequenceCount(const uint8_t* data) {
|
||||
uint16_t receivedSequenceCount = *(data + 2) << 8 | *(data + 3) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
if (receivedSequenceCount != ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK)) {
|
||||
sif::debug << "PlocHandler::checkPacketSequenceCount: Packet sequence count mismatch"
|
||||
uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK);
|
||||
if (receivedSequenceCount != expectedPacketSequenceCount) {
|
||||
sif::debug
|
||||
<< "PlocHandler::checkPacketSequenceCount: Packet sequence count mismatch. "
|
||||
<< std::endl;
|
||||
/** The packet sequence count is corrected here to match the sequence count of the PLOC */
|
||||
packetSequenceCount = (receivedSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
return SUBSEQUENCE_COUNT_FAILURE;
|
||||
sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence "
|
||||
<< "count: " << expectedPacketSequenceCount << std::endl;
|
||||
}
|
||||
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
|
||||
packetSequenceCount = receivedSequenceCount;
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
/**
|
||||
* @brief This is the device handler for the PLOC.
|
||||
*
|
||||
* @details The PLOC uses the space packet protocol for communication. On each command the PLOC
|
||||
* answers at least with one acknowledgment and one execution report.
|
||||
* @details The PLOC uses the space packet protocol for communication. To each command the PLOC
|
||||
* answers with at least one acknowledgment and one execution report.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
@ -53,7 +53,6 @@ private:
|
||||
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC
|
||||
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC
|
||||
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC
|
||||
static const ReturnValue_t SUBSEQUENCE_COUNT_FAILURE = MAKE_RETURN_CODE(0xA4); //!> The packet sequence count does not match the expected packet sequence count. There may be one packet lost.
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_HANDLER;
|
||||
|
||||
@ -63,7 +62,7 @@ private:
|
||||
static const Event CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); //!> PLOC reply has invalid crc
|
||||
|
||||
static const uint16_t APID_MASK = 0x7FF;
|
||||
static const unit16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
|
||||
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
|
||||
|
||||
uint8_t commandBuffer[PLOC::MAX_COMMAND_SIZE];
|
||||
|
||||
@ -184,14 +183,19 @@ private:
|
||||
void disableExeReportReply();
|
||||
|
||||
/**
|
||||
* @brief This function checks the subsequence count of a received space packet to detect
|
||||
* lost packets.
|
||||
* @brief This function checks and increments the packet sequence count of a received space
|
||||
* packet.
|
||||
*
|
||||
* @param data Pointer to a space packet.
|
||||
*
|
||||
* @return RETURN_OK if successful, else SUBSEQUENCE_COUNT_FAILURE
|
||||
* @return RETURN_OK if successful
|
||||
*
|
||||
* @details There should be never a case in which a wrong packet sequence count is received
|
||||
* because the communication scheme between PLOC and OBC always follows a strict
|
||||
* procedure. Thus this function mainly serves for debugging purposes to detected an
|
||||
* invalid handling of the packet sequence count.
|
||||
*/
|
||||
ReturnValue_t checkSubsequenceCount(const uint8_t* data);
|
||||
ReturnValue_t checkPacketSequenceCount(const uint8_t* data);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_PLOCHANDLER_H_ */
|
||||
|
Reference in New Issue
Block a user