diff --git a/libraries/AP_SerialManager/AP_SerialManager.cpp b/libraries/AP_SerialManager/AP_SerialManager.cpp index 49291998c2..a4a0f7b2bf 100644 --- a/libraries/AP_SerialManager/AP_SerialManager.cpp +++ b/libraries/AP_SerialManager/AP_SerialManager.cpp @@ -437,6 +437,15 @@ AP_SerialManager::SerialProtocol AP_SerialManager::get_mavlink_protocol(mavlink_ return SerialProtocol_None; } +// get_serial_by_id - gets serial by serial id +AP_HAL::UARTDriver *AP_SerialManager::get_serial_by_id(uint8_t id) +{ + if (id < SERIALMANAGER_NUM_PORTS) { + return state[id].uart; + } + return nullptr; +} + // set_blocking_writes_all - sets block_writes on or off for all serial channels void AP_SerialManager::set_blocking_writes_all(bool blocking) { diff --git a/libraries/AP_SerialManager/AP_SerialManager.h b/libraries/AP_SerialManager/AP_SerialManager.h index ed482ac5de..fa395d9117 100644 --- a/libraries/AP_SerialManager/AP_SerialManager.h +++ b/libraries/AP_SerialManager/AP_SerialManager.h @@ -146,7 +146,10 @@ public: // disable passthru by settings SERIAL_PASS2 to -1 void disable_passthru(void); - + + // get Serial Port + AP_HAL::UARTDriver *get_serial_by_id(uint8_t id); + // parameter var table static const struct AP_Param::GroupInfo var_info[];