| 25 | } |
| 26 | |
| 27 | bool MAVLinkReceiver::parse_message() { |
| 28 | // Note that one datagram can contain multiple mavlink messages. |
| 29 | for (unsigned i = 0; i < _datagram_len; ++i) { |
| 30 | if (mavlink_parse_char(_channel, _datagram[i], &_last_message, &_status) == |
| 31 | 1) { |
| 32 | // Move the pointer to the datagram forward by the amount parsed. |
| 33 | _datagram += (i + 1); |
| 34 | // And decrease the length, so we don't overshoot in the next round. |
| 35 | _datagram_len -= (i + 1); |
| 36 | |
| 37 | if (_drop_debugging_on) { |
| 38 | debug_drop_rate(); |
| 39 | } |
| 40 | |
| 41 | // We have parsed one message, let's return, so it can be handled. |
| 42 | return true; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // No (more) messages, let's give up. |
| 47 | _datagram = nullptr; |
| 48 | _datagram_len = 0; |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | void MAVLinkReceiver::debug_drop_rate() { |
| 53 | if (_last_message.msgid == MAVLINK_MSG_ID_SYS_STATUS) { |
nothing calls this directly
no outgoing calls
no test coverage detected