diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index c566bef13c062f50662a8271cd9c534712ae2d47..efd791e85b4902d773897aeb8ae48aa37dfc243b 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -2,6 +2,25 @@ <code_scheme name="Project" version="173"> <option name="RIGHT_MARGIN" value="100" /> <Objective-C-extensions> + <file> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> + </file> + <class> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> + </class> <extensions> <pair source="cpp" header="hpp" fileNamingConvention="NONE" /> <pair source="c" header="h" fileNamingConvention="NONE" /> diff --git a/CMakeLists.txt b/CMakeLists.txt index 60c3d8e969bb35fdf549059aa57d2ed426e230d9..6016165b3172d91883fac9fb36430caa2fc37a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,4 +14,4 @@ add_custom_target(check WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/ci") # Specify the .cpp files for the executables -add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp src/Services/TestService.cpp) +add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp src/Services/TestService.cpp src/Services/ReqVerifService.cpp) diff --git a/inc/Services/ReqVerifService.hpp b/inc/Services/ReqVerifService.hpp new file mode 100644 index 0000000000000000000000000000000000000000..42eeb1a0d840450685d04f14f311f0e627143d31 --- /dev/null +++ b/inc/Services/ReqVerifService.hpp @@ -0,0 +1,56 @@ + +#ifndef ECSS_SERVICES_REQVERIFSERVICE_HPP +#define ECSS_SERVICES_REQVERIFSERVICE_HPP + +#include "Service.hpp" + +/** + * Implementation of the ST[01] request verification service + * + * @todo All telemetry packets shall have a telemetry packet secondary header + */ +class ReqVerifService : public Service { +public: + ReqVerifService() { + serviceType = 1; + } + + /** + * TM[1,1] successful acceptance verification report + */ + void successAcceptVerif(uint8_t packetVersionNum, uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount); + + /** + * TM[1,2] failed acceptance verification report + */ + void failAccessVerif(uint8_t packetVersionNum, uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, uint16_t code); + + + /** + * TM[1,7] successful completion of execution verification report + */ + void successExeVerif(uint8_t packetVersionNum, uint8_t packetType, bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount); + + /** + * TM[1,8] failed completion of execution verification report + */ + void failExeVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code); + + /** + * TM[1,10] failed routing verification report + */ + void failRoutVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code); + + +}; + +#endif //ECSS_SERVICES_REQVERIFSERVICE_HPP diff --git a/src/Service.cpp b/src/Service.cpp index 27a9f4746007488ac3a881c5afda77d88adb581d..07403e438e1ff884b430c5eafff7d92a7d63c63c 100644 --- a/src/Service.cpp +++ b/src/Service.cpp @@ -7,9 +7,10 @@ void Service::storeMessage(const Message &message) { std::cout << "New " << ((message.packetType == Message::TM) ? "TM" : "TC") << "[" << std::dec << static_cast<int>(message.serviceType) << "," << static_cast<int>(message.messageType) << "] message!\n"; - std::cout << std::hex << std::setfill('0') << std::setw(2); + //std::cout << std::hex << std::setfill('0') << std::setw(2); for (int i = 0; i < message.dataSize; i++) { std::cout << static_cast<int>(message.data[i]); + std::cout << " "; } std::cout << std::endl; } diff --git a/src/Services/ReqVerifService.cpp b/src/Services/ReqVerifService.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8ebb6969c910063a25ee3291fb51b73e3661ce9c --- /dev/null +++ b/src/Services/ReqVerifService.cpp @@ -0,0 +1,105 @@ +#include "Services/ReqVerifService.hpp" + +void ReqVerifService::successAcceptVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, uint16_t APID, uint8_t seqFlag, + uint16_t packetSeqCount) { + // TM[1,1] successful acceptance verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(1); + + report.appendUint32(value); + + storeMessage(report); +} + +void ReqVerifService::failAccessVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code) { + // TM[1,2] failed acceptance verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(2); + + report.appendUint32(value); + + report.appendUint16(code); + + storeMessage(report); +} + +void ReqVerifService::successExeVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, uint16_t APID, uint8_t seqFlag, + uint16_t packetSeqCount) { + // TM[1,7] successful completion of execution verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(7); + + report.appendUint32(value); + + storeMessage(report); +} + +void ReqVerifService::failExeVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code) { + // TM[1,8] failed completion of execution verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(8); + + report.appendUint32(value); + + report.appendUint16(code); + + storeMessage(report); +} + +void ReqVerifService::failRoutVerif(uint8_t packetVersionNum, uint8_t packetType, + bool secondaryHeaderFlag, + uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount, + uint16_t code) { + // TM[1,10] failed routing verification report + assert(packetVersionNum <= 4 & packetType <= 1 & APID <= 1024 & seqFlag <= 2 & + packetSeqCount <= 8192); + + uint32_t value; + + value = (packetVersionNum << 29 | packetType << 28 | secondaryHeaderFlag << 27 | APID << 16 | + seqFlag << 14 | packetSeqCount); + + Message report = createTM(10); + + report.appendUint32(value); + + report.appendUint16(code); + + storeMessage(report); +} \ No newline at end of file diff --git a/src/Services/TestService.cpp b/src/Services/TestService.cpp index 06f60263866d9ed9192dc95385e7570b174a1bea..d7d83a94da551e344334262fc94af4c04954e60f 100644 --- a/src/Services/TestService.cpp +++ b/src/Services/TestService.cpp @@ -12,6 +12,6 @@ void TestService::onBoardConnection(Message &request) { Message report = createTM(4); report.appendUint16(request.readUint16()); - + //just print it on the screen storeMessage(report); } diff --git a/src/main.cpp b/src/main.cpp index cc24193a9f71cec7719e7ce55e85cecf1e3aa968..0ee6aeacf6757253e27c629031eafa7a1012692f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include <iostream> #include <Services/TestService.hpp> +#include <Services/ReqVerifService.hpp> #include "Message.hpp" int main() { @@ -27,5 +28,19 @@ int main() { receivedPacket.appendUint16(7); testService.onBoardConnection(receivedPacket); + // ST[01] test + // parameters take random values and works as expected + ReqVerifService reqVerifService; + receivedPacket = Message(1, 1, Message::TC, 2); + reqVerifService.successAcceptVerif(2, 0, 1, 2, 2, 10); + receivedPacket = Message(1, 2, Message::TC, 2); + reqVerifService.failAccessVerif(2, 0, 1, 2, 2, 10, 5); + receivedPacket = Message(1, 7, Message::TC, 2); + reqVerifService.successExeVerif(2, 0, 1, 2, 2, 10); + receivedPacket = Message(1, 8, Message::TC, 2); + reqVerifService.failExeVerif(2, 0, 1, 2, 2, 10, 6); + receivedPacket = Message(1, 10, Message::TC, 2); + reqVerifService.failRoutVerif(2, 0, 1, 2, 2, 10, 7); + return 0; }