Merge pull request 'PUS Service 9' (#198) from KSat/fsfw:mueller/pusSrv9 into master
Reviewed-on: fsfw/fsfw#198
This commit is contained in:
commit
9aaa5721af
58
pus/Service9TimeManagement.cpp
Normal file
58
pus/Service9TimeManagement.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include "Service9TimeManagement.h"
|
||||||
|
#include "servicepackets/Service9Packets.h"
|
||||||
|
|
||||||
|
#include "../timemanager/CCSDSTime.h"
|
||||||
|
#include "../events/EventManagerIF.h"
|
||||||
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
|
|
||||||
|
Service9TimeManagement::Service9TimeManagement(object_id_t objectId,
|
||||||
|
uint16_t apid, uint8_t serviceId) :
|
||||||
|
PusServiceBase(objectId, apid , serviceId) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Service9TimeManagement::~Service9TimeManagement() {}
|
||||||
|
|
||||||
|
ReturnValue_t Service9TimeManagement::performService() {
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
||||||
|
switch(subservice){
|
||||||
|
case SUBSERVICE::SET_TIME:{
|
||||||
|
return setTime();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t Service9TimeManagement::setTime() {
|
||||||
|
Clock::TimeOfDay_t timeToSet;
|
||||||
|
TimePacket timePacket(currentPacket.getApplicationData(),
|
||||||
|
currentPacket.getApplicationDataSize());
|
||||||
|
ReturnValue_t result = CCSDSTime::convertFromCcsds(&timeToSet,
|
||||||
|
timePacket.getTime(), timePacket.getTimeSize());
|
||||||
|
if(result != RETURN_OK) {
|
||||||
|
triggerEvent(CLOCK_SET_FAILURE, result, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t formerUptime;
|
||||||
|
Clock::getUptime(&formerUptime);
|
||||||
|
result = Clock::setClock(&timeToSet);
|
||||||
|
|
||||||
|
if(result == RETURN_OK) {
|
||||||
|
uint32_t newUptime;
|
||||||
|
Clock::getUptime(&newUptime);
|
||||||
|
triggerEvent(CLOCK_SET,newUptime,formerUptime);
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
triggerEvent(CLOCK_SET_FAILURE, result, 0);
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
41
pus/Service9TimeManagement.h
Normal file
41
pus/Service9TimeManagement.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_
|
||||||
|
#define FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_
|
||||||
|
|
||||||
|
#include "../tmtcservices/PusServiceBase.h"
|
||||||
|
|
||||||
|
class Service9TimeManagement: public PusServiceBase {
|
||||||
|
public:
|
||||||
|
|
||||||
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_9;
|
||||||
|
static constexpr Event CLOCK_SET = MAKE_EVENT(0, SEVERITY::INFO); //!< Clock has been set. P1: New Uptime. P2: Old Uptime
|
||||||
|
static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(1, SEVERITY::LOW); //!< Clock could not be set. P1: Returncode.
|
||||||
|
|
||||||
|
static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This service provides the capability to set the on-board time.
|
||||||
|
*/
|
||||||
|
Service9TimeManagement(object_id_t objectId, uint16_t apid,
|
||||||
|
uint8_t serviceId);
|
||||||
|
|
||||||
|
virtual ~Service9TimeManagement();
|
||||||
|
|
||||||
|
virtual ReturnValue_t performService() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the onboard-time by retrieving the time to set from TC[9,128].
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t handleRequest(uint8_t subservice) override;
|
||||||
|
|
||||||
|
virtual ReturnValue_t setTime();
|
||||||
|
private:
|
||||||
|
|
||||||
|
enum SUBSERVICE {
|
||||||
|
SET_TIME = 128 //!< [EXPORT] : [COMMAND] Time command in ASCII, CUC or CDS format
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_ */
|
32
pus/servicepackets/Service9Packets.h
Normal file
32
pus/servicepackets/Service9Packets.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_
|
||||||
|
#define FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_
|
||||||
|
|
||||||
|
#include "../../serialize/SerialLinkedListAdapter.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Subservice 128
|
||||||
|
* @details
|
||||||
|
* It only contains the time encoded as ASCII, CRC, CUC or CDS
|
||||||
|
* @ingroup spacepackets
|
||||||
|
*/
|
||||||
|
class TimePacket : SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 128
|
||||||
|
public:
|
||||||
|
TimePacket(const uint8_t * timeBuffer_, uint32_t timeSize_) {
|
||||||
|
timeBuffer = timeBuffer_;
|
||||||
|
timeSize = timeSize_;
|
||||||
|
}
|
||||||
|
const uint8_t* getTime() {
|
||||||
|
return timeBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getTimeSize() const {
|
||||||
|
return timeSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
TimePacket(const TimePacket &command);
|
||||||
|
const uint8_t * timeBuffer;
|
||||||
|
uint32_t timeSize; //!< [EXPORT] : [IGNORE]
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_ */
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_RETURNVALUES_FWCLASSIDS_H_
|
#ifndef FSFW_RETURNVALUES_FWCLASSIDS_H_
|
||||||
#define FRAMEWORK_RETURNVALUES_FWCLASSIDS_H_
|
#define FSFW_RETURNVALUES_FWCLASSIDS_H_
|
||||||
|
|
||||||
namespace CLASS_ID {
|
namespace CLASS_ID {
|
||||||
enum {
|
enum {
|
||||||
@ -65,9 +65,10 @@ enum {
|
|||||||
POOL_VARIABLE_IF, //PVA 59
|
POOL_VARIABLE_IF, //PVA 59
|
||||||
HOUSEKEEPING_MANAGER, //HKM 60
|
HOUSEKEEPING_MANAGER, //HKM 60
|
||||||
DLE_ENCODER, //DLEE 61
|
DLE_ENCODER, //DLEE 61
|
||||||
|
PUS_SERVICE_9, //PUS9 62
|
||||||
FW_CLASS_ID_COUNT //is actually count + 1 !
|
FW_CLASS_ID_COUNT //is actually count + 1 !
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FRAMEWORK_RETURNVALUES_FWCLASSIDS_H_ */
|
#endif /* FSFW_RETURNVALUES_FWCLASSIDS_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user