mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-18 06:38:29 -04:00
SerialManager: use instance in find_baudrate
This commit is contained in:
parent
9b3656e77c
commit
89a50b99bb
@ -187,13 +187,19 @@ AP_HAL::UARTDriver *AP_SerialManager::find_serial(enum SerialProtocol protocol,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find_baudrate - searches available serial ports for the first instance that allows the given protocol
|
// find_baudrate - searches available serial ports for the first instance that allows the given protocol
|
||||||
|
// instance should be zero if searching for the first instance, 1 for the second, etc
|
||||||
// returns baudrate on success, 0 if a serial port cannot be found
|
// returns baudrate on success, 0 if a serial port cannot be found
|
||||||
uint32_t AP_SerialManager::find_baudrate(enum SerialProtocol protocol) const
|
uint32_t AP_SerialManager::find_baudrate(enum SerialProtocol protocol, uint8_t instance) const
|
||||||
{
|
{
|
||||||
|
uint8_t found_instance = 0;
|
||||||
|
|
||||||
// search for matching protocol
|
// search for matching protocol
|
||||||
for(uint8_t i=0; i<SERIALMANAGER_NUM_PORTS; i++) {
|
for(uint8_t i=0; i<SERIALMANAGER_NUM_PORTS; i++) {
|
||||||
if ((enum SerialProtocol)state[i].protocol.get() == protocol) {
|
if ((enum SerialProtocol)state[i].protocol.get() == protocol) {
|
||||||
return map_baudrate(state[i].baud);
|
if (found_instance == instance) {
|
||||||
|
return map_baudrate(state[i].baud);
|
||||||
|
}
|
||||||
|
found_instance++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,9 @@ public:
|
|||||||
AP_HAL::UARTDriver *find_serial(enum SerialProtocol protocol, uint8_t instance) const;
|
AP_HAL::UARTDriver *find_serial(enum SerialProtocol protocol, uint8_t instance) const;
|
||||||
|
|
||||||
// find_baudrate - searches available serial ports for the first instance that allows the given protocol
|
// find_baudrate - searches available serial ports for the first instance that allows the given protocol
|
||||||
|
// instance should be zero if searching for the first instance, 1 for the second, etc
|
||||||
// returns the baudrate of that protocol on success, 0 if a serial port cannot be found
|
// returns the baudrate of that protocol on success, 0 if a serial port cannot be found
|
||||||
uint32_t find_baudrate(enum SerialProtocol protocol) const;
|
uint32_t find_baudrate(enum SerialProtocol protocol, uint8_t instance) const;
|
||||||
|
|
||||||
// get_mavlink_channel - provides the mavlink channel associated with a given protocol (and instance)
|
// get_mavlink_channel - provides the mavlink channel associated with a given protocol (and instance)
|
||||||
// instance should be zero if searching for the first instance, 1 for the second, etc
|
// instance should be zero if searching for the first instance, 1 for the second, etc
|
||||||
|
Loading…
Reference in New Issue
Block a user