Merge pull request 'Using correct version number now for PUS C' (#502) from eive/fsfw:mueller/fix-for-pus-c-version-number-cherry-picked into master

Reviewed-on: fsfw/fsfw#502
Reviewed-by: Ulrich Mohr <mohr@irs.uni-stuttgart.de>
This commit is contained in:
Ulrich Mohr 2021-10-11 17:51:58 +02:00
commit 52f0c29e99
9 changed files with 41 additions and 25 deletions

View File

@ -0,0 +1,16 @@
#ifndef FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_
#define FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_
#include <cstdint>
namespace pus {
//! Version numbers according to ECSS-E-ST-70-41C p.439
enum PusVersion: uint8_t {
PUS_A_VERSION = 1,
PUS_C_VERSION = 2
};
}
#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ */

View File

@ -1,4 +1,4 @@
#include "fsfw/tmtcpacket/pus/tc/TcPacketPus.h"
#include "TcPacketPus.h"
#include "fsfw/globalfunctions/CRC.h"
#include <cstring>
@ -8,14 +8,13 @@ TcPacketPus::TcPacketPus(const uint8_t *setData): TcPacketBase(setData) {
}
void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount,
uint8_t ack, uint8_t service, uint8_t subservice, uint16_t sourceId) {
uint8_t ack, uint8_t service, uint8_t subservice, pus::PusVersion pusVersion,
uint16_t sourceId) {
initSpacePacketHeader(true, true, apid, sequenceCount);
std::memset(&tcData->dataField, 0, sizeof(tcData->dataField));
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
// Data Field Header:
// Set CCSDS_secondary_header_flag to 0 and version number to 001
tcData->dataField.versionTypeAck = 0b00010000;
tcData->dataField.versionTypeAck |= (ack & 0x0F);
// Data Field Header. For PUS A, the first bit (CCSDS Secondary Header Flag) is zero
tcData->dataField.versionTypeAck = pusVersion << 4 | (ack & 0x0F);
tcData->dataField.serviceType = service;
tcData->dataField.serviceSubtype = subservice;
#if FSFW_USE_PUS_C_TELECOMMANDS == 1

View File

@ -2,6 +2,7 @@
#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
#include "fsfw/FSFW.h"
#include "../definitions.h"
#include "fsfw/tmtcpacket/ccsds_header.h"
#include "TcPacketBase.h"
@ -75,7 +76,8 @@ protected:
* @param subservice PUS Subservice
*/
void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
uint8_t service, uint8_t subservice, uint16_t sourceId = 0);
uint8_t service, uint8_t subservice, pus::PusVersion pusVersion,
uint16_t sourceId = 0);
/**
* A pointer to a structure which defines the data structure of

View File

@ -23,7 +23,12 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service,
return;
}
this->setData(pData);
initializeTcPacket(apid, sequenceCount, ack, service, subservice);
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION;
#else
pus::PusVersion pusVersion = pus::PusVersion::PUS_A_VERSION;
#endif
initializeTcPacket(apid, sequenceCount, ack, service, subservice, pusVersion);
std::memcpy(&tcData->appData, data, size);
this->setPacketDataLength(
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);

View File

@ -31,8 +31,6 @@ public:
//! Maximum size of a TM Packet in this mission.
//! TODO: Make this dependant on a config variable.
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
//! First four bits of first byte of secondary header
static const uint8_t VERSION_NUMBER_BYTE = 0b00010000;
/**
* This is the default constructor.

View File

@ -1,5 +1,6 @@
#include "fsfw/tmtcpacket/pus/tm/TmPacketPusA.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketBase.h"
#include "../definitions.h"
#include "TmPacketPusA.h"
#include "TmPacketBase.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/globalfunctions/arrayprinter.h"
@ -62,12 +63,7 @@ void TmPacketPusA::initializeTmPacket(uint16_t apid, uint8_t service,
//First, set to zero.
memset(&tmData->data_field, 0, sizeof(tmData->data_field));
// NOTE: In PUS-C, the PUS Version is 2 and specified for the first 4 bits.
// The other 4 bits of the first byte are the spacecraft time reference
// status. To change to PUS-C, set 0b00100000.
// Set CCSDS_secondary header flag to 0, version number to 001 and ack
// to 0000
tmData->data_field.version_type_ack = 0b00010000;
tmData->data_field.version_type_ack = pus::PusVersion::PUS_A_VERSION << 4;
tmData->data_field.service_type = service;
tmData->data_field.service_subtype = subservice;
tmData->data_field.subcounter = packetSubcounter;

View File

@ -1,5 +1,6 @@
#include "fsfw/tmtcpacket/pus/tm/TmPacketPusC.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketBase.h"
#include "../definitions.h"
#include "TmPacketPusC.h"
#include "TmPacketBase.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/globalfunctions/arrayprinter.h"
@ -64,7 +65,8 @@ void TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service,
/* Only account for last 4 bytes for time reference field */
timeRefField &= 0b1111;
tmData->dataField.versionTimeReferenceField = VERSION_NUMBER_BYTE | timeRefField;
tmData->dataField.versionTimeReferenceField =
(pus::PusVersion::PUS_C_VERSION << 4) | timeRefField;
tmData->dataField.serviceType = service;
tmData->dataField.serviceSubtype = subservice;
tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff;

View File

@ -29,8 +29,7 @@ TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,
initializeTmPacket(apid, service, subservice, packetSubcounter);
memcpy(getSourceData(), headerData, headerSize);
memcpy(getSourceData() + headerSize, data, size);
setPacketDataLength(
size + headerSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
setPacketDataLength(size + headerSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1);
}
TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service,

View File

@ -30,8 +30,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
memcpy(getSourceData(), headerData, headerSize);
memcpy(getSourceData() + headerSize, data, size);
setPacketDataLength(
size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
setPacketDataLength(size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
}
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service,