mavlink: check type on instance getting by device or network port

otherwise serial mavlink running in first will occupy default net port 14556 and could be wrongly used for stream configuring instead or udp mavlink running in first will occupy default serial "/dev/ttyS1"and could be wrongly used for stream configuring instead

issue #15558
This commit is contained in:
Oleg Evseev 2020-08-26 15:27:57 +03:00 committed by Julian Oes
parent 16776ff6fb
commit 8eb46b0eb8
1 changed files with 2 additions and 2 deletions

View File

@ -331,7 +331,7 @@ Mavlink::get_instance_for_device(const char *device_name)
Mavlink *inst;
LL_FOREACH(::_mavlink_instances, inst) {
if (strcmp(inst->_device_name, device_name) == 0) {
if ((inst->_protocol == Protocol::SERIAL) && (strcmp(inst->_device_name, device_name) == 0)) {
return inst;
}
}
@ -346,7 +346,7 @@ Mavlink::get_instance_for_network_port(unsigned long port)
Mavlink *inst;
LL_FOREACH(::_mavlink_instances, inst) {
if (inst->_network_port == port) {
if ((inst->_protocol == Protocol::UDP) && (inst->_network_port == port)) {
return inst;
}
}