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
f120659e
Commit
f120659e
authored
2 years ago
by
Stavros Malakoudis
Committed by
Stelios Tzelepis
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add functionality to send created packets to Yamcs
parent
c805d199
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/Services/OnBoardMonitoringService.hpp
+1
-1
1 addition, 1 deletion
inc/Services/OnBoardMonitoringService.hpp
src/Platform/x86/Service.cpp
+49
-4
49 additions, 4 deletions
src/Platform/x86/Service.cpp
with
50 additions
and
5 deletions
inc/Services/OnBoardMonitoringService.hpp
+
1
−
1
View file @
f120659e
...
...
@@ -98,4 +98,4 @@ public:
void
execute
(
Message
&
message
);
};
#endif // ECSS_SERVICES_ONBOARDMONITORINGSERVICE_HPP
#endif // ECSS_SERVICES_ONBOARDMONITORINGSERVICE_HPP
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Platform/x86/Service.cpp
+
49
−
4
View file @
f120659e
#include
<iostream>
#include
<iomanip>
#include
<Logger.hpp>
#include
"Service.hpp"
#include
<Logger.hpp>
#include
<MessageParser.hpp>
#include
<arpa/inet.h>
#include
<iomanip>
#include
<iostream>
#include
<netinet/in.h>
#include
<string>
#include
<sys/socket.h>
#include
<unistd.h>
class
PacketSender
{
private:
const
char
*
hostname
=
"127.0.0.1"
;
const
uint16_t
port
=
10015
;
sockaddr_in
destination
;
int
socket
;
public:
PacketSender
()
{
socket
=
::
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
destination
.
sin_family
=
AF_INET
;
destination
.
sin_port
=
htons
(
port
);
destination
.
sin_addr
.
s_addr
=
inet_addr
(
hostname
);
};
~
PacketSender
()
{
::
close
(
socket
);
};
void
sendPacketToYamcs
(
Message
&
message
)
{
// Add ECSS and CCSDS header
String
<
CCSDSMaxMessageSize
>
createdPacket
=
MessageParser
::
compose
(
message
);
auto
bytesSent
=
::
sendto
(
socket
,
createdPacket
.
c_str
(),
createdPacket
.
length
(),
0
,
reinterpret_cast
<
sockaddr
*>
(
&
destination
),
sizeof
(
destination
));
LOG_DEBUG
<<
bytesSent
<<
" bytes sent"
;
}
};
PacketSender
packetSender
;
/**
* If set to true, the created messages will be sent to port 10025 on localhost for testing purposes.
*/
inline
const
bool
SendToYamcs
=
true
;
void
Service
::
storeMessage
(
Message
&
message
)
{
// appends the remaining bits to complete a byte
...
...
@@ -14,12 +54,17 @@ void Service::storeMessage(Message& message) {
ss
<<
"New "
<<
((
message
.
packetType
==
Message
::
TM
)
?
"TM"
:
"TC"
)
<<
"["
<<
std
::
hex
<<
static_cast
<
int
>
(
message
.
serviceType
)
<<
","
// Ignore-MISRA
<<
static_cast
<
int
>
(
message
.
messageType
)
// Ignore-MISRA
<<
static_cast
<
int
>
(
message
.
messageType
)
// Ignore-MISRA
<<
"] message! "
;
for
(
unsigned
int
i
=
0
;
i
<
message
.
dataSize
;
i
++
)
{
ss
<<
static_cast
<
int
>
(
message
.
data
[
i
])
<<
" "
;
// Ignore-MISRA
}
// Send data to YAMCS port
if
constexpr
(
SendToYamcs
)
{
packetSender
.
sendPacketToYamcs
(
message
);
}
LOG_DEBUG
<<
ss
.
str
();
}
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