Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
0ddd7a40
Commit
0ddd7a40
authored
8 years ago
by
Beat Küng
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
logger: write "sys_name" and "time_ref_utc" info to log file
parent
908f7eb4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/logger/logger.cpp
+28
-0
28 additions, 0 deletions
src/modules/logger/logger.cpp
src/modules/logger/logger.h
+1
-0
1 addition, 0 deletions
src/modules/logger/logger.h
with
29 additions
and
0 deletions
src/modules/logger/logger.cpp
+
28
−
0
View file @
0ddd7a40
...
...
@@ -931,6 +931,27 @@ void Logger::write_info(const char *name, const char *value)
_writer
.
unlock
();
}
void
Logger
::
write_info
(
const
char
*
name
,
uint32_t
value
)
{
_writer
.
lock
();
uint8_t
buffer
[
sizeof
(
message_info_header_s
)];
message_info_header_s
*
msg
=
reinterpret_cast
<
message_info_header_s
*>
(
buffer
);
msg
->
msg_type
=
static_cast
<
uint8_t
>
(
MessageType
::
INFO
);
/* construct format key (type and name) */
msg
->
key_len
=
snprintf
(
msg
->
key
,
sizeof
(
msg
->
key
),
"uint32_t %s"
,
name
);
size_t
msg_size
=
sizeof
(
*
msg
)
-
sizeof
(
msg
->
key
)
+
msg
->
key_len
;
/* copy string value directly to buffer */
memcpy
(
&
buffer
[
msg_size
],
&
value
,
sizeof
(
uint32_t
));
msg_size
+=
sizeof
(
uint32_t
);
msg
->
msg_size
=
msg_size
-
3
;
write_wait
(
buffer
,
msg_size
);
_writer
.
unlock
();
}
void
Logger
::
write_header
()
{
...
...
@@ -954,6 +975,13 @@ void Logger::write_version()
{
write_info
(
"ver_sw"
,
PX4_GIT_VERSION_STR
);
write_info
(
"ver_hw"
,
HW_ARCH
);
write_info
(
"sys_name"
,
"PX4"
);
int32_t
utc_offset
=
0
;
if
(
_log_utc_offset
!=
PARAM_INVALID
)
{
param_get
(
_log_utc_offset
,
&
utc_offset
);
write_info
(
"time_ref_utc"
,
utc_offset
*
60
);
}
}
void
Logger
::
write_parameters
()
...
...
This diff is collapsed.
Click to expand it.
src/modules/logger/logger.h
+
1
−
0
View file @
0ddd7a40
...
...
@@ -128,6 +128,7 @@ private:
void
write_version
();
void
write_info
(
const
char
*
name
,
const
char
*
value
);
void
write_info
(
const
char
*
name
,
uint32_t
value
);
void
write_parameters
();
...
...
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