[patch] minor compiler warning for call to update_sensor_status_flags()

22 views
Skip to first unread message

Ralph Campbell

unread,
Sep 25, 2016, 9:46:26 PM9/25/16
to drones-discuss
I was compiling APMrover2 from the latest git source and found what I think is a minor bug.
I was using arm-none-eabi-gcc (Fedora 5.2.0-3.fc23) 5.2.0.
I was able to compile and download the firmware using qgroundcontrol. I don't have a working rover yet to test with. Just FYI.

diff --git a/APMrover2/GCS_Mavlink.cpp b/APMrover2/GCS_Mavlink.cpp
index 2e1553b..9fbbab7 100644
--- a/APMrover2/GCS_Mavlink.cpp
+++ b/APMrover2/GCS_Mavlink.cpp
@@ -209,7 +209,7 @@ void Rover::send_extended_status1(mavlink_channel_t chan)
 
 #if FRSKY_TELEM_ENABLED == ENABLED
     // give mask of error flags to Frsky_Telemetry
-    uint32_t sensors_error_flags = !control_sensors_health & control_sensors_enabled & control_sensors_present;
+    uint32_t sensors_error_flags = ~control_sensors_health & control_sensors_enabled & control_sensors_present;
     frsky_telemetry.update_sensor_status_flags(sensors_error_flags);
 #endif   
 }

Tom Pittenger

unread,
Sep 25, 2016, 10:09:53 PM9/25/16
to drones-discuss

What is the minor bug?


--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lucas De Marchi

unread,
Sep 26, 2016, 9:48:25 AM9/26/16
to drones-discuss
I guess he's talking about this warning:

../../ArduCopter/GCS_Mavlink.cpp: In member function 'void
Copter::send_extended_status1(mavlink_channel_t)':
../../ArduCopter/GCS_Mavlink.cpp:281:37: error: suggest parentheses
around operand of '!' or change '&' to '&&' or '!' to '~'
[-Werror=parentheses]
uint32_t sensors_error_flags = !control_sensors_health &
control_sensors_enabled & control_sensors_present;
^

Lucas De Marchi
>> email to drones-discus...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "drones-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to drones-discus...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Lucas De Marchi

Tom Pittenger

unread,
Sep 26, 2016, 12:45:11 PM9/26/16
to drones-discuss
yeah, I hate the & stuff as it is written now anyway.


>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "drones-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.



--
Lucas De Marchi

--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discuss+unsubscribe@googlegroups.com.

bi...@communistech.com

unread,
Sep 26, 2016, 4:57:06 PM9/26/16
to drones-...@googlegroups.com
He’s correct in that’s an error since this is logical not !control_sensors_health and should be bitwise not ~control_sensors_health

Fortunately only FrSky radio will be showing something is wring when it’s not or vice versa


uint32_t sensors_error_flags = (control_sensors_health ^ control_sensors_enabled) & control_sensors_present;

Bill




Tom Pittenger

unread,
Sep 26, 2016, 6:01:57 PM9/26/16
to drones-discuss

It works either way in this case. But yeah, it feels like a bug but isn't actually. Still should be changed.


--
You received this message because you are subscribed to the Google Groups "drones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drones-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages