Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AcubeSat-OBC
ECSS Services
Commits
31bee53b
Commit
31bee53b
authored
4 years ago
by
Sedictious
Browse files
Options
Downloads
Patches
Plain Diff
Append CRC to packets
parent
d3ac99a9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inc/ECSS_Definitions.hpp
+6
-0
6 additions, 0 deletions
inc/ECSS_Definitions.hpp
src/MessageParser.cpp
+9
-0
9 additions, 0 deletions
src/MessageParser.cpp
test/MessageParser.cpp
+19
-1
19 additions, 1 deletion
test/MessageParser.cpp
with
34 additions
and
1 deletion
inc/ECSS_Definitions.hpp
+
6
−
0
View file @
31bee53b
...
@@ -145,4 +145,10 @@
...
@@ -145,4 +145,10 @@
* @brief Size of the array holding the Parameter objects for the ST[20] parameter service
* @brief Size of the array holding the Parameter objects for the ST[20] parameter service
*/
*/
#define ECSS_PARAMETER_COUNT 3
#define ECSS_PARAMETER_COUNT 3
/**
* @brief Defines whether the optional CRC field is included
*/
#define ECSS_CRC_INCLUDE true
#endif // ECSS_SERVICES_ECSS_DEFINITIONS_H
#endif // ECSS_SERVICES_ECSS_DEFINITIONS_H
This diff is collapsed.
Click to expand it.
src/MessageParser.cpp
+
9
−
0
View file @
31bee53b
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include
"macros.hpp"
#include
"macros.hpp"
#include
"Services/TestService.hpp"
#include
"Services/TestService.hpp"
#include
"Services/RequestVerificationService.hpp"
#include
"Services/RequestVerificationService.hpp"
#include
"Helpers/CRCHelper.hpp"
void
MessageParser
::
execute
(
Message
&
message
)
{
void
MessageParser
::
execute
(
Message
&
message
)
{
switch
(
message
.
serviceType
)
{
switch
(
message
.
serviceType
)
{
...
@@ -194,6 +195,14 @@ String<CCSDS_MAX_MESSAGE_SIZE> MessageParser::compose(const Message& message) {
...
@@ -194,6 +195,14 @@ String<CCSDS_MAX_MESSAGE_SIZE> MessageParser::compose(const Message& message) {
String
<
CCSDS_MAX_MESSAGE_SIZE
>
ccsdsMessage
(
header
,
6
);
String
<
CCSDS_MAX_MESSAGE_SIZE
>
ccsdsMessage
(
header
,
6
);
ccsdsMessage
.
append
(
ecssMessage
);
ccsdsMessage
.
append
(
ecssMessage
);
#if ECSS_CRC_INCLUDE
// Append CRC field
uint16_t
crcField
=
CRCHelper
::
calculateCRC
(
reinterpret_cast
<
uint8_t
*>
(
ccsdsMessage
.
data
()),
6
+
packetDataLength
);
ccsdsMessage
.
push_back
(
static_cast
<
uint8_t
>
(
crcField
>>
8U
));
ccsdsMessage
.
push_back
(
static_cast
<
uint8_t
>
(
crcField
&
0xFF
));
#endif
return
ccsdsMessage
;
return
ccsdsMessage
;
}
}
...
...
This diff is collapsed.
Click to expand it.
test/MessageParser.cpp
+
19
−
1
View file @
31bee53b
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
<Services/RequestVerificationService.hpp>
#include
<Services/RequestVerificationService.hpp>
#include
<Message.hpp>
#include
<Message.hpp>
#include
<cstring>
#include
<cstring>
#include
"Helpers/CRCHelper.hpp"
#include
"MessageParser.hpp"
#include
"MessageParser.hpp"
#include
"Services/ServiceTests.hpp"
#include
"Services/ServiceTests.hpp"
#include
"ServicePool.hpp"
#include
"ServicePool.hpp"
...
@@ -35,10 +36,18 @@ TEST_CASE("TC Message parsing into a string", "[MessageParser]") {
...
@@ -35,10 +36,18 @@ TEST_CASE("TC Message parsing into a string", "[MessageParser]") {
message
.
dataSize
=
5
;
message
.
dataSize
=
5
;
String
<
CCSDS_MAX_MESSAGE_SIZE
>
createdPacket
=
MessageParser
::
compose
(
message
);
String
<
CCSDS_MAX_MESSAGE_SIZE
>
createdPacket
=
MessageParser
::
compose
(
message
);
#if ECSS_CRC_INCLUDE
CHECK
(
createdPacket
.
size
()
==
18
);
CHECK
(
memcmp
(
createdPacket
.
data
(),
wantedPacket
,
16
)
==
0
);
uint16_t
crcField
=
CRCHelper
::
calculateCRC
(
wantedPacket
,
16
);
uint16_t
calculatedCRC
=
(
static_cast
<
uint16_t
>
(
createdPacket
.
data
()[
16
])
<<
0x8U
)
|
(
static_cast
<
uint16_t
>
(
createdPacket
.
data
()[
17
])
&
0xFF
);
CHECK
(
calculatedCRC
==
crcField
);
#else
CHECK
(
createdPacket
.
size
()
==
16
);
CHECK
(
createdPacket
.
size
()
==
16
);
// The two parentheses are necessary so that Catch2 doesn't try to parse the strings here
// The two parentheses are necessary so that Catch2 doesn't try to parse the strings here
CHECK
((
createdPacket
==
String
<
16
>
(
wantedPacket
)));
CHECK
((
createdPacket
==
String
<
16
>
(
wantedPacket
)));
#endif
}
}
TEST_CASE
(
"TM message parsing"
,
"[MessageParser]"
)
{
TEST_CASE
(
"TM message parsing"
,
"[MessageParser]"
)
{
...
@@ -67,10 +76,19 @@ TEST_CASE("TM Message parsing into a string", "[MessageParser]") {
...
@@ -67,10 +76,19 @@ TEST_CASE("TM Message parsing into a string", "[MessageParser]") {
message
.
messageType
=
17
;
message
.
messageType
=
17
;
memcpy
(
message
.
data
,
"hellohi"
,
7
);
memcpy
(
message
.
data
,
"hellohi"
,
7
);
message
.
dataSize
=
7
;
message
.
dataSize
=
7
;
String
<
CCSDS_MAX_MESSAGE_SIZE
>
createdPacket
=
MessageParser
::
compose
(
message
);
String
<
CCSDS_MAX_MESSAGE_SIZE
>
createdPacket
=
MessageParser
::
compose
(
message
);
#if ECSS_CRC_INCLUDE
CHECK
(
createdPacket
.
size
()
==
20
);
CHECK
(
memcmp
(
createdPacket
.
data
(),
wantedPacket
,
18
)
==
0
);
uint16_t
crcField
=
CRCHelper
::
calculateCRC
(
wantedPacket
,
18
);
uint16_t
calculatedCRC
=
(
static_cast
<
uint16_t
>
(
createdPacket
.
data
()[
18
])
<<
0x8U
)
|
(
static_cast
<
uint16_t
>
(
createdPacket
.
data
()[
19
])
&
0xFFU
);
CHECK
(
calculatedCRC
==
crcField
);
#else
CHECK
(
createdPacket
.
size
()
==
18
);
CHECK
(
createdPacket
.
size
()
==
18
);
// The two parentheses are necessary so that Catch2 doesn't try to parse the strings here
// The two parentheses are necessary so that Catch2 doesn't try to parse the strings here
CHECK
((
createdPacket
==
String
<
18
>
(
wantedPacket
)));
CHECK
((
createdPacket
==
String
<
18
>
(
wantedPacket
)));
#endif
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment