diff --git a/inc/Services/EventReportService.hpp b/inc/Services/EventReportService.hpp index 9682b491c83e13a9278b2c32599190eaedd2cae4..8a2f2bd2debb80d1aa33398567aac599757232da 100644 --- a/inc/Services/EventReportService.hpp +++ b/inc/Services/EventReportService.hpp @@ -16,7 +16,7 @@ #define ECSS_EVENTS_BITS 16 class EventReportService : public Service { -public: +private: static const uint8_t numberOfEvents = 7; std::bitset<numberOfEvents> stateOfEvents; public: @@ -124,7 +124,7 @@ public: /** * TC[5,7] request to report the disabled event definitions - * + * Note: No arguments, according to the standard. */ void requestListOfDisabledEvents(); diff --git a/src/Services/EventReportService.cpp b/src/Services/EventReportService.cpp index 4db2cca4feec5693e665ff125ad5e3431b82d332..407721722f00bd82ec8f0f6ed62629636c2303c0 100644 --- a/src/Services/EventReportService.cpp +++ b/src/Services/EventReportService.cpp @@ -1,9 +1,10 @@ #include <Services/EventReportService.hpp> #include "Services/EventReportService.hpp" #include "Message.hpp" + /** * - * @todo: this code is error prone, depending on parameters given, add fail safes + * @todo: this code is error prone, depending on parameters given, add fail safes (probably?) */ void EventReportService::informativeEventReport(Event eventID, const uint8_t *data, uint8_t length) { @@ -55,15 +56,30 @@ void EventReportService::enableReportGeneration(uint8_t length, Event *eventID) } void EventReportService::disableReportGeneration(uint8_t length, Event *eventID) { + // TC[5,6] for (uint8_t i = 0; i < length; i++) { stateOfEvents[static_cast<uint8_t> (eventID[i])] = 0; } } void EventReportService::requestListOfDisabledEvents() { - + // TC[5,7] + // I think this is all that is needed here. + listOfDisabledEventsReport(); } void EventReportService::listOfDisabledEventsReport() { + // TC[5,8] + Message report = createTM(8); + // Any chance we'll have more than uint8_t (>255 events) ? This will produce an error! + uint8_t numberOfDisabledEvents = stateOfEvents.size() - stateOfEvents.any(); + report.appendByte(numberOfDisabledEvents); + for (uint8_t i = 0; i < numberOfDisabledEvents; i++) { + if (stateOfEvents[i] == 0) { + report.appendEnum8(i); + } + } + + storeMessage(report); }