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
b9db3b32
Commit
b9db3b32
authored
6 years ago
by
kongr45gpen
Browse files
Options
Downloads
Patches
Plain Diff
Fix bugs, typos and issues
parent
24fb3034
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/Message.hpp
+23
-15
23 additions, 15 deletions
inc/Message.hpp
src/Message.cpp
+11
-9
11 additions, 9 deletions
src/Message.cpp
with
34 additions
and
24 deletions
inc/Message.hpp
+
23
−
15
View file @
b9db3b32
...
...
@@ -89,14 +89,18 @@ public:
* Adds an enumerated parameter consisting of an arbitrary number of bits to the end of the
* message
*
* PTC =
1
, PFC = \p bits
* PTC =
2
, PFC = \p bits
*/
void
appendEnumerated
(
uint8_t
bits
,
uint32_t
value
);
void
appendEnumerated
(
uint8_t
bits
,
uint32_t
value
)
{
// TODO: Implement 32-bit enums, if needed
return
appendBits
(
bits
,
value
);
}
/**
* Adds an enumerated parameter consisting of 1 byte to the end of the message
*
* PTC =
1
, PFC = 8
* PTC =
2
, PFC = 8
*/
void
appendEnum8
(
uint8_t
value
)
{
return
appendByte
(
value
);
...
...
@@ -105,7 +109,7 @@ public:
/**
* Adds an enumerated parameter consisting of 2 bytes to the end of the message
*
* PTC =
1
, PFC = 16
* PTC =
2
, PFC = 16
*/
void
appendEnum16
(
uint16_t
value
)
{
return
appendHalfword
(
value
);
...
...
@@ -114,7 +118,7 @@ public:
/**
* Adds an enumerated parameter consisting of 4 bytes to the end of the message
*
* PTC =
1
, PFC = 32
* PTC =
2
, PFC = 32
*/
void
appendEnum32
(
uint32_t
value
)
{
return
appendWord
(
value
);
...
...
@@ -123,7 +127,7 @@ public:
/**
* Adds a 1 byte unsigned integer to the end of the message
*
* PTC =
2
, PFC = 4
* PTC =
3
, PFC = 4
*/
void
appendUint8
(
uint8_t
value
)
{
return
appendByte
(
value
);
...
...
@@ -132,7 +136,7 @@ public:
/**
* Adds a 2 byte unsigned integer to the end of the message
*
* PTC =
2
, PFC = 8
* PTC =
3
, PFC = 8
*/
void
appendUint16
(
uint16_t
value
)
{
return
appendHalfword
(
value
);
...
...
@@ -141,7 +145,7 @@ public:
/**
* Adds a 4 byte unsigned integer to the end of the message
*
* PTC =
2
, PFC = 14
* PTC =
3
, PFC = 14
*/
void
appendUint32
(
uint32_t
value
)
{
return
appendWord
(
value
);
...
...
@@ -150,28 +154,28 @@ public:
/**
* Adds a 1 byte signed integer to the end of the message
*
* PTC =
3
, PFC = 4
* PTC =
4
, PFC = 4
*/
void
appendSint8
(
int8_t
value
)
{
return
appendByte
(
reinterpret_cast
<
uint8_t
&>
(
value
));
return
appendByte
(
reinterpret_cast
<
uint8_t
&>
(
value
));
}
/**
* Adds a 2 byte signed integer to the end of the message
*
* PTC =
3
, PFC = 8
* PTC =
4
, PFC = 8
*/
void
appendSint16
(
int16_t
value
)
{
return
appendHalfword
(
reinterpret_cast
<
uint16_t
&>
(
value
));
return
appendHalfword
(
reinterpret_cast
<
uint16_t
&>
(
value
));
}
/**
* Adds a 4 byte signed integer to the end of the message
*
* PTC =
3
, PFC = 14
* PTC =
4
, PFC = 14
*/
void
appendSint32
(
int32_t
value
)
{
return
appendWord
(
reinterpret_cast
<
uint32_t
&>
(
value
));
return
appendWord
(
reinterpret_cast
<
uint32_t
&>
(
value
));
}
/**
...
...
@@ -180,7 +184,11 @@ public:
* PTC = 5, PFC = 1
*/
void
appendFloat
(
float
value
)
{
static_assert
(
sizeof
(
uint32_t
)
==
sizeof
(
value
),
"Floating point numbers must be 32 bits long"
);
static_assert
(
sizeof
(
uint32_t
)
==
sizeof
(
value
),
"Floating point numbers must be 32 bits long"
);
return
appendWord
(
reinterpret_cast
<
uint32_t
&>
(
value
));
}
return
appendWord
(
reinterpret_cast
<
uint32_t
&>
(
value
));
}
...
...
This diff is collapsed.
Click to expand it.
src/Message.cpp
+
11
−
9
View file @
b9db3b32
#include
"Message.hpp"
#include
<cstring>
#include
<Message.hpp>
Message
::
Message
(
uint8_t
serviceType
,
uint8_t
messageType
,
Message
::
PacketType
packetType
,
uint16_t
applicationId
)
:
serviceType
(
serviceType
),
messageType
(
messageType
),
packetType
(
packetType
),
applicationId
(
applicationId
)
{}
void
Message
::
appendBits
(
uint8_t
numBits
,
uint16_t
data
)
{
assert
(
dataSize
<
ECSS_MAX_MESSAGE_SIZE
);
assert
(
numBits
<
16
);
// TODO: Add assertion that data does not contain 1s outside of numBits bits
assert
(
numBits
<
=
16
);
while
(
numBits
>
0
)
{
// For every sequence of 8 bits...
assert
(
dataSize
<
ECSS_MAX_MESSAGE_SIZE
);
if
(
currentBit
+
numBits
>=
8
)
{
// Will have to shift the bits and insert the next ones later
auto
bitsToAddNow
=
static_cast
<
uint8_t
>
(
8
-
currentBit
);
...
...
@@ -65,13 +73,7 @@ void Message::appendString(uint8_t size, const char *value) {
dataSize
+=
size
;
}
void
Message
::
appendEnumerated
(
uint8_t
bits
,
uint32_t
value
)
{
// TODO: Implement 32-bit enums, if needed
assert
((
value
&
0xffff0000
)
!=
0
);
return
appendBits
(
bits
,
value
)
;
return
value
;
}
Message
::
Message
(
uint8_t
serviceType
,
uint8_t
messageType
,
Message
::
PacketType
packetType
,
uint16_t
applicationId
)
:
serviceType
(
serviceType
),
messageType
(
messageType
),
packetType
(
packetType
),
applicationId
(
applicationId
)
{}
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