mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 04:03:34 +08:00
orb_advert_t changed to void * and checks changed to nullptr
The existing orb_advert_t use thoughout the code sometimes tries to treat it as a file descriptor and there are checks for < 0 and ::close calls on orb_advert_t types which is an invalid use of an object pointer, which is what orb_advert_t really is. Initially I had changed the -1 initializations to 0 but it was suggested that this should be nullptr. That was a good recommendation but the definition of orb_advert_t had to change to void * because you cannot initialize a uintptr_t as nullptr. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Lorenz Meier
parent
180c8b0cb0
commit
1ca05aaa64
@@ -517,13 +517,13 @@ Sensors::Sensors() :
|
||||
_manual_control_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_sensor_pub(0),
|
||||
_manual_control_pub(0),
|
||||
_actuator_group_3_pub(0),
|
||||
_rc_pub(0),
|
||||
_battery_pub(0),
|
||||
_airspeed_pub(0),
|
||||
_diff_pres_pub(0),
|
||||
_sensor_pub(nullptr),
|
||||
_manual_control_pub(nullptr),
|
||||
_actuator_group_3_pub(nullptr),
|
||||
_rc_pub(nullptr),
|
||||
_battery_pub(nullptr),
|
||||
_airspeed_pub(nullptr),
|
||||
_diff_pres_pub(nullptr),
|
||||
|
||||
/* performance counters */
|
||||
_loop_perf(perf_alloc(PC_ELAPSED, "sensor task update")),
|
||||
@@ -1295,7 +1295,7 @@ Sensors::diff_pres_poll(struct sensor_combined_s &raw)
|
||||
_airspeed.air_temperature_celsius = air_temperature_celsius;
|
||||
|
||||
/* announce the airspeed if needed, just publish else */
|
||||
if (_airspeed_pub > 0) {
|
||||
if (_airspeed_pub != nullptr) {
|
||||
orb_publish(ORB_ID(airspeed), _airspeed_pub, &_airspeed);
|
||||
|
||||
} else {
|
||||
@@ -1770,7 +1770,7 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
_diff_pres.temperature = -1000.0f;
|
||||
|
||||
/* announce the airspeed if needed, just publish else */
|
||||
if (_diff_pres_pub > 0) {
|
||||
if (_diff_pres_pub != nullptr) {
|
||||
orb_publish(ORB_ID(differential_pressure), _diff_pres_pub, &_diff_pres);
|
||||
|
||||
} else {
|
||||
@@ -1784,7 +1784,7 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
|
||||
if (_battery_status.voltage_filtered_v > BATT_V_IGNORE_THRESHOLD) {
|
||||
/* announce the battery status if needed, just publish else */
|
||||
if (_battery_pub > 0) {
|
||||
if (_battery_pub != nullptr) {
|
||||
orb_publish(ORB_ID(battery_status), _battery_pub, &_battery_status);
|
||||
|
||||
} else {
|
||||
@@ -1983,7 +1983,7 @@ Sensors::rc_poll()
|
||||
_rc.timestamp = rc_input.timestamp_last_signal;
|
||||
|
||||
/* publish rc_channels topic even if signal is invalid, for debug */
|
||||
if (_rc_pub > 0) {
|
||||
if (_rc_pub != nullptr) {
|
||||
orb_publish(ORB_ID(rc_channels), _rc_pub, &_rc);
|
||||
|
||||
} else {
|
||||
@@ -2018,7 +2018,7 @@ Sensors::rc_poll()
|
||||
manual.offboard_switch = get_rc_sw2pos_position (rc_channels_s::RC_CHANNELS_FUNCTION_OFFBOARD, _parameters.rc_offboard_th, _parameters.rc_offboard_inv);
|
||||
|
||||
/* publish manual_control_setpoint topic */
|
||||
if (_manual_control_pub > 0) {
|
||||
if (_manual_control_pub != nullptr) {
|
||||
orb_publish(ORB_ID(manual_control_setpoint), _manual_control_pub, &manual);
|
||||
|
||||
} else {
|
||||
@@ -2041,7 +2041,7 @@ Sensors::rc_poll()
|
||||
actuator_group_3.control[7] = manual.aux3;
|
||||
|
||||
/* publish actuator_controls_3 topic */
|
||||
if (_actuator_group_3_pub > 0) {
|
||||
if (_actuator_group_3_pub != nullptr) {
|
||||
orb_publish(ORB_ID(actuator_controls_3), _actuator_group_3_pub, &actuator_group_3);
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user