1
0
forked from fsfw/fsfw

WIP compiler Flags and new unit tests for fixes

This commit is contained in:
2022-02-23 18:23:22 +01:00
parent 457bc6609e
commit f6357b4531
16 changed files with 171 additions and 117 deletions

View File

@ -6,6 +6,7 @@
#include <fsfw/cfdp/tlv/Tlv.h>
#include <fsfw/cfdp/tlv/TlvIF.h>
#include <fsfw/serialize/SerializeIF.h>
#include <FSFWConfig.h>
#include <cstddef>
#include <cstdint>

View File

@ -28,7 +28,7 @@ const uint16_t CRC::crc16ccitt_table[256] = {
// CRC implementation
uint16_t CRC::crc16ccitt(uint8_t const input[], uint32_t length, uint16_t startingCrc) {
uint8_t *data = (uint8_t *)input;
const uint8_t *data = static_cast<const uint8_t *>(input);
unsigned int tbl_idx;
while (length--) {
@ -39,88 +39,4 @@ uint16_t CRC::crc16ccitt(uint8_t const input[], uint32_t length, uint16_t starti
}
return startingCrc & 0xffff;
// The part below is not used!
// bool temr[16];
// bool xor_out[16];
// bool r[16];
// bool d[8];
// uint16_t crc_value = 0;
//
//
// for (int i=0; i<16 ;i++) {
// temr[i] = false;
// xor_out[i] = false;
// }
//
//
// for (int i=0; i<16 ;i++)
// r[i] = true; // initialize with 0xFFFF
//
//
//
// for (int j=0; j<length ;j++)
// {
//
// for (int i=0; i<8 ;i++)
// if ((input[j] & 1<<i) == 1<<i)
// d[7-i]=true; // reverse input data
// else
// d[7-i]=false; // reverse input data
//
//
//
// temr[0] = d[4] ^ d[0];
// temr[1] = d[5] ^ d[1];
// temr[2] = d[6] ^ d[2];
// temr[3] = d[7] ^ d[3];
// temr[4] = r[12] ^ r[8];
// temr[5] = r[13] ^ r[9];
// temr[6] = r[14] ^ r[10];
// temr[7] = r[15] ^ r[11];
// temr[8] = d[4] ^ r[12];
// temr[9] = d[5] ^ r[13];
// temr[10] = d[6] ^ r[14];
// temr[11] = d[7] ^ r[15];
// temr[12] = temr[0] ^ temr[4];
// temr[13] = temr[1] ^ temr[5];
// temr[14] = temr[2] ^ temr[6];
// temr[15] = temr[3] ^ temr[7];
//
//
// xor_out[0] = temr[12];
// xor_out[1] = temr[13];
// xor_out[2] = temr[14];
// xor_out[3] = temr[15];
// xor_out[4] = temr[8];
// xor_out[5] = temr[9] ^ temr[12];
// xor_out[6] = temr[10] ^ temr[13];
// xor_out[7] = temr[11] ^ temr[14];
// xor_out[8] = temr[15] ^ r[0];
// xor_out[9] = temr[8] ^ r[1];
// xor_out[10] = temr[9] ^ r[2];
// xor_out[11] = temr[10] ^ r[3];
// xor_out[12] = temr[11] ^ temr[12] ^ r[4];
// xor_out[13] = temr[13] ^ r[5];
// xor_out[14] = temr[14] ^ r[6];
// xor_out[15] = temr[15] ^ r[7];
//
// for (int i=0; i<16 ;i++)
// {
// r[i]= xor_out[i] ;
// }
//
// }
//
//
//
// for (int i=0; i<16 ;i++)
// {
// if (xor_out[i] == true)
// crc_value = crc_value + pow(2,(15 -i)); // reverse CrC result before
// Final XOR
// }
//
// crc_value = 0;// for debug mode
// return (crc_value);
} /* Calculate_CRC() */

View File

@ -9,6 +9,8 @@
#include "fsfw/serviceinterface/ServiceInterfacePrinter.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include <stdio.h>
BinarySemaphore::BinarySemaphore() {
// Using unnamed semaphores for now
initSemaphore();

View File

@ -169,8 +169,8 @@ class RMAP : public HasReturnvaluesIF {
* @param buffer the data to write
* @param length length of data
* @return
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL
* in write command
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was ==
* NULL in write command
* - return codes of RMAPChannelIF::sendCommand()
*/
static ReturnValue_t sendWriteCommand(RMAPCookie *cookie, const uint8_t *buffer, size_t length);
@ -205,8 +205,8 @@ class RMAP : public HasReturnvaluesIF {
* @param cookie to cookie to read from
* @param expLength the expected maximum length of the reply
* @return
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was == NULL
* in write command, or nullpointer in read command
* - @c COMMAND_NULLPOINTER datalen was != 0 but data was ==
* NULL in write command, or nullpointer in read command
* - return codes of RMAPChannelIF::sendCommand()
*/
static ReturnValue_t sendReadCommand(RMAPCookie *cookie, uint32_t expLength);

View File

@ -75,11 +75,11 @@ class RMAPChannelIF {
* - @c RETURN_OK
* - @c COMMAND_NO_DESCRIPTORS_AVAILABLE no descriptors available for sending
* command; command was not sent
* - @c COMMAND_BUFFER_FULL no receiver buffer available for expected
* len; command was not sent
* - @c COMMAND_TOO_BIG the data that was to be sent was too long for the
* hw to handle (write command) or the expected len was bigger than maximal expected len (read
* command) command was not sent
* - @c COMMAND_BUFFER_FULL no receiver buffer available for
* expected len; command was not sent
* - @c COMMAND_TOO_BIG the data that was to be sent was too long
* for the hw to handle (write command) or the expected len was bigger than maximal expected len
* (read command) command was not sent
* - @c COMMAND_CHANNEL_DEACTIVATED the channel has no port set
* - @c NOT_SUPPORTED if you dont feel like
* implementing something...
@ -97,8 +97,8 @@ class RMAPChannelIF {
* - @c REPLY_NO_REPLY no reply was received
* - @c REPLY_NOT_SENT command was not sent, implies no reply
* - @c REPLY_NOT_YET_SENT command is still waiting to be sent
* - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission buffer
* still being processed)
* - @c WRITE_REPLY_INTERFACE_BUSY Interface is busy (transmission
* buffer still being processed)
* - @c WRITE_REPLY_TRANSMISSION_ERROR Interface encountered errors during last
* operation, data could not be processed. (transmission error)
* - @c WRITE_REPLY_INVALID_DATA Invalid data (amount / value)

View File

@ -1,6 +1,8 @@
#ifndef FSFW_SERVICEINTERFACE_SERVICEINTERFACEPRINTER
#define FSFW_SERVICEINTERFACE_SERVICEINTERFACEPRINTER
#include <FSFWConfig.h>
#if FSFW_DISABLE_PRINTOUT == 0
#include <cstdio>
#endif

View File

@ -2,6 +2,8 @@
#include <cstring>
#include <FSFWConfig.h>
#include "fsfw/FSFW.h"
#include "fsfw/objectmanager/ObjectManager.h"
@ -110,7 +112,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr
}
ReturnValue_t LocalPool::deleteData(store_address_t storeId) {
#if FSFW_VERBOSE_PRINTOUT == 2
#if FSFW_VERBOSE_LEVEL >= 2
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Delete: Pool: " << std::dec << storeId.poolIndex
<< " Index: " << storeId.packetIndex << std::endl;
@ -148,7 +150,7 @@ ReturnValue_t LocalPool::deleteData(uint8_t* ptr, size_t size, store_address_t*
// element of an object.
localId.packetIndex = deltaAddress / elementSizes[n];
result = deleteData(localId);
#if FSFW_VERBOSE_PRINTOUT == 2
#if FSFW_VERBOSE_LEVEL >= 2
if (deltaAddress % elementSizes[n] != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPool::deleteData: Address not aligned!" << std::endl;
@ -219,7 +221,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI
status = findEmpty(storeId->poolIndex, &storeId->packetIndex);
}
if (status == RETURN_OK) {
#if FSFW_VERBOSE_PRINTOUT == 2
#if FSFW_VERBOSE_LEVEL >= 2
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Reserve: Pool: " << std::dec << storeId->poolIndex
<< " Index: " << storeId->packetIndex << std::endl;
@ -257,7 +259,7 @@ void LocalPool::setToSpillToHigherPools(bool enable) { this->spillsToHigherPools
ReturnValue_t LocalPool::getSubPoolIndex(size_t packetSize, uint16_t* subpoolIndex,
uint16_t startAtIndex) {
for (uint16_t n = startAtIndex; n < NUMBER_OF_SUBPOOLS; n++) {
#if FSFW_VERBOSE_PRINTOUT == 2
#if FSFW_VERBOSE_LEVEL >= 2
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalPool " << getObjectId() << "::getPoolIndex: Pool: " << n
<< ", Element Size: " << elementSizes[n] << std::endl;

View File

@ -17,7 +17,7 @@ ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* addr
}
ReturnValue_t PoolManager::deleteData(store_address_t storeId) {
#if FSFW_VERBOSE_PRINTOUT == 2
#if FSFW_VERBOSE_LEVEL >= 2
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store "
<< storeId.poolIndex << ". id is " << storeId.packetIndex << std::endl;

View File

@ -109,8 +109,8 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f
if (result != RETURN_OK) {
return result;
}
Ccs_mseconds* temp = (Ccs_mseconds*)from;
// At this point we made sure that this is a valid ccs time
const Ccs_mseconds* temp = reinterpret_cast<const Ccs_mseconds*>(from);
to->year = (temp->yearMSB << 8) + temp->yearLSB;
to->hour = temp->hour;
@ -118,16 +118,19 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f
to->second = temp->second;
if (temp->pField & (1 << 3)) { // day of year variation
uint16_t tempDay = (temp->month << 8) + temp->day;
result = convertDaysOfYear(tempDay, to->year, &(temp->month), &(temp->day));
uint16_t tempDayOfYear = (temp->month << 8) + temp->day;
uint8_t tempDay = 0;
uint8_t tempMonth = 0;
result = convertDaysOfYear(tempDayOfYear, to->year, &tempMonth, &tempDay);
if (result != RETURN_OK) {
return result;
}
to->month = tempMonth;
to->day = tempDay;
}else{
to->month = temp->month;
to->day = temp->day;
}
to->month = temp->month;
to->day = temp->day;
to->usecond = 0;
if (subsecondsLength > 0) {
*foundLength += 1;
@ -162,7 +165,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
uint16_t hour;
uint16_t minute;
float second;
int count = sscanf((char*)from,
int count = sscanf((const char*)from,
"%4" SCNu16 "-%2" SCNu16 "-%2" SCNu16
"T%"
"2" SCNu16 ":%2" SCNu16 ":%fZ",
@ -179,7 +182,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
}
// try Code B (yyyy-ddd)
count = sscanf((char*)from,
count = sscanf((const char*)from,
"%4" SCNu16 "-%3" SCNu16 "T%2" SCNu16
":%"
"2" SCNu16 ":%fZ",
@ -211,7 +214,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
float second;
// try Code A (yyyy-mm-dd)
int count =
sscanf((char*)from, "%4" SCNu16 "-%2" SCNu8 "-%2" SCNu16 "T%2" SCNu8 ":%2" SCNu8 ":%fZ",
sscanf((const char*)from, "%4" SCNu16 "-%2" SCNu8 "-%2" SCNu16 "T%2" SCNu8 ":%2" SCNu8 ":%fZ",
&year, &month, &day, &hour, &minute, &second);
if (count == 6) {
to->year = year;
@ -225,7 +228,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
}
// try Code B (yyyy-ddd)
count = sscanf((char*)from, "%4" SCNu16 "-%3" SCNu16 "T%2" SCNu8 ":%2" SCNu8 ":%fZ", &year, &day,
count = sscanf((const char*)from, "%4" SCNu16 "-%3" SCNu16 "T%2" SCNu8 ":%2" SCNu8 ":%fZ", &year, &day,
&hour, &minute, &second);
if (count == 5) {
uint8_t tempDay;
@ -248,7 +251,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
}
ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) {
Ccs_mseconds* time_struct = (Ccs_mseconds*)time;
const Ccs_mseconds* time_struct = reinterpret_cast<const Ccs_mseconds*>(time);
uint8_t additionalBytes = time_struct->pField & 0b111;
if ((additionalBytes == 0b111) || (length < (additionalBytes + 8))) {
@ -278,7 +281,7 @@ ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) {
return INVALID_TIME_FORMAT;
}
uint8_t* additionalByte = &time_struct->secondEminus2;
const uint8_t* additionalByte = &time_struct->secondEminus2;
for (; additionalBytes != 0; additionalBytes--) {
if (*additionalByte++ > 99) {