mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 14:47:44 +08:00
fix(platforms/i2c): report current bus, not filter, in iterator external() (#27346)
I2CBusIterator::external() was returning px4_i2c_bus_external(_bus), where _bus is the constructor filter argument (the user's -b value, which defaults to -1 when no bus is specified). When a driver was started with -I and no -b (e.g. iis2mdc -I start, bmp388 -I start), _bus stayed -1, px4_i2c_bus_external(-1) fell through to its "not found" fallback that returns true, and the boot log printed "on I2C bus 4 (external)" for sensors sitting on an internal bus. Pass bus().bus instead so the result reflects the bus the iterator is currently positioned on. This mirrors SPIBusIterator::external() and restores the pre-8080ca966a8 semantics. Device::external() (the override used by sensors status and calibration) already used the device id's bus number, so only the boot-time print was wrong. Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
int externalBusIndex() const { return _external_bus_counter; }
|
||||
|
||||
bool external() const { return px4_i2c_bus_external(_bus); }
|
||||
bool external() const { return px4_i2c_bus_external(bus().bus); }
|
||||
|
||||
private:
|
||||
const FilterType _filter;
|
||||
|
||||
Reference in New Issue
Block a user