i2c  1.4.2
RoadNarrows Robotics I2C Package
i2cmon.sh
1 #
2 # Example Shell Program using the I2C commands.
3 #
4 # Usage: i2cmon.sh addr readlen byte1 [byte2 ...]
5 #
6 addr=$1
7 readlen=$2
8 shift 2
9 
10 if ! ./i2ccheck --address "$addr"
11 then
12  echo "I2C device $addr not found" >&2
13  ./i2cscan --verbose >&2
14  exit 2
15 fi
16 
17 while :
18 do
19  rsp=$(./i2ctrans --fd 3 --address $addr --count $readlen $*)
20  echo $rsp
21  sleep 1
22 done 3<>/dev/i2c/0
23