Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
embedded-linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Maul
embedded-linux
Commits
6c8c0a3e
Commit
6c8c0a3e
authored
4 months ago
by
Ruben Otto
Browse files
Options
Downloads
Patches
Plain Diff
feat: send daemon message to kernel
parent
033a48a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
daemon/src/main.c
+21
-1
21 additions, 1 deletion
daemon/src/main.c
with
21 additions
and
1 deletion
daemon/src/main.c
+
21
−
1
View file @
6c8c0a3e
#include
"../../common/include/message.h"
#include
"../../common/include/userspace_comm.h"
#include
"../include/receive.h"
#include
"../include/send.h"
#include
<errno.h>
#include
<stddef.h>
#include
<string.h>
#include
<stdint.h>
#include
<stdlib.h>
#include
<stdio.h>
...
...
@@ -11,8 +15,11 @@
#include
<signal.h>
userspace_receive_handle_t
userspace_receive_handle
;
kernel_send_handle_t
kernel_send_handle
;
void
signal_handler
(
int
sig
)
{
destroy_userspace_receive_handle
(
&
userspace_receive_handle
);
destroy_kernel_send_handle
(
&
kernel_send_handle
);
exit
(
1
);
}
...
...
@@ -65,7 +72,17 @@ void print_message_data(message_t* message) {
int
main
()
{
if
(
create_userspace_receive_handle
(
&
userspace_receive_handle
)
!=
0
)
{
perror
(
"Failed to create receive module"
);
if
(
errno
==
EEXIST
)
{
fprintf
(
stderr
,
"Failed to create message queue (file '%s' exists, has another process already created the message queue?): %s
\n
"
,
MSG_QUEUE_KEY
,
strerror
(
errno
));
}
else
{
perror
(
"Failed to create message queue"
);
}
return
EXIT_FAILURE
;
}
if
(
create_kernel_send_handle
(
&
kernel_send_handle
)
!=
0
)
{
destroy_userspace_receive_handle
(
&
userspace_receive_handle
);
perror
(
"Failed to create kernel connection (is the kernel module loaded?)"
);
return
EXIT_FAILURE
;
}
...
...
@@ -85,6 +102,9 @@ int main() {
printf
(
"Received data from %d with length %d: "
,
message
.
measurement_id
,
message
.
length
);
print_message_data
(
&
message
);
if
(
send_kernel_message
(
&
kernel_send_handle
,
&
message
)
==
-
1
)
{
printf
(
" (failed to send to kernel)"
);
}
printf
(
"
\n
"
);
}
...
...
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