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 authored and Julian Oes committed 2020-08-27 17:28:12 +02:00
1 parent 16776ff6fb
commit 8eb46b0eb8
1 file changed
+2 -2
+2 -2
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;
}
}