added srv9

This commit is contained in:
Robin Müller 2020-08-29 00:16:40 +02:00
parent b0673c7fa6
commit 6c02776975
4 changed files with 133 additions and 0 deletions

View 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;
}
}

View File

@ -0,0 +1,42 @@
#ifndef FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_
#define FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_
#include <fsfw/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
};
void setIsisClock(Clock::TimeOfDay_t& timeOfDay);
};
#endif /* FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_ */

View 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_ */

View File

@ -67,6 +67,7 @@ enum {
DLE_ENCODER, //DLEE 61 DLE_ENCODER, //DLEE 61
PUS_PARSER, //PUSP 62 PUS_PARSER, //PUSP 62
SERIAL_ANALYZER, //SERA 63 SERIAL_ANALYZER, //SERA 63
PUS_SERVICE_9,
FW_CLASS_ID_COUNT //is actually count + 1 ! FW_CLASS_ID_COUNT //is actually count + 1 !
}; };