Skip to content
Snippets Groups Projects
Commit edfa0e84 authored by thodkatz's avatar thodkatz
Browse files

Some suggestions have been integrated

parent b10aa5d2
No related branches found
No related tags found
No related merge requests found
......@@ -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 src/Services/ReqVerifService.cpp)
add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp src/Services/TestService.cpp src/Services/RequestVerificationService.cpp)
#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
#ifndef ECSS_SERVICES_REQUSTVERIFICATIONSERVICE_HPP
#define ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP
#include "Service.hpp"
/**
* Implementation of the ST[01] request verification service
*
* @todo All telemetry packets shall have a telemetry packet secondary header
*/
class RequestVerificationService : public Service {
public:
RequestVerificationService() {
serviceType = 1;
}
/**
* TM[1,1] successful acceptance verification report
*/
void successAcceptanceVerification(uint8_t packetType, bool secondaryHeaderFlag,
uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount);
/**
* TM[1,2] failed acceptance verification report
*/
void failAcceptanceVerification(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 successExecutionVerification(uint8_t packetType, bool secondaryHeaderFlag,
uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount);
/**
* TM[1,8] failed completion of execution verification report
*/
void failExecutionVerification(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 failRoutingVerification(uint8_t packetType,
bool secondaryHeaderFlag,
uint16_t APID, uint8_t seqFlag, uint16_t packetSeqCount,
uint16_t code);
};
#endif //ECSS_SERVICES_REQUESTVERIFICATIONSERVICE_HPP
#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
#include "Services/RequestVerificationService.hpp"
void RequestVerificationService::successAcceptanceVerification(uint8_t packetType,
bool secondaryHeaderFlag,
uint16_t APID, uint8_t seqFlag,
uint16_t packetSeqCount) {
// TM[1,1] successful acceptance verification report
assert(packetType <= 1);
assert(APID <= 1024);
assert(seqFlag <= 2);
assert(packetSeqCount <= 8192);
Message report = createTM(1);
report.appendBits(3, ECSS_PUS_VERSION); //packet version number
report.appendBits(1, packetType);
report.appendBits(1, (uint16_t) secondaryHeaderFlag);
report.appendBits(11, APID);
report.appendBits(2, seqFlag);
report.appendBits(14, packetSeqCount);
storeMessage(report);
}
void
RequestVerificationService::failAcceptanceVerification(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(packetType <= 1);
assert(APID <= 1024);
assert(seqFlag <= 2);
assert(packetSeqCount <= 8192);
Message report = createTM(2);
report.appendBits(3, ECSS_PUS_VERSION); //packet version number
report.appendBits(1, packetType);
report.appendBits(1, (uint16_t) secondaryHeaderFlag);
report.appendBits(11, APID);
report.appendBits(2, seqFlag);
report.appendBits(14, packetSeqCount);
report.appendUint16(code);
storeMessage(report);
}
void RequestVerificationService::successExecutionVerification(uint8_t packetType,
bool secondaryHeaderFlag,
uint16_t APID, uint8_t seqFlag,
uint16_t packetSeqCount) {
// TM[1,7] successful completion of execution verification report
assert(packetType <= 1);
assert(APID <= 1024);
assert(seqFlag <= 2);
assert(packetSeqCount <= 8192);
Message report = createTM(7);
report.appendBits(3, ECSS_PUS_VERSION); //packet version number
report.appendBits(1, packetType);
report.appendBits(1, (uint16_t) secondaryHeaderFlag);
report.appendBits(11, APID);
report.appendBits(2, seqFlag);
report.appendBits(14, packetSeqCount);
storeMessage(report);
}
void
RequestVerificationService::failExecutionVerification(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(packetType <= 1);
assert(APID <= 1024);
assert(seqFlag <= 2);
assert(packetSeqCount <= 8192);
Message report = createTM(8);
report.appendBits(3, ECSS_PUS_VERSION); //packet version number
report.appendBits(1, packetType);
report.appendBits(1, (uint16_t) secondaryHeaderFlag);
report.appendBits(11, APID);
report.appendBits(2, seqFlag);
report.appendBits(14, packetSeqCount);
report.appendUint16(code);
storeMessage(report);
}
void
RequestVerificationService::failRoutingVerification(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(packetType <= 1);
assert(APID <= 1024);
assert(seqFlag <= 2);
assert(packetSeqCount <= 8192);
Message report = createTM(10);
report.appendBits(3, ECSS_PUS_VERSION); //packet version number
report.appendBits(1, packetType);
report.appendBits(1, (uint16_t) secondaryHeaderFlag);
report.appendBits(11, APID);
report.appendBits(2, seqFlag);
report.appendBits(14, packetSeqCount);
report.appendUint16(code);
storeMessage(report);
}
\ No newline at end of file
#include <iostream>
#include <Services/TestService.hpp>
#include <Services/ReqVerifService.hpp>
#include <Services/RequestVerificationService.hpp>
#include "Message.hpp"
int main() {
......@@ -31,17 +31,17 @@ int main() {
// ST[01] test
// parameters take random values and works as expected
ReqVerifService reqVerifService;
RequestVerificationService reqVerifService;
receivedPacket = Message(1, 1, Message::TC, 2);
reqVerifService.successAcceptVerif(2, 0, 1, 2, 2, 10);
reqVerifService.successAcceptanceVerification(0, (uint8_t )1, 2, 2, 10);
receivedPacket = Message(1, 2, Message::TC, 2);
reqVerifService.failAccessVerif(2, 0, 1, 2, 2, 10, 5);
reqVerifService.failAcceptanceVerification(0, (uint8_t )1, 2, 2, 10, 5);
receivedPacket = Message(1, 7, Message::TC, 2);
reqVerifService.successExeVerif(2, 0, 1, 2, 2, 10);
reqVerifService.successExecutionVerification(0, (uint8_t )1, 2, 2, 10);
receivedPacket = Message(1, 8, Message::TC, 2);
reqVerifService.failExeVerif(2, 0, 1, 2, 2, 10, 6);
reqVerifService.failExecutionVerification(0, (uint8_t )1, 2, 2, 10, 6);
receivedPacket = Message(1, 10, Message::TC, 2);
reqVerifService.failRoutVerif(2, 0, 1, 2, 2, 10, 7);
reqVerifService.failRoutingVerification(0, (uint8_t )1, 2, 2, 10, 7);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment