From a1f151a79b1d207df26d3b64cf20ac2738b69d98 Mon Sep 17 00:00:00 2001 From: Staroselskii Georgii Date: Fri, 8 Jul 2016 16:16:11 +0300 Subject: [PATCH] AP_HAL_Linux: do not create unnecessary consoles in UARTDriver --- libraries/AP_HAL_Linux/UARTDriver.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libraries/AP_HAL_Linux/UARTDriver.cpp b/libraries/AP_HAL_Linux/UARTDriver.cpp index ce492b5345..4312634fae 100644 --- a/libraries/AP_HAL_Linux/UARTDriver.cpp +++ b/libraries/AP_HAL_Linux/UARTDriver.cpp @@ -61,19 +61,21 @@ void UARTDriver::begin(uint32_t b) void UARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS) { - if (device_path == NULL && _console) { - _device = new ConsoleDevice(); - } else if (!_initialised) { - if (device_path == NULL) { - return; - } - - _device = _parseDevicePath(device_path); - - if (!_device.get()) { - ::fprintf(stderr, "Argument is not valid. Fallback to console.\n" - "Launch with --help to see an example.\n"); + if (!_initialised) { + if (device_path == NULL && _console) { _device = new ConsoleDevice(); + } else { + if (device_path == NULL) { + return; + } + + _device = _parseDevicePath(device_path); + + if (!_device.get()) { + ::fprintf(stderr, "Argument is not valid. Fallback to console.\n" + "Launch with --help to see an example.\n"); + _device = new ConsoleDevice(); + } } }