GCS_MAVLink: fixed locking of mavlink in serial control

this fixes takeover of mavlink ports for high serial numbers
This commit is contained in:
Andrew Tridgell 2020-09-03 10:21:47 +10:00
parent a547af97c6
commit 74686f8dc4
1 changed files with 12 additions and 1 deletions

View File

@ -75,10 +75,21 @@ void GCS_MAVLINK::handle_serial_control(const mavlink_message_t &msg)
return;
}
break;
case SERIAL_CONTROL_SERIAL0 ... SERIAL_CONTROL_SERIAL9:
case SERIAL_CONTROL_SERIAL0 ... SERIAL_CONTROL_SERIAL9: {
// direct access to a SERIALn port
stream = port = AP::serialmanager().get_serial_by_id(packet.device - SERIAL_CONTROL_SERIAL0);
// see if we need to lock mavlink
for (uint8_t i=0; i<MAVLINK_COMM_NUM_BUFFERS; i++) {
GCS_MAVLINK *link = gcs().chan(i);
if (link == nullptr || link->get_uart() != port) {
continue;
}
link->lock(exclusive);
break;
}
break;
}
default:
// not supported yet