Merge branch 'develop' into eive/develop
This commit is contained in:
@ -16,18 +16,38 @@
|
||||
#cmakedefine FSFW_ADD_MONITORING
|
||||
#cmakedefine FSFW_ADD_SGP4_PROPAGATOR
|
||||
|
||||
// FSFW core defines
|
||||
|
||||
#ifndef FSFW_TCP_RECV_WIRETAPPING_ENABLED
|
||||
#define FSFW_TCP_RECV_WIRETAPPING_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef FSFW_CPP_OSTREAM_ENABLED
|
||||
#define FSFW_CPP_OSTREAM_ENABLED 1
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED */
|
||||
|
||||
#ifndef FSFW_VERBOSE_LEVEL
|
||||
#define FSFW_VERBOSE_LEVEL 1
|
||||
#endif /* FSFW_VERBOSE_LEVEL */
|
||||
|
||||
#ifndef FSFW_USE_REALTIME_FOR_LINUX
|
||||
#define FSFW_USE_REALTIME_FOR_LINUX 0
|
||||
#endif /* FSFW_USE_REALTIME_FOR_LINUX */
|
||||
|
||||
#ifndef FSFW_NO_C99_IO
|
||||
#define FSFW_NO_C99_IO 0
|
||||
#endif /* FSFW_NO_C99_IO */
|
||||
|
||||
#ifndef FSFW_USE_PUS_C_TELEMETRY
|
||||
#define FSFW_USE_PUS_C_TELEMETRY 1
|
||||
#endif
|
||||
#endif /* FSFW_USE_PUS_C_TELEMETRY */
|
||||
|
||||
#ifndef FSFW_USE_PUS_C_TELECOMMANDS
|
||||
#define FSFW_USE_PUS_C_TELECOMMANDS 1
|
||||
#endif
|
||||
|
||||
// FSFW HAL defines
|
||||
|
||||
// Can be used for low-level debugging of the SPI bus
|
||||
#ifndef FSFW_HAL_SPI_WIRETAPPING
|
||||
#define FSFW_HAL_SPI_WIRETAPPING 0
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
const char* const FSFW_VERSION_NAME = "ASTP";
|
||||
|
||||
#define FSFW_VERSION 1
|
||||
#define FSFW_SUBVERSION 2
|
||||
#define FSFW_VERSION 2
|
||||
#define FSFW_SUBVERSION 0
|
||||
#define FSFW_REVISION 0
|
||||
|
||||
#endif /* FSFW_VERSION_H_ */
|
||||
|
@ -165,11 +165,9 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_
|
||||
if (sourceStream[encodedIndex++] != STX_CHAR) {
|
||||
return DECODING_ERROR;
|
||||
}
|
||||
while ((encodedIndex < sourceStreamLen)
|
||||
and (decodedIndex < maxDestStreamlen)
|
||||
and (sourceStream[encodedIndex] != ETX_CHAR)
|
||||
and (sourceStream[encodedIndex] != STX_CHAR)) {
|
||||
if (sourceStream[encodedIndex] == DLE_CHAR) {
|
||||
while ((encodedIndex < sourceStreamLen) and (decodedIndex < maxDestStreamlen)) {
|
||||
switch(sourceStream[encodedIndex]) {
|
||||
case(DLE_CHAR): {
|
||||
if(encodedIndex + 1 >= sourceStreamLen) {
|
||||
//reached the end of the sourceStream
|
||||
*readLen = sourceStreamLen;
|
||||
@ -197,29 +195,33 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_
|
||||
}
|
||||
}
|
||||
++encodedIndex;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
case(STX_CHAR): {
|
||||
*readLen = encodedIndex;
|
||||
return DECODING_ERROR;
|
||||
}
|
||||
case(ETX_CHAR): {
|
||||
*readLen = ++encodedIndex;
|
||||
*decodedLen = decodedIndex;
|
||||
return RETURN_OK;
|
||||
}
|
||||
default: {
|
||||
destStream[decodedIndex] = sourceStream[encodedIndex];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
++encodedIndex;
|
||||
++decodedIndex;
|
||||
}
|
||||
if (sourceStream[encodedIndex] != ETX_CHAR) {
|
||||
if(decodedIndex == maxDestStreamlen) {
|
||||
//so far we did not find anything wrong here, so let user try again
|
||||
*readLen = 0;
|
||||
return STREAM_TOO_SHORT;
|
||||
}
|
||||
else {
|
||||
*readLen = ++encodedIndex;
|
||||
return DECODING_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*readLen = ++encodedIndex;
|
||||
*decodedLen = decodedIndex;
|
||||
return RETURN_OK;
|
||||
|
||||
if(decodedIndex == maxDestStreamlen) {
|
||||
//so far we did not find anything wrong here, so let user try again
|
||||
*readLen = 0;
|
||||
return STREAM_TOO_SHORT;
|
||||
} else {
|
||||
*readLen = encodedIndex;
|
||||
return DECODING_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ target_sources(${LIB_FSFW_NAME}
|
||||
QueueFactory.cpp
|
||||
SemaphoreFactory.cpp
|
||||
TaskFactory.cpp
|
||||
Timer.cpp
|
||||
tcpipHelpers.cpp
|
||||
unixUtility.cpp
|
||||
CommandExecutor.cpp
|
||||
|
@ -6,16 +6,14 @@ Countdown::Countdown(uint32_t initialTimeout): timeout(initialTimeout) {
|
||||
Countdown::~Countdown() {
|
||||
}
|
||||
|
||||
ReturnValue_t Countdown::setTimeout(uint32_t miliseconds) {
|
||||
ReturnValue_t return_value = Clock::getUptime( &startTime );
|
||||
timeout = miliseconds;
|
||||
return return_value;
|
||||
ReturnValue_t Countdown::setTimeout(uint32_t milliseconds) {
|
||||
ReturnValue_t returnValue = Clock::getUptime( &startTime );
|
||||
timeout = milliseconds;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
bool Countdown::hasTimedOut() const {
|
||||
uint32_t current_time;
|
||||
Clock::getUptime( ¤t_time );
|
||||
if ( uint32_t(current_time - startTime) >= timeout) {
|
||||
if ( uint32_t( this->getCurrentTime() - startTime) >= timeout) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -31,7 +29,23 @@ ReturnValue_t Countdown::resetTimer() {
|
||||
}
|
||||
|
||||
void Countdown::timeOut() {
|
||||
uint32_t current_time;
|
||||
Clock::getUptime( ¤t_time );
|
||||
startTime= current_time - timeout;
|
||||
startTime = this->getCurrentTime() - timeout;
|
||||
}
|
||||
|
||||
uint32_t Countdown::getRemainingMillis() const {
|
||||
// We fetch the time before the if-statement
|
||||
// to be sure that the return is in
|
||||
// range 0 <= number <= timeout
|
||||
uint32_t currentTime = this->getCurrentTime();
|
||||
if (this->hasTimedOut()){
|
||||
return 0;
|
||||
}else{
|
||||
return (startTime + timeout) - currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Countdown::getCurrentTime() const {
|
||||
uint32_t currentTime;
|
||||
Clock::getUptime( ¤tTime );
|
||||
return currentTime;
|
||||
}
|
||||
|
@ -4,28 +4,77 @@
|
||||
#include "Clock.h"
|
||||
|
||||
/**
|
||||
* @brief This file defines the Countdown class.
|
||||
* @author baetz
|
||||
*
|
||||
* Countdown keeps track of a timespan.
|
||||
*
|
||||
* Countdown::resetTimer restarts the timer.
|
||||
* Countdown::setTimeout sets a new countdown duration and resets.
|
||||
*
|
||||
* Can be checked with Countdown::hasTimedOut or
|
||||
* Countdown::isBusy.
|
||||
*
|
||||
* Countdown::timeOut will force the timer to time out.
|
||||
*
|
||||
*/
|
||||
class Countdown {
|
||||
public:
|
||||
uint32_t timeout;
|
||||
/**
|
||||
* Constructor which sets the countdown duration in milliseconds
|
||||
*
|
||||
* It does not start the countdown!
|
||||
* Call resetTimer or setTimeout before usage!
|
||||
* Otherwise a call to hasTimedOut might return True.
|
||||
*
|
||||
* @param initialTimeout Countdown duration in milliseconds
|
||||
*/
|
||||
Countdown(uint32_t initialTimeout = 0);
|
||||
~Countdown();
|
||||
ReturnValue_t setTimeout(uint32_t miliseconds);
|
||||
|
||||
/**
|
||||
* Call to set a new countdown duration.
|
||||
*
|
||||
* Resets the countdown!
|
||||
*
|
||||
* @param milliseconds new countdown duration in milliseconds
|
||||
* @return Returnvalue from Clock::getUptime
|
||||
*/
|
||||
ReturnValue_t setTimeout(uint32_t milliseconds);
|
||||
/**
|
||||
* Returns true if the countdown duration has passed.
|
||||
*
|
||||
* @return True if the countdown has passed
|
||||
* False if it is still running
|
||||
*/
|
||||
bool hasTimedOut() const;
|
||||
|
||||
/**
|
||||
* Complementary to hasTimedOut.
|
||||
*
|
||||
* @return True if the countdown is till running
|
||||
* False if it is still running
|
||||
*/
|
||||
bool isBusy() const;
|
||||
|
||||
//!< Use last set timeout value and restart timer.
|
||||
/**
|
||||
* Uses last set timeout value and restarts timer.
|
||||
*/
|
||||
ReturnValue_t resetTimer();
|
||||
|
||||
//!< Make hasTimedOut() return true
|
||||
/**
|
||||
* Returns the remaining milliseconds (0 if timeout)
|
||||
*/
|
||||
uint32_t getRemainingMillis() const;
|
||||
/**
|
||||
* Makes hasTimedOut() return true
|
||||
*/
|
||||
void timeOut();
|
||||
|
||||
/**
|
||||
* Internal countdown duration in milliseconds
|
||||
*/
|
||||
uint32_t timeout;
|
||||
private:
|
||||
/**
|
||||
* Last time the timer was started (uptime)
|
||||
*/
|
||||
uint32_t startTime = 0;
|
||||
|
||||
uint32_t getCurrentTime() const;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TIMEMANAGER_COUNTDOWN_H_ */
|
||||
|
@ -26,12 +26,11 @@ public:
|
||||
* @param sequenceCount ets the packet's Source Sequence Count field.
|
||||
*/
|
||||
SpacePacket(uint16_t packetDataLength, bool isTelecommand = false,
|
||||
uint16_t apid = APID_IDLE_PACKET, uint16_t sequenceCount = 0);
|
||||
uint16_t apid = APID_IDLE_PACKET, uint16_t sequenceCount = 0);
|
||||
/**
|
||||
* The class's default destructor.
|
||||
*/
|
||||
virtual ~SpacePacket();
|
||||
|
||||
/**
|
||||
* With this call, the complete data content (including the CCSDS Primary
|
||||
* Header) is overwritten with the byte stream given.
|
||||
@ -41,6 +40,7 @@ public:
|
||||
* @li \c false else.
|
||||
*/
|
||||
bool addWholeData(const uint8_t* p_data, uint32_t packet_size);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This structure defines the data structure of a Space Packet as local data.
|
||||
|
@ -30,8 +30,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,
|
||||
|
Reference in New Issue
Block a user