i2c¶
Probes the I2C device.
Function Arguments¶
Name |
Type |
Description |
---|---|---|
bus_number |
str, None |
(optional; default: |
bus_path |
str, None |
(optional; default: |
bus_name |
str, None |
(optional; default: |
addr |
str, None |
(optional; default: |
use_r_flag |
bool |
(optional; default: |
Description¶
This function probes a specific bus/address to check whether an I2C device is connected there or not.
The probed result for a single I2C device is a dictionary which contains
at least two entries, one is bus_number
and the other one is addr
.
Examples¶
Let’s say we’ve already known that the address of I2C camera X is 0x24 but we don’t know which bus that camera is connected. A not 100% reliable way to verify whether camera X is installed or not on the device is to write the probe statement
{
"eval": {
"i2c": {
"addr": "0x24"
}
}
}
The function will try to probe address 0x24
on all I2C buses. If camera
X is found at bus 2, we will have below probed results:
[
{
"addr": "0x24",
"bus_number": "2"
}
]
Otherwise the probed results might be just an empty list. Howerver, it’s
possible that another I2C device has the address number 0x24
on another
bus too. In this case, the probe statement above will lead to a false
positive result.