Mavgen JS: Heartbeat message mavlink_version should be automaticlly completed#926
Conversation
Remove from constructor parameter list, and assign directly. Remains settable by the unpacker for received messages. Heartbeat test cases updated to reflect new interface.
b80afe4 to
059e59d
Compare
|
Looks fine to me, but @davidbuzz will know better than I. |
There was a problem hiding this comment.
looks good to me, thankyou.! - @peterbarker happy for you to merge
|
@shancock884 -if your're using the Javascript generator in a project, I'd love to hear about it.. eg, I've used it in a few projects... for example, I implemented this tool... which is the only one i know of that supports packet-signing with these bindings... https://github.com/davidbuzz/MAVAgent |
|
Merged, thanks! |
Hi @davidbuzz. The short version is that I have been working on a mobile phone app for planning waypoint routes - initially just for the drone that our startup (Linking Drones) is working on, using bluetooth. Then to expand its scope of usefulness I was looking into using the phone's USB port as a wired connection to any Mavlink drone. As the app is using React Native I needed some JS! |
This PR updates the Javascript generator to automate the filling of the HEARTBEAT.mavlink_version parameter.
As per the C Mavgen, it uses 'omit_arg' parameter of the field to determine that the parameter should be omitted from the input parameter list, and 'const_value' parameter to determine the value to set.
When building a HEARTBEAT message via the constructor the parameter should no longer be specified, and the test cases have been updated to do this.
When the message is being read from a data stream, the value is correctly populated to whatever its actual value is, as this uses direct field assignment and not the constructor to build the message (I have tested this).
The change in output ends up looking like this:
from:
to:
Testing:
I have tested this on my React Native application, including checking that a received message correctly populates the field - even if its value differs from the default.
This is also tested in CI on a variety of NodeJS versions.