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.

Here is the source code of Ardupilot, including ArduPlane.

  • $\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$ – Dave Jan 1 '15 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$ – qsp Jan 2 '15 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$ – Dave Jan 2 '15 at 22:47
  • $\begingroup$ @Dave I already asked in the APM forum, and nobody has replied me yet. Thanks anyway. $\endgroup$ – qsp Jan 4 '15 at 4:20

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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