mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
mavlink: added check if instance mode is serial when trying to find if instance exists (#12642)
This commit is contained in:
@@ -419,14 +419,14 @@ Mavlink::get_status_all_instances(bool show_streams_status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Mavlink::instance_exists(const char *device_name, Mavlink *self)
|
Mavlink::serial_instance_exists(const char *device_name, Mavlink *self)
|
||||||
{
|
{
|
||||||
Mavlink *inst = ::_mavlink_instances;
|
Mavlink *inst = ::_mavlink_instances;
|
||||||
|
|
||||||
while (inst != nullptr) {
|
while (inst != nullptr) {
|
||||||
|
|
||||||
/* don't compare with itself */
|
/* don't compare with itself and with non serial instances*/
|
||||||
if (inst != self && !strcmp(device_name, inst->_device_name)) {
|
if ((inst != self) && (inst->get_protocol() == SERIAL) && !strcmp(device_name, inst->_device_name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2074,7 +2074,7 @@ Mavlink::task_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (get_protocol() == SERIAL) {
|
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);
|
PX4_ERR("%s already running", _device_name);
|
||||||
return PX4_ERROR;
|
return PX4_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ public:
|
|||||||
|
|
||||||
static int get_status_all_instances(bool show_streams_status);
|
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);
|
static void forward_message(const mavlink_message_t *msg, Mavlink *self);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user