mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-13 14:51:37 +08:00
mavlink: allow resetting mavlink streams to default via MAV_CMD_SET_MESSAGE_INTERVAL
This implementation does not need more resources. It's not super efficient in terms of runtime, but it's also not something that is called often.
This commit is contained in:
@@ -1844,7 +1844,7 @@ MavlinkReceiver::handle_message_heartbeat(mavlink_message_t *msg)
|
||||
int
|
||||
MavlinkReceiver::set_message_interval(int msgId, float interval, int data_rate)
|
||||
{
|
||||
if (msgId == 0) {
|
||||
if (msgId == MAVLINK_MSG_ID_HEARTBEAT) {
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
@@ -1853,18 +1853,16 @@ MavlinkReceiver::set_message_interval(int msgId, float interval, int data_rate)
|
||||
}
|
||||
|
||||
// configure_stream wants a rate (msgs/second), so convert here.
|
||||
float rate = 0;
|
||||
float rate = 0.f;
|
||||
|
||||
if (interval < 0) {
|
||||
// stop the stream.
|
||||
rate = 0;
|
||||
if (interval < -0.00001f) {
|
||||
rate = 0.f; // stop the stream
|
||||
|
||||
} else if (interval > 0) {
|
||||
} else if (interval > 0.00001f) {
|
||||
rate = 1000000.0f / interval;
|
||||
|
||||
} else {
|
||||
// note: mavlink spec says rate == 0 is requesting a default rate but our streams
|
||||
// don't publish a default rate so for now let's pick a default rate of zero.
|
||||
rate = -2.f; // set default rate
|
||||
}
|
||||
|
||||
bool found_id = false;
|
||||
|
||||
Reference in New Issue
Block a user