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
abecaabe
Commit
abecaabe
authored
4 months ago
by
Ruben Otto
Browse files
Options
Downloads
Patches
Plain Diff
feat: send data to kernel if measurement got updated
parent
7998c196
Branches
Branches containing commit
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
+68
-7
68 additions, 7 deletions
daemon/src/main.c
with
68 additions
and
7 deletions
daemon/src/main.c
+
68
−
7
View file @
abecaabe
...
...
@@ -85,6 +85,9 @@ int main() {
sigaction
(
SIGINT
,
&
signal_action
,
NULL
);
measurement_t
measurement_cache
[
sizeof
(
uint8_t
)];
uint8_t
measurement_cache_size
=
0
;
printf
(
"Started daemon
\n
"
);
while
(
1
)
{
...
...
@@ -98,15 +101,73 @@ int main() {
printf
(
"Received data from %d: "
,
measurement
.
id
);
print_measurement_data
(
&
measurement
);
// -1 = insert & update
// 0 = nothing
// 1 = update
int
action
=
-
1
;
for
(
int
i
=
0
;
i
<
measurement_cache_size
;
i
++
)
{
if
(
measurement_cache
[
i
].
id
!=
measurement
.
id
)
{
continue
;
}
if
(
measurement_cache
[
i
].
datatype
==
measurement
.
datatype
)
{
switch
(
measurement
.
datatype
)
{
case
INT8
:
action
=
measurement_cache
[
i
].
data
.
int8
!=
measurement
.
data
.
int8
;
break
;
case
UINT8
:
action
=
measurement_cache
[
i
].
data
.
uint8
!=
measurement
.
data
.
uint8
;
break
;
case
INT16
:
action
=
measurement_cache
[
i
].
data
.
int16
!=
measurement
.
data
.
int16
;
break
;
case
UINT16
:
action
=
measurement_cache
[
i
].
data
.
uint16
!=
measurement
.
data
.
uint16
;
break
;
case
INT32
:
action
=
measurement_cache
[
i
].
data
.
int32
!=
measurement
.
data
.
int32
;
break
;
case
UINT32
:
action
=
measurement_cache
[
i
].
data
.
uint32
!=
measurement
.
data
.
uint32
;
break
;
case
INT64
:
action
=
measurement_cache
[
i
].
data
.
int64
!=
measurement
.
data
.
int64
;
break
;
case
UINT64
:
action
=
measurement_cache
[
i
].
data
.
uint64
!=
measurement
.
data
.
uint64
;
break
;
case
FLOAT32
:
action
=
measurement_cache
[
i
].
data
.
float32
!=
measurement
.
data
.
float32
;
break
;
case
FLOAT64
:
action
=
measurement_cache
[
i
].
data
.
float64
!=
measurement
.
data
.
float64
;
break
;
}
}
else
{
action
=
-
1
;
}
measurement_cache
[
i
]
=
measurement
;
}
if
(
action
==
-
1
)
{
measurement_cache
[
measurement_cache_size
]
=
measurement
;
measurement_cache_size
++
;
}
if
(
action
!=
0
)
{
data_t
data
=
{
.
sender_id
=
SENDER_ID
,
.
count
=
1
,
.
measurements
=
&
measurement
,
.
count
=
measurement_cache_size
,
.
measurements
=
measurement
_cache
,
};
if
(
send_kernel_message
(
&
kernel_send_handle
,
&
data
)
==
-
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