Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change register_periodic_telemetry() to use msg ID and support other protocols (mavlink) #1448

Merged
merged 6 commits into from
Dec 1, 2015

Conversation

flixr
Copy link
Member

@flixr flixr commented Nov 29, 2015

Alternative to #1442:

  • Change register_periodic_telemetry() to use msg ID
  • possibility to use register_periodic_telemetry for mavlink and others.
    • in the telemetry xml file a type can be specified for the process (default is "pprz").
    • You can also set "mavlink" and use mavlink messages, which will be sent as specified if the mavlink module is loaded and that mavlink message is registered there.
  • use PPRZ_MSG_ID_x instead of DL_x

This requires an extra unit8_t id field in the struct (so if you have 20 different messages in the telmetry file, this would add an extra 20bytes compared to #1442).
At runtime it will loop over the periodic messages until it finds the matching id (compared to already knowing the index).
Also this really makes it impossible to register "meta/alias" messages... but I would argue that even in #1442 this is not nice since you need to provide the #ifndefs in the code...

in the telemetry xml file a type can be specified for the process (default is "pprz").
You can also set "mavlink" and use mavlink messages, which will be sent as specified if the mavlink module is loaded and that mavlink message is registered there.
@flixr
Copy link
Member Author

flixr commented Nov 29, 2015

So I would vote for this solution, so basically dropping support for registering alias messages and requiring the messages to match instead.
Main reasons for me are: makes it easier to use for mavlink or other protocols as well and reduces footprint on the small systems.

@gautierhattenberger @martinmm @dewagter what do you think?

};

/** Register a telemetry callback function.
* empty implementation is provided if PERIODIC_TELEMETRY is not set or set to FALSE
* @param _pt periodic telemetry structure to register
* @param _msg message name (string) as defined in telemetry xml file
* @param _msgn message id/number (use DL_<message_name> define)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be PPRZ_MSG_ID_

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, fixed

@gautierhattenberger
Copy link
Member

I'm fine with this one

@flixr
Copy link
Member Author

flixr commented Nov 30, 2015

ping @dewagter @martinmm would be great if you could chip in here... would like to merge this ASAP...

- if a mavlink process is specified in the telemetry file, use that, otherwise fall back to fixed message periods
- print warning if telemety file has no mavlink process
- fix code style
@flixr
Copy link
Member Author

flixr commented Nov 30, 2015

@dewagter @LodewijkSikkel also changed the mavlink module to send messages as specified in the telemetry xml file (if no mavlink process in telemetry file it will fall back to hardcoded periods).

@martinmm
Copy link
Member

still fits into the Naze32 if the compressed sine is used, guess the overall size increased over the last 5 months; starts and looks ok
(something is wrong with the compressed sine)

flixr added a commit that referenced this pull request Dec 1, 2015
Change register_periodic_telemetry() to use msg ID and support other protocols (mavlink)

- Change register_periodic_telemetry() to use msg ID (PPRZ_MSG_ID_x or MAVLINK_MSG_ID_x)
- possibility to use register_periodic_telemetry for mavlink and others.
 -  in the telemetry xml file a type can be specified for the process (default is "pprz").
 - You can also set "mavlink" and use mavlink messages, which will be sent as specified if the mavlink module is loaded and that mavlink message is registered there.
@flixr flixr merged commit 506d7de into master Dec 1, 2015
@flixr flixr deleted the register_with_msg_id branch December 1, 2015 17:43
@flixr flixr added this to the v5.8 milestone Dec 1, 2015
// send periodic mavlink messages as defined in the Mavlink process of the telemetry xml file
// transport and device not used here yet...
periodic_telemetry_send_Mavlink(&mavlink_telemetry, NULL, NULL);
#else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this RunOnceEvery was needed before because there was no other option, but now that you have the telemetry file which is much more flexible, I would argue that this RunOnceEvery can be completely removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the RunOnceEvery for now so it will still work when you have a telemetry file without the mavlink process... just wanted to avoid breaking existing stuff...
But I wouldn't mind removing those (except for the send_params)

@dewagter
Copy link
Member

dewagter commented Dec 1, 2015

This looks great and is a milestone in the support of multiple protocols.

Not really about this pull request: but is there no better technical solution than to loop through the list to match ID's on every message? Now that it are uint8_t, can't we have a list of 256 function pointers or is RAM more valuable than a few hundred machine codes per iteration?

@flixr
Copy link
Member Author

flixr commented Dec 1, 2015

Of course we could have a list of 256 function pointers, but IMHO this is wasting space.
The for loop is only needed once when registering the message and at maximum it will loop up to the number of different registered messages... so it should not be very costly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants