AP_SerialManager: add support for fetching serial port by id

This commit is contained in:
Siddharth Purohit 2019-01-04 17:51:05 +08:00 committed by Andrew Tridgell
parent 32a71cef92
commit 3a46fb59e5
2 changed files with 13 additions and 1 deletions

View File

@ -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)
{

View File

@ -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[];