I.MX6 Android Linux shell MMPF0100 i2c 获取数据
2016-04-01 20:17
405 查看
#!/system/bin/busybox ash # # I.MX6 Android Linux shell MMPF0100 i2c 获取数据 # 说明: # 本文主要记录通过shell脚本来获取MMPF0100的数据,更多的是为了更为 # 方便的获取到数据,在进行一些调试的时候能够更有效。 # # 2016-4-1 深圳 南山平山村 曾剑锋 # # 检查参数个数 if [ $# -lt 3 ]; then echo "USAGE:" echo " i2cData.sh <curPage> <firstAddress(hex)> <byteCount(hex)>" exit 1 fi curPage=$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 ];then busybox printf "\n0x%x0 " $((i/16)) firstLine=false else # 用于填充一行前面的0,更多的方便16进制查看数据 if $firstLine ;then padZero=$((i%16)) busybox printf "\n0x%x0 " $padZero # 循环填充数据 j=0 while [ $j -lt $padZero ] do busybox printf " 00" j=$((j+1)) done firstLine=false fi fi # 读取数据 data=`./i2cget -f -y $i2cBusNumber $deviceAdress $i` busybox printf " %02x" $data i=$((i+1)) done echo # 输出结果: # 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 #
相关文章推荐
- .bash_profile
- 认识与学习bash
- 用代码定位硬盘上的文件(使用ShellExecute执行explorer /select命令,其它参数也很全)
- React Native (Mac) 终端修改 ~/.bashrc, ~/.profile, ~/.zshrc
- A implementation of a simple unix-like shell with pure c
- PowerShell 5.0和跨平台PowerShell支持class类编程
- ShellExecuteEx启动WORD进程关不掉的处理
- shell基本语法及应用
- impala-shell基本命令
- 使用jq工具在Shell命令行处理JSON数据
- shell文本处理
- adb shell中设置android系统内部环境变量!
- shell脚本中的if参数
- SSH Secure Shell Client远程登录Linux
- Linux用shell脚本监控网站运行状态并发告警邮件
- 使用shell脚本往数据库批量插入数据和执行sql
- [转载]Linux login、non-login shell以及su,sudo相关概念
- [转载]Linux中profile、bashrc、bash_profile之间的区别和联系
- hadoop Shell命令详解
- shell之wget