Last change
on this file since 73 was 46, checked in by Thomas Fuhrmann, 8 years ago |
Add the mavlink branch
|
File size:
1.1 KB
|
Rev | Line | |
---|
| 1 | #ifndef _MAVLINK_GET_INFO_H_
|
---|
| 2 | #define _MAVLINK_GET_INFO_H_
|
---|
| 3 |
|
---|
| 4 | #ifdef MAVLINK_USE_MESSAGE_INFO
|
---|
| 5 | #define MAVLINK_HAVE_GET_MESSAGE_INFO
|
---|
| 6 | /*
|
---|
| 7 | return the message_info struct for a message
|
---|
| 8 | */
|
---|
| 9 | MAVLINK_HELPER const mavlink_message_info_t *mavlink_get_message_info(const mavlink_message_t *msg)
|
---|
| 10 | {
|
---|
| 11 | static const mavlink_message_info_t mavlink_message_info[] = MAVLINK_MESSAGE_INFO;
|
---|
| 12 | /*
|
---|
| 13 | use a bisection search to find the right entry. A perfect hash may be better
|
---|
| 14 | Note that this assumes the table is sorted with primary key msgid
|
---|
| 15 | */
|
---|
| 16 | uint32_t msgid = msg->msgid;
|
---|
| 17 | uint32_t low=0, high=sizeof(mavlink_message_info)/sizeof(mavlink_message_info[0]);
|
---|
| 18 | while (low < high) {
|
---|
| 19 | uint32_t mid = (low+1+high)/2;
|
---|
| 20 | if (msgid < mavlink_message_info[mid].msgid) {
|
---|
| 21 | high = mid-1;
|
---|
| 22 | continue;
|
---|
| 23 | }
|
---|
| 24 | if (msgid > mavlink_message_info[mid].msgid) {
|
---|
| 25 | low = mid;
|
---|
| 26 | continue;
|
---|
| 27 | }
|
---|
| 28 | low = mid;
|
---|
| 29 | break;
|
---|
| 30 | }
|
---|
| 31 | return &mavlink_message_info[low];
|
---|
| 32 | }
|
---|
| 33 | #endif // MAVLINK_USE_MESSAGE_INFO
|
---|
| 34 |
|
---|
| 35 | #endif // _MAVLINK_GET_INFO_H_
|
---|
| 36 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.