mavlink: added check if instance mode is serial when trying to find if instance exists (#12642)

This commit is contained in:
garfieldG
2019-08-06 17:53:07 +03:00
committed by Daniel Agar
parent 5a1c46deeb
commit d3ba9c59e0
2 changed files with 5 additions and 5 deletions

View File

@@ -419,14 +419,14 @@ Mavlink::get_status_all_instances(bool show_streams_status)
}
bool
Mavlink::instance_exists(const char *device_name, Mavlink *self)
Mavlink::serial_instance_exists(const char *device_name, Mavlink *self)
{
Mavlink *inst = ::_mavlink_instances;
while (inst != nullptr) {
/* don't compare with itself */
if (inst != self && !strcmp(device_name, inst->_device_name)) {
/* don't compare with itself and with non serial instances*/
if ((inst != self) && (inst->get_protocol() == SERIAL) && !strcmp(device_name, inst->_device_name)) {
return true;
}
@@ -2074,7 +2074,7 @@ Mavlink::task_main(int argc, char *argv[])
}
if (get_protocol() == SERIAL) {
if (Mavlink::instance_exists(_device_name, this)) {
if (Mavlink::serial_instance_exists(_device_name, this)) {
PX4_ERR("%s already running", _device_name);
return PX4_ERROR;
}

View File

@@ -156,7 +156,7 @@ public:
static int get_status_all_instances(bool show_streams_status);
static bool instance_exists(const char *device_name, Mavlink *self);
static bool serial_instance_exists(const char *device_name, Mavlink *self);
static void forward_message(const mavlink_message_t *msg, Mavlink *self);