corrections in plocHandler, endianness
This commit is contained in:
@ -63,10 +63,10 @@ namespace PLOC {
|
||||
*
|
||||
* @param memAddr The memory address to read from.
|
||||
*/
|
||||
TcMemRead(const uint32_t memAddr) :
|
||||
SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ) {
|
||||
fillPacketDataField(&memAddr);
|
||||
}
|
||||
TcMemRead(const uint32_t memAddr, uint16_t sequenceCount) :
|
||||
SpacePacket(LENGTH_TC_MEM_READ - 1, true, APID_TC_MEM_READ, sequenceCount) {
|
||||
fillPacketDataField(&memAddr);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -80,22 +80,21 @@ namespace PLOC {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* memoryAddressPos = this->localData.fields.buffer;
|
||||
SerializeAdapter::serialize<uint32_t>(memAddrPtr, &memoryAddressPos, &serializedSize,
|
||||
sizeof(*memAddrPtr), SerializeIF::Endianness::BIG);
|
||||
sizeof(*memAddrPtr), SerializeIF::Endianness::LITTLE);
|
||||
|
||||
/* 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;
|
||||
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
|
||||
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
|
||||
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE, 0);
|
||||
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_READ - CRC_SIZE);
|
||||
|
||||
/* Add crc to packet data field of space packet */
|
||||
serializedSize = 0;
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize,
|
||||
sizeof(crc), SerializeIF::Endianness::BIG);
|
||||
memcpy(this->localData.fields.buffer + CRC_OFFSET, &crc, sizeof(crc));
|
||||
}
|
||||
|
||||
static const uint8_t OFFSET_MEM_LEN_FIELD = 4;
|
||||
@ -117,9 +116,10 @@ namespace PLOC {
|
||||
*
|
||||
* @param memAddr The PLOC memory address where to write to.
|
||||
* @param memoryData The data to write to the specified memory address.
|
||||
* @param sequenceCount The subsequence count. Must be incremented with each new packet.
|
||||
*/
|
||||
TcMemWrite(const uint32_t memAddr, const uint32_t memoryData) :
|
||||
SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE) {
|
||||
TcMemWrite(const uint32_t memAddr, const uint32_t memoryData, uint16_t sequenceCount) :
|
||||
SpacePacket(LENGTH_TC_MEM_WRITE - 1, true, APID_TC_MEM_WRITE, sequenceCount) {
|
||||
fillPacketDataField(&memAddr, &memoryData);
|
||||
}
|
||||
|
||||
@ -140,8 +140,8 @@ namespace PLOC {
|
||||
sizeof(*memAddrPtr), SerializeIF::Endianness::BIG);
|
||||
|
||||
/* 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;
|
||||
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD] = 1;
|
||||
this->localData.fields.buffer[OFFSET_MEM_LEN_FIELD + 1] = 0;
|
||||
|
||||
/* Add memData to packet data field */
|
||||
serializedSize = 0;
|
||||
@ -151,14 +151,13 @@ namespace PLOC {
|
||||
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
|
||||
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE, 0);
|
||||
sizeof(CCSDSPrimaryHeader) + LENGTH_TC_MEM_WRITE - CRC_SIZE);
|
||||
|
||||
serializedSize = 0;
|
||||
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
|
||||
/* Add crc to packet data field of space packet */
|
||||
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize,
|
||||
sizeof(crc), SerializeIF::Endianness::BIG);
|
||||
memcpy(this->localData.fields.buffer + CRC_OFFSET, &crc, sizeof(crc));
|
||||
}
|
||||
|
||||
/** Offsets from base address of packet data field */
|
||||
|
Reference in New Issue
Block a user