I.MX6 Android Linux shell MMPF0100 i2c 获取数据
#!/system/bin/busybox ash #
# I.MX6 Android Linux shell MMPF0100 i2c 获取数据
# 说明:
# 本文主要记录通过shell脚本来获取MMPF0100的数据,更多的是为了更为
# 方便的获取到数据,在进行一些调试的时候能够更有效。
#
# -- 深圳 南山平山村 曾剑锋
# # 检查参数个数
if [ $# -lt ]; then
echo "USAGE:"
echo " i2cData.sh <curPage> <firstAddress(hex)> <byteCount(hex)>"
exit
fi curPage=$ # 从第几页开始获取
byteCount=$(($)) # 一次获取多少个字节
firstAddress=$(($)) # 获取字节的首地址 i2cBusNumber= # 采用哪个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%)) -eq ];then
busybox printf "\n0x%x0 " $((i/))
firstLine=false
else
# 用于填充一行前面的0,更多的方便16进制查看数据
if $firstLine ;then
padZero=$((i%))
busybox printf "\n0x%x0 " $padZero # 循环填充数据
j=
while [ $j -lt $padZero ]
do
busybox printf ""
j=$((j+)) done
firstLine=false
fi
fi # 读取数据
data=`./i2cget -f -y $i2cBusNumber $deviceAdress $i`
busybox printf " %02x" $data i=$((i+))
done echo # 输出结果:
# root@android:/data/local # ./i2cData.sh 0x10 0x50
# currentPage :
# firstAddress :
# byteCount :
# i2cBus : /dev/dev-i2c1
# deviceAdress : 0x08
# pageRegAddress : 0x7f
#
# 0A 0B 0C 0D 0E 0F
#
# 0x10 3f
# 0x20 2b 1b 2b 0c c4 2b 1b
# 0x30 2b 0c c4 0c d4 2c 2c 2c 0c
# 0x40 e4 2c 2c 2c 0c e4 6f 6f 6f 0c f4
# 0x50
# root@android:/data/local #
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脚本来设置 ...
- I.MX6 Android Linux UART send receive with multi-thread and multi-mode demo
/******************************************************************************************* * I.MX6 ...
- android linux shell 日期设置
/************************************************************************ android linux shell 日期设置 * ...
- I.MX6 Android shutdown shell command
/******************************************************************************* * I.MX6 Android shu ...
- Linux shell自动读mongo数据、远程获取文件大小示例脚本
1.示例1 功能:对mongoDB导出数据,根据sid的不同状态进行统计 技术点:shell bash 读写文件.字符串截取.函数.用多个文件提到的map.grep查找并赋值给变量 #!/bin/b ...
- Linux Shell脚本中获取本机ip地址方法
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" 命令解释 ...
- linux shell通过curl获取HTTP请求的状态码
直接上代码: curl -I -m -o /dev/null -s -w %{http_code} www.baidu.com 参数说明: -I 仅测试HTTP头 -m 10 最多查询10s -o / ...
- android与c#之间scoket获取数据进行赋值显示的问题
Android端发送的信息为:“手机号码,低压,高压,心率”. 需要实时的将接收到的信息显示到“数据栏”中,但是在执行监听任务的时候,启用了一个主线程,在接收数据的时候直接将数值复制给文本框会出现错误 ...
- linux shell获取键盘输入
linux shell从键盘获取输入 代码1: #!/bin/bash #提示“Input your choice:”,把用户的输入保存入变量choice_user中read -p "Inp ...
随机推荐
- wxPython 基本框架与运行原理 -- App 与 Frame
<wxPython in Action> chapter 1.2 笔记 wxPython 是 wxWidgets 的 Python 实现,“w” for Microsoft Windows ...
- Microsoft Visual Studio Ultimate 2013 旗舰版 有效注册密钥
Visual Studio Ultimate 2013 KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9 Visual Studio Premium 2013 KEY(密钥) ...
- Invalid argument supplied for foreach()
将需要被遍历的数组强制转换为数组类型即可 <?php $array = null; foreach((array)$array as $value){ #..code.... } ?>
- webx学习笔记
Webx学习笔记周建旭 2014-08-01 Webx工作流程 图 3.2. Webx Framework如何响应请求 当Webx Framework接收到一个来自WEB的请求以后,实际上它主要做了两 ...
- 过长文字自动换行的技巧 Word-Break Word-Wrap
在很多时候,为了防止内容过长把表格或容器撑破, 我们都需要为容器加上自动换行的功能. 实现自动换行,用CSS来实现,通常有两种方式: word-break: 取值为 normal, break-all ...
- 1305: [CQOI2009]dance跳舞 - BZOJ
Description 一次舞会有n个男孩和n个女孩.每首曲子开始时,所有男孩和女孩恰好配成n对跳交谊舞.每个男孩都不会和同一个女孩跳两首(或更多)舞曲.有一些男孩女孩相互喜欢,而其他相互不喜欢(不会 ...
- 原生js获取window高和宽
视口的宽和高 var pw = window.innerWidth, ph = window.innerHeight; if(typeof pw != "number"){ pw ...
- 【leetcode】Trapping Rain Water(hard)
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...
- HDU4720+三角形外接圆
/* 几何 求给定三角形的外接圆圆心 方法:求解二元方程组 */ #include<stdio.h> #include<string.h> #include<math.h ...
- UrlRewriteFilter 美化器的使用方法 伪静态化的解决方案(转)
一,URL美化器简介 UrlRewriteFilter是一个用于改写URL的Web过滤器,类似于Apache的mod_rewrite.适用于任何Web应用服务器(如Resin,Orion,Tomcat ...