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
a48e3bf6
Commit
a48e3bf6
authored
7 years ago
by
Daniel Agar
Browse files
Options
Downloads
Patches
Plain Diff
sensors fix uninitialized diffferential_pressure message
- fixes coverity CID 260383
parent
fc829b85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/sensors/sensors.cpp
+11
-8
11 additions, 8 deletions
src/modules/sensors/sensors.cpp
with
11 additions
and
8 deletions
src/modules/sensors/sensors.cpp
+
11
−
8
View file @
a48e3bf6
...
...
@@ -183,6 +183,10 @@ private:
DataValidator
_airspeed_validator
;
/**< data validator to monitor airspeed */
#ifdef ADC_AIRSPEED_VOLTAGE_CHANNEL
differential_pressure_s
_diff_pres
{};
#endif
/* ADC_AIRSPEED_VOLTAGE_CHANNEL */
Battery
_battery
[
BOARD_NUMBER_BRICKS
];
/**< Helper lib to publish battery_status topic. */
Parameters
_parameters
{};
/**< local copies of interesting parameters */
...
...
@@ -480,7 +484,7 @@ Sensors::adc_poll()
if
(
ADC_AIRSPEED_VOLTAGE_CHANNEL
==
buf_adc
[
i
].
am_channel
)
{
/* calculate airspeed, raw is the difference from */
float
voltage
=
(
float
)(
buf_adc
[
i
].
am_data
)
*
3.3
f
/
4096.0
f
*
2.0
f
;
// V_ref/4096 * (voltage divider factor)
const
float
voltage
=
(
float
)(
buf_adc
[
i
].
am_data
)
*
3.3
f
/
4096.0
f
*
2.0
f
;
// V_ref/4096 * (voltage divider factor)
/**
* The voltage divider pulls the signal down, only act on
...
...
@@ -489,17 +493,16 @@ Sensors::adc_poll()
*/
if
(
voltage
>
0.4
f
&&
(
_parameters
.
diff_pres_analog_scale
>
0.0
f
))
{
float
diff_pres_pa_raw
=
voltage
*
_parameters
.
diff_pres_analog_scale
-
_parameters
.
diff_pres_offset_pa
;
const
float
diff_pres_pa_raw
=
voltage
*
_parameters
.
diff_pres_analog_scale
-
_parameters
.
diff_pres_offset_pa
;
differential_pressure_s
diff_pres
;
diff_pres
.
timestamp
=
t
;
diff_pres
.
differential_pressure_raw_pa
=
diff_pres_pa_raw
;
diff_pres
.
differential_pressure_filtered_pa
=
(
diff_pres
.
differential_pressure_filtered_pa
*
0.9
f
)
+
_diff_pres
.
timestamp
=
t
;
_diff_pres
.
differential_pressure_raw_pa
=
diff_pres_pa_raw
;
_diff_pres
.
differential_pressure_filtered_pa
=
(
_diff_pres
.
differential_pressure_filtered_pa
*
0.9
f
)
+
(
diff_pres_pa_raw
*
0.1
f
);
diff_pres
.
temperature
=
-
1000.0
f
;
_
diff_pres
.
temperature
=
-
1000.0
f
;
int
instance
;
orb_publish_auto
(
ORB_ID
(
differential_pressure
),
&
_diff_pres_pub
,
&
diff_pres
,
&
instance
,
ORB_PRIO_DEFAULT
);
orb_publish_auto
(
ORB_ID
(
differential_pressure
),
&
_diff_pres_pub
,
&
_
diff_pres
,
&
instance
,
ORB_PRIO_DEFAULT
);
}
}
else
...
...
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