Files
Jacob Dahl 239947a100 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>
2026-05-15 19:19:59 -06:00
..