first commit
This commit is contained in:
24
i2c_scan.sh
Executable file
24
i2c_scan.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# i2c_scan_all.sh - 扫描当前系统所有 I2C 总线上的设备
|
||||
|
||||
set -e
|
||||
|
||||
if ! command -v i2cdetect >/dev/null 2>&1; then
|
||||
echo "未找到 i2cdetect,请先安装 i2c-tools:"
|
||||
echo " sudo apt install i2c-tools"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "列出 I2C 总线:"
|
||||
i2cdetect -l
|
||||
echo
|
||||
|
||||
buses=$(i2cdetect -l | awk '{print $1}' | sed 's/i2c-//')
|
||||
|
||||
for bus in $buses; do
|
||||
echo "==============================="
|
||||
echo "扫描 I2C bus $bus (/dev/i2c-$bus)"
|
||||
echo "==============================="
|
||||
i2cdetect -y "$bus"
|
||||
echo
|
||||
done
|
||||
Reference in New Issue
Block a user