1
$\begingroup$

I'm trying to understand the source code of ArduPlane. The MAVLink message is decoded using a set of _MAV_RETURN_???? functions, e.g. _MAV_RETURN_float

When I grep recursively for _MAV_RETURN_float, I could not find where it is defined. I wonder if I'm missing anything.


UPDATE
Here is the source code of Ardupilot, including ArduPlane.
https://github.com/diydrones/ardupilot

$\endgroup$
4
  • $\begingroup$ they look like macros and not functions. take a look into the header file (.h or .hpp). Anyway, since not everybody has ArduPlane installed it should be nice if you points us to the repository on GitHub if present (as I started it was there) $\endgroup$
    – Wilhelm
    Jan 1, 2015 at 9:16
  • $\begingroup$ @Dave thanks for your reply, I updated the repository of the source code. I grepped recursively for all files in all sub-folders, and I could only see places it is called. $\endgroup$
    – sean
    Jan 2, 2015 at 20:13
  • $\begingroup$ You are right. I've downloaded the whole repositiry and searched with grep thru all files. I get only return functions, but not the macro. I saw in internet but nothing. I think you should ask in the diydrones forum. Sorry! $\endgroup$
    – Wilhelm
    Jan 2, 2015 at 22:47
  • $\begingroup$ @Dave I already asked in the APM forum, and nobody has replied me yet. Thanks anyway. $\endgroup$
    – sean
    Jan 4, 2015 at 4:20

1 Answer 1

1
+50
$\begingroup$

Macros(_MAV_RETURN_??) for uin8_t, int8_t and char are defined at https://github.com/diydrones/ardupilot/blob/master/libraries/GCS_MAVLink/include/mavlink/v1.0/protocol.h#L236 onwoards.

However for datatype with more that 8 bits, they have written inline function _MAV_RETURN_## using 'Token Pasting Operator' which handles rest 16bit, 32bit and 64bit datatypes handled by mavlink including float. This function is written at https://github.com/diydrones/ardupilot/blob/master/libraries/GCS_MAVLink/include/mavlink/v1.0/protocol.h#L242 onwards

You an read more about Token Pasting Operator (##) in following links https://stackoverflow.com/questions/216875/in-macros https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html#Concatenation

$\endgroup$
1
  • $\begingroup$ Thank you. I didn't know about the Token Pasting Operator. $\endgroup$
    – sean
    Jan 6, 2015 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.