TMTC Packet Base improvements #80

Merged
gaisser merged 20 commits from KSat/fsfw:mueller_tcPacketBase into master 2020-10-29 13:17:36 +01:00
2 changed files with 12 additions and 10 deletions
Showing only changes of commit 331b36fe18 - Show all commits

View File

@ -51,11 +51,10 @@ void TcPacketBase::setData(const uint8_t* pData) {
tcData = (TcPacketPointer*) pData;
}
void TcPacketBase::setApplicationData(const uint8_t * pData, uint16_t dataLen) {
setData(pData);
// packet data length is actual size of data field minus 1
void TcPacketBase::setAppData(uint8_t * appData, uint16_t dataLen) {

The getter is called "getApplicationData", we should keep the names the same.

The getter is called "getApplicationData", we should keep the names the same.
memcpy(&tcData->appData, appData, dataLen);

As tcData->appData is only a "fake" pointer of which we are not able to check the length, this operation is dangerous and there is no warning about it. TcPacketStored is the way the user does not have to thing about that. The whole class is only intended as Parsing Helper for a existing Packet or it is hidden behind a safe operation as in TcPacketStored.

I'm not sure if we should allow setting of anything here after the constructor.
Even the setData function is interessting maybe we could make that protected as its only used in TcPacketStored.

As tcData->appData is only a "fake" pointer of which we are not able to check the length, this operation is dangerous and there is no warning about it. TcPacketStored is the way the user does not have to thing about that. The whole class is only intended as Parsing Helper for a existing Packet or it is hidden behind a safe operation as in TcPacketStored. I'm not sure if we should allow setting of anything here after the constructor. Even the setData function is interessting maybe we could make that protected as its only used in TcPacketStored.
SpacePacketBase::setPacketDataLength(dataLen +
sizeof(PUSTcDataFieldHeader) + TcPacketBase::CRC_SIZE - 1);
sizeof(PUSTcDataFieldHeader) + TcPacketBase::CRC_SIZE - 1);
}
uint8_t TcPacketBase::getSecondaryHeaderFlag() {

View File

@ -168,6 +168,14 @@ public:
* current content of the packet.
*/
void setErrorControl();
/**
* Copies the supplied data to the internal TC application data field.
* @param pData
* @param dataLen
*/
void setAppData(uint8_t * appData, uint16_t dataLen);
/**
* With this method, the packet data pointer can be redirected to another
* location.
@ -178,12 +186,7 @@ public:
* @param p_data A pointer to another PUS Telecommand Packet.
*/
void setData( const uint8_t* pData );
/**
* Set application data and corresponding length field.
* @param pData
* @param dataLen
*/
void setApplicationData(const uint8_t * pData, uint16_t dataLen);
/**
* This is a debugging helper method that prints the whole packet content
* to the screen.