QC.SCAN

I2C multiplexer scanner for detecting sensors across all MUX channels.

Iterates through all four I2C MUX channels, runs i2cdetect on each, and cross-references discovered addresses against a known sensor map (sensorList) to produce a summary table showing sensor names, expected vs. actual channels, and detection status. This is primarily a factory-floor diagnostic helper used to confirm that every I2C peripheral on an Oizom mainboard is responding on the correct MUX leg.

Example

Run directly from the project root to perform a full bus sweep:

$ python -m QC.SCAN  # doctest: +SKIP

Note

Requires the i2cdetect utility (i2c-tools) and read access to /dev/i2c-*. Switching MUX channels uses drivers.gpio.gpio.select_I2C(), which drives MUX-select GPIOs on the host Raspberry Pi.

Attributes

Functions

detect_i2c_addresses(→ list[int])

Detect all responding I2C addresses on the specified bus.

scan_i2c_mux(→ None)

Scan all four I2C MUX channels and print a sensor detection report.

Module Contents

QC.SCAN.detect_i2c_addresses(bus_number: int = 0) list[int][source]

Detect all responding I2C addresses on the specified bus.

Shells out to i2cdetect -y <bus_number> and parses the resulting grid into a list of integers. Cells marked -- are skipped, and only acknowledged addresses are returned.

Parameters:

bus_number – I2C bus number passed to i2cdetect -y. Defaults to 0 which corresponds to /dev/i2c-0 on the Pi.

Returns:

List of integer I2C addresses (7-bit) that acknowledged during the scan. Returns an empty list if i2cdetect fails.

Raises:

subprocess.CalledProcessError – Caught internally and logged; the function returns [] in that case rather than re-raising.

Example

Sweep bus 0 and print the discovered addresses in hex:

>>> for addr in detect_i2c_addresses(0):
...     print(hex(addr))

Note

Requires i2c-tools to be installed on the host. The current process must also have permission to read /dev/i2c-<bus>, which usually means membership in the i2c group or running as root.

QC.SCAN.scan_i2c_mux() None[source]

Scan all four I2C MUX channels and print a sensor detection report.

For each of the four MUX channels (0-3) this routine switches the multiplexer via drivers.gpio.gpio.select_I2C(), calls detect_i2c_addresses() to enumerate live peripherals, and finally compares the results against sensorList. A formatted plain-text table is printed to stdout summarising channel, address, sensor name, and a Status column that flags expected hits, relocations, and unknown devices.

Returns:

None. Output is rendered to stdout for human inspection.

Raises:

OSError – If switching MUX channels via GPIO fails (propagated from drivers.gpio.gpio).

Example

Run a full scan from a Python REPL on the device:

>>> scan_i2c_mux()

Note

This function is hardware-only and will not produce meaningful output when executed on a development workstation. Must be run with sufficient privileges to manipulate GPIO and the I2C bus.

QC.SCAN.sensorList