Skip to content
Snippets Groups Projects
Commit b99cbfb1 authored by kongr45gpen's avatar kongr45gpen
Browse files

Merge branch 'ECSS-ST13-split-function' into 'master'

ECSS ST13 Split Function

**ECSS ST13 Split Function**  
After the initial development of the ECSS ST13 Large Packet Transfer Service, it is time to * *drumroll* * add the required function that is used to split the Large Messages into smaller ones.  
Currently it works with normal messages. However, the function should be changed in the future, perhaps with the addition of messages that are able to contain an amount of data larger than the current Message class can hold. Right now the Message::data can contain up to 1024 bytes. The max octet string size is 256. The testing was based on these numbers.

**Things to consider about this Service && Function**
*  A new class that fosters all the needs of a large message might be needed
*  Sensors or any device that will produce any kind of data, might use this class, for the purposes of ignoring the data size limit imposed by the protocol

See merge request acubesat/obc/ecss-services!37
parents 49f6188a 1640f47a
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,13 @@ public:
* @param string This will change when these function will be modified
*/
String<ECSS_MAX_FIXED_OCTET_STRING_SIZE> lastUplinkPart(const String<ECSS_MAX_FIXED_OCTET_STRING_SIZE>& string);
/**
* Function that splits large messages
* @param Message that is exceeds the standards and has to be split down
* @param largeMessageTransactionIdentifier that is a value we assign to this splitting of the large message
*/
void split(Message& message, uint16_t largeMessageTransactionIdentifier);
};
#endif // ECSS_SERVICES_LARGEPACKETTRANSFERSERVICE_HPP
......@@ -53,3 +53,38 @@ LargePacketTransferService::lastUplinkPart(const String<ECSS_MAX_FIXED_OCTET_STR
// TC[13, 11]
return string;
}
void LargePacketTransferService::split(Message& message, uint16_t largeMessageTransactionIdentifier) {
//TODO: Should this be uint32?
uint16_t size = message.dataSize;
uint16_t positionCounter = 0;
uint16_t parts = (size/ECSS_MAX_FIXED_OCTET_STRING_SIZE) + 1;
String<ECSS_MAX_FIXED_OCTET_STRING_SIZE> stringPart("");
uint8_t dataPart[ECSS_MAX_FIXED_OCTET_STRING_SIZE];
for (uint16_t i = 0; i < ECSS_MAX_FIXED_OCTET_STRING_SIZE; i++){
dataPart[i] = message.data[positionCounter];
positionCounter++;
}
stringPart = dataPart;
firstDownlinkPartReport(largeMessageTransactionIdentifier, 0, stringPart);
for (uint16_t part = 1; part < (parts - 1u); part++){
for (uint16_t i = 0; i < ECSS_MAX_FIXED_OCTET_STRING_SIZE; i++){
dataPart[i] = message.data[positionCounter];
positionCounter++;
}
stringPart = dataPart;
intermediateDownlinkPartReport(largeMessageTransactionIdentifier, part, stringPart);
}
for (uint16_t i = 0; i < ECSS_MAX_FIXED_OCTET_STRING_SIZE; i++){
if (message.dataSize == positionCounter){
dataPart[i] = 0; // To prevent from filling the rest of the String with garbage info
}
dataPart[i] = message.data[positionCounter];
positionCounter++;
}
stringPart = dataPart;
lastDownlinkPartReport(largeMessageTransactionIdentifier, (parts - 1u), stringPart);
}
......@@ -4,6 +4,7 @@
#include "ServiceTests.hpp"
#include <cstring>
#include <etl/String.hpp>
#include "ECSS_Definitions.hpp"
LargePacketTransferService& lPT = Services.largePacketTransferService;
......@@ -17,7 +18,7 @@ TEST_CASE("First Downlink Part Report TM[13,1]", "[service][st13]") {
CHECK(report.readUint16() == 1);
CHECK(report.readUint16() == 1);
uint8_t string2[ECSS_MAX_FIXED_OCTET_STRING_SIZE];
printf("%d", report.readOctetString(string2));
report.readOctetString(string2);
auto a = String<ECSS_MAX_FIXED_OCTET_STRING_SIZE>(string2, 8);
CHECK(string.compare(a) == 0);
}
......@@ -66,3 +67,24 @@ TEST_CASE("Last Uplink Part TC[13,11]", "[service][st13]") {
String<256> string = "12345678";
CHECK(string.compare(lPT.lastUplinkPart(string)) == 0);
}
TEST_CASE("Split function", "[no][service]") {
Message message(13, 0, Message::TC, 0);
for (uint16_t i = 0; i < 800; i++){
message.appendUint8(UINT8_MAX);
}
uint16_t largeMessageTransactionIdentifier = 1;
lPT.split(message, largeMessageTransactionIdentifier);
Message message5(13, 0, Message::TC, 0);
for (int i = 0; i < 4; i++){
uint16_t partSequenceNumber = i;
CHECK(largeMessageTransactionIdentifier == ServiceTests::get(i).readUint16());
CHECK(partSequenceNumber == ServiceTests::get(i).readUint16());
CHECK(ECSS_MAX_FIXED_OCTET_STRING_SIZE == ServiceTests::get(i).readUint16());
for (int j = 0; j < 256; j++){
message5.appendUint8(ServiceTests::get(i).readUint8());
}
}
CHECK(message == message5);
}
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