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
9dbbe8cd
Commit
9dbbe8cd
authored
8 years ago
by
Mark Whitehorn
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
log changes to parameters
parent
e5e523aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/logger/logger.cpp
+76
-0
76 additions, 0 deletions
src/modules/logger/logger.cpp
src/modules/logger/logger.h
+3
-0
3 additions, 0 deletions
src/modules/logger/logger.h
with
79 additions
and
0 deletions
src/modules/logger/logger.cpp
+
76
−
0
View file @
9dbbe8cd
...
...
@@ -452,6 +452,14 @@ void Logger::run()
bool
data_written
=
false
;
/* Check if parameters have changed */
// this needs to change to a timestamped record to record a history of parameter changes
if
(
_parameter_update_sub
.
check_updated
())
{
warnx
(
"parameter update"
);
_parameter_update_sub
.
update
();
write_changed_parameters
();
}
// Write data messages for normal subscriptions
int
msg_id
=
0
;
...
...
@@ -757,11 +765,13 @@ void Logger::write_parameters()
param_t
param
=
0
;
do
{
// get next parameter which is invalid OR used
do
{
param
=
param_for_index
(
param_idx
);
++
param_idx
;
}
while
(
param
!=
PARAM_INVALID
&&
!
param_used
(
param
));
// save parameters which are valid AND used
if
(
param
!=
PARAM_INVALID
)
{
/* get parameter type and size */
const
char
*
type_str
;
...
...
@@ -808,5 +818,71 @@ void Logger::write_parameters()
_writer
.
notify
();
}
void
Logger
::
write_changed_parameters
()
{
_writer
.
lock
();
uint8_t
buffer
[
sizeof
(
message_parameter_header_s
)
+
sizeof
(
param_value_u
)];
message_parameter_header_s
*
msg
=
reinterpret_cast
<
message_parameter_header_s
*>
(
buffer
);
msg
->
msg_type
=
static_cast
<
uint8_t
>
(
MessageType
::
PARAMETER
);
int
param_idx
=
0
;
param_t
param
=
0
;
do
{
// get next parameter which is invalid OR used
do
{
param
=
param_for_index
(
param_idx
);
++
param_idx
;
}
while
(
param
!=
PARAM_INVALID
&&
!
param_used
(
param
));
// log parameters which are valid AND used AND unsaved
if
((
param
!=
PARAM_INVALID
)
&&
param_value_unsaved
(
param
))
{
warnx
(
"logging change to parameter %s"
,
param_name
(
param
));
/* get parameter type and size */
const
char
*
type_str
;
param_type_t
type
=
param_type
(
param
);
size_t
value_size
=
0
;
switch
(
type
)
{
case
PARAM_TYPE_INT32
:
type_str
=
"int32_t"
;
value_size
=
sizeof
(
int32_t
);
break
;
case
PARAM_TYPE_FLOAT
:
type_str
=
"float"
;
value_size
=
sizeof
(
float
);
break
;
default:
continue
;
}
/* format parameter key (type and name) */
msg
->
key_len
=
snprintf
(
msg
->
key
,
sizeof
(
msg
->
key
),
"%s %s"
,
type_str
,
param_name
(
param
));
size_t
msg_size
=
sizeof
(
*
msg
)
-
sizeof
(
msg
->
key
)
+
msg
->
key_len
;
/* copy parameter value directly to buffer */
param_get
(
param
,
&
buffer
[
msg_size
]);
msg_size
+=
value_size
;
msg
->
msg_size
=
msg_size
-
2
;
/* write message */
while
(
!
_writer
.
write
(
buffer
,
msg_size
))
{
/* wait if buffer is full, don't skip PARAMETER messages */
_writer
.
unlock
();
_writer
.
notify
();
usleep
(
_log_interval
);
_writer
.
lock
();
}
}
}
while
((
param
!=
PARAM_INVALID
)
&&
(
param_idx
<
(
int
)
param_count
()));
_writer
.
unlock
();
_writer
.
notify
();
}
}
}
This diff is collapsed.
Click to expand it.
src/modules/logger/logger.h
+
3
−
0
View file @
9dbbe8cd
...
...
@@ -76,6 +76,8 @@ private:
void
write_parameters
();
void
write_changed_parameters
();
bool
copy_if_updated_multi
(
orb_id_t
topic
,
int
multi_instance
,
int
*
handle
,
void
*
buffer
,
uint64_t
*
time_last_checked
);
static
constexpr
size_t
MAX_TOPICS_NUM
=
128
;
...
...
@@ -87,6 +89,7 @@ private:
uint8_t
*
_log_buffer
;
char
_log_dir
[
64
];
uORB
::
Subscription
<
vehicle_status_s
>
_vehicle_status_sub
{
ORB_ID
(
vehicle_status
)};
uORB
::
Subscription
<
parameter_update_s
>
_parameter_update_sub
{
ORB_ID
(
parameter_update
)};
bool
_enabled
=
false
;
bool
_log_on_start
;
Array
<
LoggerSubscription
,
MAX_TOPICS_NUM
>
_subscriptions
;
...
...
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