some renamings

This commit is contained in:
Robin Müller 2020-05-19 18:55:13 +02:00
parent 7bc7e06277
commit 483a47d353
3 changed files with 18 additions and 18 deletions

View File

@ -13,28 +13,28 @@ TcPacketBase::~TcPacketBase() {
}
uint8_t TcPacketBase::getService() {
return tcData->data_field.service_type;
return tcData->dataField.service_type;
}
uint8_t TcPacketBase::getSubService() {
return tcData->data_field.service_subtype;
return tcData->dataField.service_subtype;
}
uint8_t TcPacketBase::getAcknowledgeFlags() {
return tcData->data_field.version_type_ack & 0b00001111;
return tcData->dataField.version_type_ack & 0b00001111;
}
const uint8_t* TcPacketBase::getApplicationData() const {
return &tcData->data;
return &tcData->appData;
}
uint16_t TcPacketBase::getApplicationDataSize() {
return getPacketDataLength() - sizeof(tcData->data_field) - CRC_SIZE + 1;
return getPacketDataLength() - sizeof(tcData->dataField) - CRC_SIZE + 1;
}
uint16_t TcPacketBase::getErrorControl() {
uint16_t size = getApplicationDataSize() + CRC_SIZE;
uint8_t* p_to_buffer = &tcData->data;
uint8_t* p_to_buffer = &tcData->appData;
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
}
@ -42,8 +42,8 @@ void TcPacketBase::setErrorControl() {
uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
uint32_t size = getApplicationDataSize();
(&tcData->data)[size] = (crc & 0XFF00) >> 8; // CRCH
(&tcData->data)[size + 1] = (crc) & 0X00FF; // CRCL
(&tcData->appData)[size] = (crc & 0XFF00) >> 8; // CRCH
(&tcData->appData)[size + 1] = (crc) & 0X00FF; // CRCL
}
void TcPacketBase::setData(const uint8_t* pData) {
@ -59,11 +59,11 @@ void TcPacketBase::setApplicationData(const uint8_t * pData, uint16_t dataLen) {
}
uint8_t TcPacketBase::getSecondaryHeaderFlag() {
return (tcData->data_field.version_type_ack & 0b10000000) >> 7;
return (tcData->dataField.version_type_ack & 0b10000000) >> 7;
}
uint8_t TcPacketBase::getPusVersionNumber() {
return (tcData->data_field.version_type_ack & 0b01110000) >> 4;
return (tcData->dataField.version_type_ack & 0b01110000) >> 4;
}
void TcPacketBase::print() {
@ -78,14 +78,14 @@ void TcPacketBase::print() {
void TcPacketBase::initializeTcPacket(uint16_t apid, uint16_t sequenceCount,
uint8_t ack, uint8_t service, uint8_t subservice) {
initSpacePacketHeader(true, true, apid, sequenceCount);
memset(&tcData->data_field, 0, sizeof(tcData->data_field));
memset(&tcData->dataField, 0, sizeof(tcData->dataField));
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
//Data Field Header:
//Set CCSDS_secondary_header_flag to 0, version number to 001 and ack to 0000
tcData->data_field.version_type_ack = 0b00010000;
tcData->data_field.version_type_ack |= (ack & 0x0F);
tcData->data_field.service_type = service;
tcData->data_field.service_subtype = subservice;
tcData->dataField.version_type_ack = 0b00010000;
tcData->dataField.version_type_ack |= (ack & 0x0F);
tcData->dataField.service_type = service;
tcData->dataField.service_subtype = subservice;
}
size_t TcPacketBase::calculateFullPacketLength(size_t appDataLen) {

View File

@ -24,8 +24,8 @@ struct PUSTcDataFieldHeader {
*/
struct TcPacketPointer {
CCSDSPrimaryHeader primary;
PUSTcDataFieldHeader data_field;
uint8_t data;
PUSTcDataFieldHeader dataField;
uint8_t appData;
};
/**

View File

@ -24,7 +24,7 @@ TcPacketStored::TcPacketStored(uint8_t service, uint8_t subservice,
}
this->setData(p_data);
initializeTcPacket(apid, sequence_count, ack, service, subservice);
memcpy(&tcData->data, data, size);
memcpy(&tcData->appData, data, size);
this->setPacketDataLength(
size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
this->setErrorControl();