I.MX6 Android Linux shell MMPF0100 i2c 获取数据
生活随笔
收集整理的這篇文章主要介紹了
I.MX6 Android Linux shell MMPF0100 i2c 获取数据
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#!/system/bin/busybox ash#
# I.MX6 Android Linux shell MMPF0100 i2c 獲取數據
# 說明:
# 本文主要記錄通過shell腳本來獲取MMPF0100的數據,更多的是為了更為
# 方便的獲取到數據,在進行一些調試的時候能夠更有效。
#
# 2016-4-1 深圳 南山平山村 曾劍鋒
## 檢查參數個數
if [ $# -lt 3 ]; thenecho "USAGE:"echo " i2cData.sh <curPage> <firstAddress(hex)> <byteCount(hex)>"exit 1
ficurPage=$1 # 從第幾頁開始獲取
byteCount=$(($3)) # 一次獲取多少個字節
firstAddress=$(($2)) # 獲取字節的首地址i2cBusNumber=1 # 采用哪個i2c總線
deviceAdress="0x08" # i2c設備地址
pageRegAddress="0x7f" # 存放頁的寄存器地址# 設置MMPF0100地址頁
./i2cset -f -y $i2cBusNumber $deviceAdress $pageRegAddress $curPage # 顯示一些參數
echo " currentPage : $curPage"
echo " firstAddress : $firstAddress"
echo " byteCount : $byteCount"
echo " i2cBus : /dev/dev-i2c$i2cBusNumber"
echo " deviceAdress : $deviceAdress"
echo "pageRegAddress : $pageRegAddress"
echo # 顯示行對應的數
busybox printf " 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"
echo# i是計數變量
i=$firstAddress
firstLine=true # 用于判斷第一行是否需要填充0
while [ $i -lt $(($byteCount+$firstAddress)) ]
do# 16個字節一行,換行并輸出行號if [ $((i%16)) -eq 0 ];thenbusybox printf "\n0x%x0 " $((i/16)) firstLine=falseelse# 用于填充一行前面的0,更多的方便16進制查看數據if $firstLine ;thenpadZero=$((i%16))busybox printf "\n0x%x0 " $padZero# 循環填充數據j=0while [ $j -lt $padZero ]dobusybox printf " 00" j=$((j+1))donefirstLine=falsefifi# 讀取數據data=`./i2cget -f -y $i2cBusNumber $deviceAdress $i`busybox printf " %02x" $datai=$((i+1))
doneecho# 輸出結果:
# root@android:/data/local # ./i2cData.sh 0 0x10 0x50
# currentPage : 0
# firstAddress : 16
# byteCount : 80
# i2cBus : /dev/dev-i2c1
# deviceAdress : 0x08
# pageRegAddress : 0x7f
#
# 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
#
# 0x10 00 00 3f 00 00 00 00 00 00 00 00 10 00 00 00 00
# 0x20 2b 1b 2b 0c c4 00 00 00 00 00 00 00 00 00 2b 1b
# 0x30 2b 0c c4 00 00 72 72 72 0c d4 00 00 2c 2c 2c 0c
# 0x40 e4 00 00 2c 2c 2c 0c e4 00 00 6f 6f 6f 0c f4 00
# 0x50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# root@android:/data/local #
?
總結
以上是生活随笔為你收集整理的I.MX6 Android Linux shell MMPF0100 i2c 获取数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: yield return关键字怎么使用?
- 下一篇: linux ssh基本