<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cyher.NET &#187; GNU/linux</title>
	<atom:link href="http://cyher.net/category/gnulinux/feed" rel="self" type="application/rss+xml" />
	<link>http://cyher.net</link>
	<description>Technology, Life, Code, OpenSource, *nix, Mac and iphone, Mobile development</description>
	<lastBuildDate>Sun, 25 Jul 2010 08:43:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Android 手机电源管理实例 &#8211; milestone</title>
		<link>http://cyher.net/gnulinux/android/android-phone-powermanagement</link>
		<comments>http://cyher.net/gnulinux/android/android-phone-powermanagement#comments</comments>
		<pubDate>Sun, 25 Jul 2010 08:07:59 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[milestone]]></category>
		<category><![CDATA[power management]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637064</guid>
		<description><![CDATA[
	标签：android, linux, milestone, power management

	相关日志
	
	android驱动之虚拟按键 (0)
	android驱动之jogball (2)
	自己的嵌入式学习经验, 想不到别人给拍成视频了 (0)
	自己曾经作过的小实验 (0)
	科技是一种信仰(apple&#038;linux) (5)


]]></description>
			<content:encoded><![CDATA[
<table id="wp-table-reloaded-id-1-no-1" class="wp-table-reloaded wp-table-reloaded-id-1">
<thead>
	<tr class="row-1 odd">
		<th class="column-1"></th><th class="column-2">MOTO Milestone (omap)</th><th class="column-3">HTC tattoo (msm7225)</th><th class="column-4">HTC Magic (msm7201A)</th><th class="column-5">某手机(保密)(msm7227)</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">开机过程</td><td class="column-2">200ma-1000ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5">200ma-500ma</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">HSDPA 联网</td><td class="column-2">700ma</td><td class="column-3"></td><td class="column-4">500ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">idle, 屏幕最暗, 黑色背景,键灯关</td><td class="column-2">44ma</td><td class="column-3">13ma</td><td class="column-4">33ma</td><td class="column-5">60ma</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1">idle, 屏幕中等, 黑色背景,键灯关</td><td class="column-2">69ma</td><td class="column-3">64ma</td><td class="column-4">73ma</td><td class="column-5">88ma</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1">idle, 屏幕最亮, 黑色背景,键灯关</td><td class="column-2">104ma</td><td class="column-3">97ma</td><td class="column-4">135ma</td><td class="column-5">120ma</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1">idle, 屏幕最暗, 动态桌面,键灯关</td><td class="column-2">330ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-8 even">
		<td class="column-1">idle, 屏幕中等, 动态桌面,键灯关</td><td class="column-2">350ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-9 odd">
		<td class="column-1">idle, 屏幕最亮, 动态桌面,键灯关</td><td class="column-2">450ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-10 even">
		<td class="column-1">idle, 屏幕最暗, 白背景,键灯关</td><td class="column-2">51ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-11 odd">
		<td class="column-1">idle, 屏幕中等, 白背景,键灯关</td><td class="column-2">92ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-12 even">
		<td class="column-1">idle, 屏幕最亮, 白背景,键灯关</td><td class="column-2">167ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-13 odd">
		<td class="column-1">照相机预览</td><td class="column-2">400ma-500ma(1G)<br />
325ma-350ma(550M)</td><td class="column-3">210ma-260ma</td><td class="column-4">295ma-334ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-14 even">
		<td class="column-1">录制音频(开屏)</td><td class="column-2">107ma-112ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-15 odd">
		<td class="column-1">录制音频(关屏)</td><td class="column-2">43ma-59ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-16 even">
		<td class="column-1">录制视频</td><td class="column-2">500ma-700ma(1G)<br />
427ma-558ma(550M)</td><td class="column-3">260ma-360ma</td><td class="column-4">360ma-390ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-17 odd">
		<td class="column-1">google maps(gps开)</td><td class="column-2">540ma-750ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-18 even">
		<td class="column-1">浏览网页(HSDPA)(有数据链接时)</td><td class="column-2">400ma-600ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-19 odd">
		<td class="column-1">浏览网页(EDGE)(有数据链接时)</td><td class="column-2">200ma-500ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-20 even">
		<td class="column-1">开屏,放mp3,耳机</td><td class="column-2">90ma-120ma</td><td class="column-3"></td><td class="column-4">168ma-220ma</td><td class="column-5">285ma</td>
	</tr>
	<tr class="row-21 odd">
		<td class="column-1">关屏, 放mp3,耳机</td><td class="column-2">30ma-50ma</td><td class="column-3"></td><td class="column-4">93ma-112ma</td><td class="column-5">210ma</td>
	</tr>
	<tr class="row-22 even">
		<td class="column-1">开屏, 放mp4,耳机(放自己拍摄的)</td><td class="column-2">250ma-300ma</td><td class="column-3"></td><td class="column-4">300ma-327ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-23 odd">
		<td class="column-1">开启g-sensro和gps</td><td class="column-2">320ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-24 even">
		<td class="column-1">wifi扫描时</td><td class="column-2">150ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-25 odd">
		<td class="column-1">开led闪光灯(长亮)</td><td class="column-2">50ma(单独计算)</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-26 even">
		<td class="column-1">虚拟按键led</td><td class="column-2">20ma(单独计算)</td><td class="column-3">14ma</td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-27 odd">
		<td class="column-1">GSM通话(开接近)</td><td class="column-2">350ma-450ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-28 even">
		<td class="column-1">suspend(关屏进入休眠)</td><td class="column-2">2ma</td><td class="column-3">1ma</td><td class="column-4">1ma</td><td class="column-5">2ma</td>
	</tr>
</tbody>
</table>


	标签：<a href="http://cyher.net/tag/android" title="android" rel="tag">android</a>, <a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/milestone" title="milestone" rel="tag">milestone</a>, <a href="http://cyher.net/tag/power-management" title="power management" rel="tag">power management</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/android/virualkey" title="android驱动之虚拟按键 (2010年03月22号)">android驱动之虚拟按键</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/android/android-driver-jogball" title="android驱动之jogball (2010年03月16号)">android驱动之jogball</a> (2)</li>
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/android/android-phone-powermanagement/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>macbook pro ubuntu10.4 bcm无线网卡问题修复</title>
		<link>http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver</link>
		<comments>http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver#comments</comments>
		<pubDate>Sun, 02 May 2010 13:03:00 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637057</guid>
		<description><![CDATA[话说虽然用了macbook pro成了apple fan但是也没有使我对linux的热情衰减， 这不刚刚把macbook pro上的9.10升级为10.4， 这回我相信ubuntu的自动升级能力，但是结果是，我不应该像要求mac os x一样要求 ubuntu。 有几个东西不能用了，但是那也无关紧要，最要命的使我的wireless的驱动没了，装不上了，靠。这个我受不了。找到了以下解决方法。
首先，说明一点，我的电脑是macbook pro 471，就是macbook pro 5,1.
本来是应该这样解决的
System-&#62;Administration-&#62;Hardware Drivers. Select the Broadcom STA options and click enable.
但是现在不行了。
1. 下载broadcom驱动源码，http://www.broadcom.com/support/802.11/linux_sta.php
2. 解压，然后找到 src/wl/sys/wl_linux.c 这个文件
3. 在 #include &#60;XX.h&#62;的下面一行加上下面的代码
#include &#60;﻿linux/sched.h&#62;
4. 编译源码  make
5.把新编译的driver放到lib中
sudo mv wl.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless
6. 更新依赖关系
sudo depmod -a
7. ok 加入内核
modprobe wl
8. 如果编译报 没有include &#60;linux/sched.h&#62; 加入新的内核头文件。
sudo apt-get install linux-headers-$(uname -r)
到这里基本上就ok了 可以继续自由自在了，至于以后升级内核从新来一遍就ok

	标签：driver, linux, macbook, ubuntu, [...]]]></description>
			<content:encoded><![CDATA[<p>话说虽然用了macbook pro成了apple fan但是也没有使我对linux的热情衰减， 这不刚刚把macbook pro上的9.10升级为10.4， 这回我相信ubuntu的自动升级能力，但是结果是，我不应该像要求mac os x一样要求 ubuntu。 有几个东西不能用了，但是那也无关紧要，最要命的使我的wireless的驱动没了，装不上了，靠。这个我受不了。找到了以下解决方法。</p>
<p>首先，说明一点，我的电脑是macbook pro 471，就是macbook pro 5,1.</p>
<p>本来是应该这样<a href="https://help.ubuntu.com/community/MacBookPro5-1_5-2/Lucid#Wireless">解决</a>的</p>
<blockquote><p>System-&gt;Administration-&gt;Hardware Drivers. Select the Broadcom STA options and click enable.</p></blockquote>
<p>但是现在不行了。</p>
<p>1. 下载broadcom驱动源码，<a href="http://www.broadcom.com/support/802.11/linux_sta.php" target="_blank">http://www.broadcom.com/support/802.11/linux_sta.php</a></p>
<p>2. 解压，然后找到 src/wl/sys/wl_linux.c 这个文件</p>
<p>3. 在 #include &lt;XX.h&gt;的下面一行加上下面的代码</p>
<p><code>#include &lt;﻿linux/sched.h&gt;</code></p>
<p>4. 编译源码  make</p>
<p>5.把新编译的driver放到lib中</p>
<p><code>sudo mv wl.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless</code></p>
<p>6. 更新依赖关系</p>
<p><code>sudo depmod -a</code></p>
<p>7. ok 加入内核<br />
modprobe wl<br />
8. 如果编译报 没有include &lt;linux/sched.h&gt; 加入新的内核头文件。</p>
<p><code>sudo apt-get install linux-headers-$(uname -r)</code></p>
<p>到这里基本上就ok了 可以继续自由自在了，至于以后升级内核从新来一遍就ok</p>

	标签：<a href="http://cyher.net/tag/driver" title="driver" rel="tag">driver</a>, <a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/macbook" title="macbook" rel="tag">macbook</a>, <a href="http://cyher.net/tag/ubuntu" title="ubuntu" rel="tag">ubuntu</a>, <a href="http://cyher.net/tag/wireless" title="wireless" rel="tag">wireless</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/apple/multi-os-on-macbook" title="在macbook上安装各种操作系统 (2009年07月26号)">在macbook上安装各种操作系统</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/bad_cheese_linux" title="变质的奶酪,linux! (2009年01月18号)">变质的奶酪,linux!</a> (2)</li>
	<li><a href="http://cyher.net/gnulinux/android/virualkey" title="android驱动之虚拟按键 (2010年03月22号)">android驱动之虚拟按键</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/android/android-driver-jogball" title="android驱动之jogball (2010年03月16号)">android驱动之jogball</a> (2)</li>
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android驱动之虚拟按键</title>
		<link>http://cyher.net/gnulinux/android/virualkey</link>
		<comments>http://cyher.net/gnulinux/android/virualkey#comments</comments>
		<pubDate>Mon, 22 Mar 2010 03:09:57 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[virualkey]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637050</guid>
		<description><![CDATA[1    背景
nexus one工业设计简洁，类似于iphone只有一个按键的设计，只有中间的一个轨迹球。但是android标准键盘是有 HOME，MENU，BACK，SEARCH等，但是同时要保持工业设计。nexus one是这样解决问题的，显示屏是800X480，但是在电容触摸屏是8xx*480的就是比800要大的地方就变成了虚拟按键，模拟了android标准按键。
2    方案
要实现，虚拟按键，在android里面是靠两层协助实现，底层要把虚拟按键在比显示屏多出的地方规定好虚拟按键的位置大小以及键值等，给上层一文件接口。上层java层启动一个服务来读取这一区域的按键响应，这样就是大体的架构。具体实现如下：
2.1    底层虚拟按键功能实现方案
简而言之，就是在内核中把虚拟按键的所有信息给上层给出，用什么方式？就是用sys文件系统的方式，sys文件系统的路径是约定好的所以代码如下实现。给出信息的协议格式是一段连续的字符串，每个按键有六项分别用冒号分割，按键按键之间也是用冒号分割，六项按顺序分别是：
键类型:键值:按键区域中心x坐标:按键区域中心y坐标:按键区域宽:按键区域高
arch/arm/mach-msm/board-mahimahi.c

static ssize_t mahimahi_virtual_keys_show&#40;struct kobject *kobj,
			       struct kobj_attribute *attr, char *buf&#41;
&#123;
	if &#40;system_rev &#38;gt; 2&#41; &#123;
		/* center: x: back: 55, menu: 172, home: 298, search 412, y: 835 */
		return sprintf&#40;buf,
			__stringify&#40;EV_KEY&#41; &#34;:&#34; __stringify&#40;KEY_BACK&#41;  &#34;:55:835:90:55&#34;
		   &#34;:&#34; __stringify&#40;EV_KEY&#41; &#34;:&#34; __stringify&#40;KEY_MENU&#41;   &#34;:172:835:125:55&#34;
		   [...]]]></description>
			<content:encoded><![CDATA[<h1>1    背景</h1>
<p>nexus one工业设计简洁，类似于iphone只有一个按键的设计，只有中间的一个轨迹球。但是android标准键盘是有 HOME，MENU，BACK，SEARCH等，但是同时要保持工业设计。nexus one是这样解决问题的，显示屏是800X480，但是在电容触摸屏是8xx*480的就是比800要大的地方就变成了虚拟按键，模拟了android标准按键。</p>
<h1>2    方案</h1>
<p>要实现，虚拟按键，在android里面是靠两层协助实现，底层要把虚拟按键在比显示屏多出的地方规定好虚拟按键的位置大小以及键值等，给上层一文件接口。上层java层启动一个服务来读取这一区域的按键响应，这样就是大体的架构。具体实现如下：</p>
<h3>2.1    底层虚拟按键功能实现方案</h3>
<p>简而言之，就是在内核中把虚拟按键的所有信息给上层给出，用什么方式？就是用sys文件系统的方式，sys文件系统的路径是约定好的所以代码如下实现。给出信息的协议格式是一段连续的字符串，每个按键有六项分别用冒号分割，按键按键之间也是用冒号分割，六项按顺序分别是：</p>
<p><code>键类型:键值:按键区域中心x坐标:按键区域中心y坐标:按键区域宽:按键区域高</code></p>
<p>arch/arm/mach-msm/board-mahimahi.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> ssize_t mahimahi_virtual_keys_show<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> kobject <span style="color: #339933;">*</span>kobj<span style="color: #339933;">,</span>
			       <span style="color: #993333;">struct</span> kobj_attribute <span style="color: #339933;">*</span>attr<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buf<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>system_rev <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/* center: x: back: 55, menu: 172, home: 298, search 412, y: 835 */</span>
		<span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span>buf<span style="color: #339933;">,</span>
			__stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_BACK<span style="color: #009900;">&#41;</span>  <span style="color: #ff0000;">&quot;:55:835:90:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_MENU<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:172:835:125:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_HOME<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:298:835:115:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_SEARCH<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:412:835:95:55&quot;</span>
		   <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/* center: x: home: 55, menu: 185, back: 305, search 425, y: 835 */</span>
		<span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span>buf<span style="color: #339933;">,</span>
			__stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_HOME<span style="color: #009900;">&#41;</span>  <span style="color: #ff0000;">&quot;:55:835:70:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_MENU<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:185:835:100:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_BACK<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:305:835:70:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_SEARCH<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:425:835:70:55&quot;</span>
		   <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> kobj_attribute mahimahi_virtual_keys_attr <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	.<span style="color: #202020;">attr</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		.<span style="color: #202020;">name</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;virtualkeys.synaptics-rmi-touchscreen&quot;</span><span style="color: #339933;">,</span>
		.<span style="color: #202020;">mode</span> <span style="color: #339933;">=</span> S_IRUGO<span style="color: #339933;">,</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	.<span style="color: #202020;">show</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mahimahi_virtual_keys_show<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> attribute <span style="color: #339933;">*</span>mahimahi_properties_attrs<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mahimahi_virtual_keys_attr.<span style="color: #202020;">attr</span><span style="color: #339933;">,</span>
	NULL
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> attribute_group mahimahi_properties_attr_group <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	.<span style="color: #202020;">attrs</span> <span style="color: #339933;">=</span> mahimahi_properties_attrs<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> kobject <span style="color: #339933;">*</span>properties_kobj<span style="color: #339933;">;</span>
&nbsp;
properties_kobj <span style="color: #339933;">=</span> kobject_create_and_add<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;board_properties&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>properties_kobj<span style="color: #009900;">&#41;</span>
	ret <span style="color: #339933;">=</span> sysfs_create_group<span style="color: #009900;">&#40;</span>properties_kobj<span style="color: #339933;">,</span>
					 <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mahimahi_properties_attr_group<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>properties_kobj <span style="color: #339933;">||</span> ret<span style="color: #009900;">&#41;</span>
	pr_err<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;failed to create board_properties<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>2.2    JAVA上层方案</h3>
<p>Java层主要是读取按键信息，然后经过一定的算法，来识别虚拟按键，基本不需要修改，但最好还是熟悉java层的架构这样出问题的时候利于定位<br />
frameworks/base/services/java/com/android/server/KeyInputQueue.java</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*这是虚拟按键的类里面包括了VirtualKey所用到的成员变量和按键定位方法*/</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> VirtualKey <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> scancode<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> centerx<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> centery<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> width<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> height<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> hitLeft<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> hitTop<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> hitRight<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> hitBottom<span style="color: #339933;">;</span>
&nbsp;
        InputDevice lastDevice<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> lastKeycode<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">boolean</span> checkHit<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> hitLeft <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> x <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> hitRight                     <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> y <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> hitTop <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> y <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> hitBottom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">void</span> computeHitRect<span style="color: #009900;">&#40;</span>InputDevice dev, <span style="color: #000066; font-weight: bold;">int</span> dw, <span style="color: #000066; font-weight: bold;">int</span> dh<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dev <span style="color: #339933;">==</span> lastDevice<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEBUG_VIRTUAL_KEYS<span style="color: #009900;">&#41;</span> Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;computeHitRect for &quot;</span> <span style="color: #339933;">+</span> scancode
                    <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: dev=&quot;</span> <span style="color: #339933;">+</span> dev <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; absX=&quot;</span> <span style="color: #339933;">+</span> dev.<span style="color: #006633;">absX</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; absY=&quot;</span> <span style="color: #339933;">+</span> dev.<span style="color: #006633;">absY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            lastDevice <span style="color: #339933;">=</span> dev<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> minx <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absX</span>.<span style="color: #006633;">minValue</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> maxx <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absX</span>.<span style="color: #006633;">maxValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> halfw <span style="color: #339933;">=</span> width<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> left <span style="color: #339933;">=</span> centerx <span style="color: #339933;">-</span> halfw<span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> right <span style="color: #339933;">=</span> centerx <span style="color: #339933;">+</span> halfw<span style="color: #339933;">;</span>
            hitLeft <span style="color: #339933;">=</span> minx <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>left<span style="color: #339933;">*</span>maxx<span style="color: #339933;">-</span>minx<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            hitRight <span style="color: #339933;">=</span> minx <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>right<span style="color: #339933;">*</span>maxx<span style="color: #339933;">-</span>minx<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> miny <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absY</span>.<span style="color: #006633;">minValue</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> maxy <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absY</span>.<span style="color: #006633;">maxValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> halfh <span style="color: #339933;">=</span> height<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> top <span style="color: #339933;">=</span> centery <span style="color: #339933;">-</span> halfh<span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> bottom <span style="color: #339933;">=</span> centery <span style="color: #339933;">+</span> halfh<span style="color: #339933;">;</span>
            hitTop <span style="color: #339933;">=</span> miny <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>top<span style="color: #339933;">*</span>maxy<span style="color: #339933;">-</span>miny<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dh<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            hitBottom <span style="color: #339933;">=</span> miny <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>bottom<span style="color: #339933;">*</span>maxy<span style="color: #339933;">-</span>miny<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dh<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">/*以下就是与底层接口的函数，如果这个函数和底层接口正常，基本上虚拟按键就能够ok*/</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> readVirtualKeys<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> deviceName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">FileInputStream</span> fis <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileInputStream</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">&quot;/sys/board_properties/virtualkeys.&quot;</span> <span style="color: #339933;">+</span> deviceName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*这里就是读取kernel给出信息的地方，也就是地层与上层接口的地方，所以整个实现的重点就是这里*/</span>
            <span style="color: #003399;">InputStreamReader</span> isr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>fis<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">BufferedReader</span> br <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span>isr, <span style="color: #cc66cc;">2048</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> str <span style="color: #339933;">=</span> br.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>str <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> it <span style="color: #339933;">=</span> str.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEBUG_VIRTUAL_KEYS<span style="color: #009900;">&#41;</span> Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;***** VIRTUAL KEYS: &quot;</span> <span style="color: #339933;">+</span> it<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> N <span style="color: #339933;">=</span> it.<span style="color: #006633;">length</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span>N<span style="color: #339933;">;</span> i<span style="color: #339933;">+=</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">&quot;0x01&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        Log.<span style="color: #006633;">w</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Unknown virtual key type at elem #&quot;</span> <span style="color: #339933;">+</span> i
                                <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #339933;">+</span> it<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                        VirtualKey sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> VirtualKey<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">scancode</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">centerx</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">centery</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">width</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">height</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEBUG_VIRTUAL_KEYS<span style="color: #009900;">&#41;</span> Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Virtual key &quot;</span>
                                <span style="color: #339933;">+</span> sb.<span style="color: #006633;">scancode</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: center=&quot;</span> <span style="color: #339933;">+</span> sb.<span style="color: #006633;">centerx</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;,&quot;</span>
                                <span style="color: #339933;">+</span> sb.<span style="color: #006633;">centery</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; size=&quot;</span> <span style="color: #339933;">+</span> sb.<span style="color: #006633;">width</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;x&quot;</span>
                                <span style="color: #339933;">+</span> sb.<span style="color: #006633;">height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        mVirtualKeys.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>sb<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">NumberFormatException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        Log.<span style="color: #006633;">w</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Bad number at region &quot;</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; in: &quot;</span>
                                <span style="color: #339933;">+</span> str, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            br.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Log.<span style="color: #006633;">i</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;No virtual keys found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Log.<span style="color: #006633;">w</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Error reading virtual keys&quot;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<h3>2.3    总结</h3>
<p>方案基本上就是这样，主要是调试工作可能需要一段时间，还有如果要做虚拟按键，还需要硬件的支持（超过显示区域的触摸屏区域）。本代码基于android 2.1请根据实际情况修改</p>

	标签：<a href="http://cyher.net/tag/android" title="android" rel="tag">android</a>, <a href="http://cyher.net/tag/driver" title="driver" rel="tag">driver</a>, <a href="http://cyher.net/tag/kernel" title="kernel" rel="tag">kernel</a>, <a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/virualkey" title="virualkey" rel="tag">virualkey</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/android/android-driver-jogball" title="android驱动之jogball (2010年03月16号)">android驱动之jogball</a> (2)</li>
	<li><a href="http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver" title="macbook pro ubuntu10.4 bcm无线网卡问题修复 (2010年05月2号)">macbook pro ubuntu10.4 bcm无线网卡问题修复</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/android/android-phone-powermanagement" title="Android 手机电源管理实例 &#8211; milestone (2010年07月25号)">Android 手机电源管理实例 &#8211; milestone</a> (1)</li>
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/android/virualkey/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android驱动之jogball</title>
		<link>http://cyher.net/gnulinux/android/android-driver-jogball</link>
		<comments>http://cyher.net/gnulinux/android/android-driver-jogball#comments</comments>
		<pubDate>Tue, 16 Mar 2010 09:18:16 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637024</guid>
		<description><![CDATA[1 简介
JogBall是首款Android手机-HTC Dream上附带的类似轨迹球Trackball的滑轮，通过Jogball用户可以轻松的实现网页的翻页、地图翻
转等操作，这种在手机上增加轨迹球的方式可以取消传统的4维导航键，Jogball并非HTC公司的首例，早在HTC 3300(Dopod P800)就
实现了这项功能，轨迹球操作方式的加入可以实现像电脑上鼠标一样轻松操控。现在jogball基本上算是android手机的标准配置了。
2 框图&#38;架构


2.1    gpio_event子系统
Jogball驱动是由linux代码中的gpio_event子系统实现的。
由以下文件组成：

 driver/input/misc/gpio_event.c
 driver/input/misc/gpio_input.c
 driver/input/misc/gpio_output.c
 driver/input/misc/gpio_matrix.c
 driver/input/misc/gpio_axis.c

gpio_event子系统是一个关于gpio的输入设备的通用代码，里面可以包含一般嵌入式设备中需要的键盘阵列和坐标有关的输入等。
2.2 Jogball架构
Jogball是归类于gpio_axis.c中的，是一个相对坐标系，判断电信号的高低来对坐标加或者减一定数值。具体细节在gpio_axis.c中
gpio_axis.c中的结构体初始化是在xxx-borad.c中的，基本架构就是这样，细节在下文叙述。
3 硬件描述


3.1 Jogball机械特性
Jogball是一个基于滚球滚动的输入设备，所以它机械特性也是比较重要，知道他的机械特性，便于我们理解驱动。
Jogball和以前的滚球鼠标比较相似，依靠滚轮的滚动来带动四周的圆柱体旋转。每个圆柱体端头都有一个磁铁，这个磁体铁从横断
面来看就是由N极的扇形和S极的扇形来组成一个圆周。这样当磁铁旋转的时候，N极和S极切换，使霍尔IC产生高低电平。
注意：在滚球旋转时，两个相对方向只有一个方向可以转动，这是为了减化软件编写的一个机械特性。
3.2 Jogball的电气特性
Jogball最重要的电特性就是这个霍尔IC，
霍尔元件的工作原理：所谓霍尔效应，是指磁场作用于载流金属导体、半导体中的载流子时，产生横向电位差的物理现
象。金属的霍尔效应是1879年被美 国物理学家霍尔发现的。当电流通过金属箔片时，若在垂直于电流的方向施加磁场，则金属箔片
两侧面会出现横向电位差。半导体中的霍尔效应比金属箔片中更为明 显，而铁磁金属在居里温度以下将呈现极强的霍尔效应。
所以jogball是旋转磁轴引起磁场的变幻，来产生高低电压的。从而根据机械特性就不难理解jogball的数字输入过程。
3.3 Jogball的原理图
其实jogball只是机械结构,原理图是hall ic的,有兴趣的人在这里下载
4 数据结构

struct hero_axis_info &#123;
        struct gpio_event_axis_info info; /*gpio_event_axis结构的信息*/
        uint16_t in_state;/*记录输入的高低电平信号*/
        uint16_t out_state;/*记录输出的高低电平信号*/
 [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #000000;">1 简介</span></h1>
<p>JogBall是首款Android手机-HTC Dream上附带的类似轨迹球Trackball的滑轮，通过Jogball用户可以轻松的实现网页的翻页、地图翻</p>
<p>转等操作，这种在手机上增加轨迹球的方式可以取消传统的4维导航键，Jogball并非HTC公司的首例，早在HTC 3300(Dopod P800)就</p>
<p>实现了这项功能，轨迹球操作方式的加入可以实现像电脑上鼠标一样轻松操控。现在jogball基本上算是android手机的标准配置了。</p>
<h1><span style="color: #000000;">2 框图&amp;架构</span></h1>
<p><span style="color: #000000;"><br />
</span></p>
<h3><span style="color: #000000;">2.1    gpio_event子系统</span></h3>
<p>Jogball驱动是由linux代码中的gpio_event子系统实现的。<br />
由以下文件组成：</p>
<ul>
<li> driver/input/misc/gpio_event.c</li>
<li> driver/input/misc/gpio_input.c</li>
<li> driver/input/misc/gpio_output.c</li>
<li> driver/input/misc/gpio_matrix.c</li>
<li> driver/input/misc/gpio_axis.c</li>
</ul>
<p>gpio_event子系统是一个关于gpio的输入设备的通用代码，里面可以包含一般嵌入式设备中需要的键盘阵列和坐标有关的输入等。</p>
<h3><span style="color: #000000;">2.2 Jogball架构</span></h3>
<p>Jogball是归类于gpio_axis.c中的，是一个相对坐标系，判断电信号的高低来对坐标加或者减一定数值。具体细节在gpio_axis.c中</p>
<p>gpio_axis.c中的结构体初始化是在xxx-borad.c中的，基本架构就是这样，细节在下文叙述。</p>
<h1><span style="color: #000000;">3 硬件描述</span></h1>
<p><span style="color: #000000;"><br />
</span></p>
<h3><span style="color: #000000;">3.1 Jogball机械特性</span></h3>
<p>Jogball是一个基于滚球滚动的输入设备，所以它机械特性也是比较重要，知道他的机械特性，便于我们理解驱动。<br />
Jogball和以前的滚球鼠标比较相似，依靠滚轮的滚动来带动四周的圆柱体旋转。每个圆柱体端头都有一个磁铁，这个磁体铁从横断</p>
<p>面来看就是由N极的扇形和S极的扇形来组成一个圆周。这样当磁铁旋转的时候，N极和S极切换，使霍尔IC产生高低电平。<br />
注意：在滚球旋转时，两个相对方向只有一个方向可以转动，这是为了减化软件编写的一个机械特性。</p>
<h3><span style="color: #000000;">3.2 Jogball的电气特性</span></h3>
<p>Jogball最重要的电特性就是这个霍尔IC，</p>
<blockquote><p>霍尔元件的工作原理：所谓霍尔效应，是指磁场作用于载流金属导体、半导体中的载流子时，产生横向电位差的物理现</p>
<p>象。金属的霍尔效应是1879年被美 国物理学家霍尔发现的。当电流通过金属箔片时，若在垂直于电流的方向施加磁场，则金属箔片</p>
<p>两侧面会出现横向电位差。半导体中的霍尔效应比金属箔片中更为明 显，而铁磁金属在居里温度以下将呈现极强的霍尔效应。</p></blockquote>
<p>所以jogball是旋转磁轴引起磁场的变幻，来产生高低电压的。从而根据机械特性就不难理解jogball的数字输入过程。</p>
<p>3.3 Jogball的原理图</p>
<p>其实jogball只是机械结构,原理图是hall ic的,有兴趣的人在<a href="http://www.datasheetarchive.com/pdf-datasheets/Datasheets-24/DSA-469829.pdf" target="_blank">这里下载</a></p>
<h1><span style="color: #000000;">4 数据结构</span></h1>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> hero_axis_info <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">struct</span> gpio_event_axis_info info<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio_event_axis结构的信息*/</span>
        uint16_t in_state<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*记录输入的高低电平信号*/</span>
        uint16_t out_state<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*记录输出的高低电平信号*/</span>
        uint16_t temp_state<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*临时存储高低电平*/</span>
        uint16_t threshold<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*门限值，超过这个值上报给input子系统*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #009900;">&#123;</span>
        <span style="color: #808080; font-style: italic;">/* initialize to gpio_event_axis_func */</span>
        <span style="color: #993333;">struct</span> gpio_event_info info<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio_event信息*/</span>
        uint8_t  count<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio的数量*/</span>
        uint8_t  type<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* EV_REL or EV_ABS */</span>
        uint16_t code<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*输入键值类型*/</span>
        uint16_t decoded_size<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio 数组的大小*/</span>
        uint16_t <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>map<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span> uint16_t in<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*解析回调函数*/</span>
        uint32_t <span style="color: #339933;">*</span>gpio<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio端口数组*/</span>
        uint32_t flags<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*调试标值*/</span>
        uint32_t enable_emc_protect_delay<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*保护间隔时间*/</span>
        uint16_t emc_gpio_state<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* 延时中用到gpio_state*/</span>
        atomic_t emc_disable_irqnum<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*延时中用到的屏蔽的中断号*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> gpio_event_info <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>func<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">,</span>
        <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span>
        <span style="color: #993333;">void</span> <span style="color: #339933;">**</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> func<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #808080; font-style: italic;">/*给gpio_event子系统中实现注册到内核中的回调函数*/</span>
        <span style="color: #993333;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">,</span>
        <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span>
        <span style="color: #993333;">void</span> <span style="color: #339933;">**</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> type<span style="color: #339933;">,</span>
        <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> code<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* out events */</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> gpio_event_platform_data <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>name<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*名字*/</span>
        <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">**</span>info<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*gpio_event的结构指针*/</span>
        size_t info_count<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*注册到axis中的info 结构体的数量*/</span>
        <span style="color: #993333;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>power<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">struct</span> gpio_event_platform_data <span style="color: #339933;">*</span>pdata<span style="color: #339933;">,</span> bool on<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*电源管理回调函数*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<h1><span style="color: #000000;">5 代码分析</span></h1>
<h3><span style="color: #000000;">5.1 通用代码</span></h3>
<p>driver/input/misc/gpio_event.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*gpio_event基本数据结构*/</span>
<span style="color: #993333;">struct</span> gpio_event <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">;</span>
        <span style="color: #993333;">const</span> <span style="color: #993333;">struct</span> gpio_event_platform_data <span style="color: #339933;">*</span>info<span style="color: #339933;">;</span>
        <span style="color: #993333;">struct</span> early_suspend early_suspend<span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>state<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*注册给input的回调函数*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> gpio_input_event<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>dev<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> type<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> code<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> value<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*调用下层给的回调函数来实现具体的注册*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> gpio_event_call_all_func<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_event <span style="color: #339933;">*</span>ip<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> func<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*电源管理*/</span>
<span style="color: #339933;">#ifdef CONFIG_HAS_EARLYSUSPEND</span>
<span style="color: #993333;">void</span> gpio_event_suspend<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> early_suspend <span style="color: #339933;">*</span>h<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #993333;">void</span> gpio_event_resume<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> early_suspend <span style="color: #339933;">*</span>h<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">#endif</span>
<span style="color: #808080; font-style: italic;">/*注册*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> __init gpio_event_probe<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> platform_device <span style="color: #339933;">*</span>pdev<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*注销*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> gpio_event_remove<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> platform_device <span style="color: #339933;">*</span>pdev<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> platform_driver gpio_event_driver
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> __devinit gpio_event_init<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> __exit gpio_event_exit<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>gpio_event.c:主要是gpio_event子系统的框架</p>
<h3><span style="color: #000000;">5.2    soc代码</span></h3>
<p>driver/input/misc/gpio_axis.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> gpio_axis_state <span style="color: #009900;">&#123;</span>
<span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*input设备结构*/</span>
<span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #339933;">*</span>info<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*坐标系数据结构*/</span>
uint32_t pos<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*位置*/</span>
<span style="color: #993333;">struct</span> hrtimer emc_hrtimer_delay<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* 延时时间*/</span>
atomic_t atomic_emc_hrtimer_is_run<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*延时的原子变量*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/*上报input数据*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> gpio_event_update_axis<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_axis_state <span style="color: #339933;">*</span>as<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> report<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*时间处理函数*/</span>
<span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">enum</span> hrtimer_restart emc_progress_hrtimer_handler_func<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> hrtimer <span style="color: #339933;">*</span>timer<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*中断处理函数*/</span>
<span style="color: #993333;">static</span> irqreturn_t gpio_axis_irq_handler<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> irq<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>dev_id<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*给上层的注册回调函数*/</span>
<span style="color: #993333;">int</span> gpio_event_axis_func<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">,</span> <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">**</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> func<span style="color: #009900;">&#41;</span></pre></div></div>

<h3><span style="color: #000000;">5.3    platform代码</span></h3>
<p>例如：/arch/arm/match-msm/board-72&#215;7.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">uint16_t hero_axis_map<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span> uint16_t in<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">struct</span> hero_axis_info <span style="color: #339933;">*</span>ai <span style="color: #339933;">=</span> container_of<span style="color: #009900;">&#40;</span>info<span style="color: #339933;">,</span> <span style="color: #993333;">struct</span> hero_axis_info<span style="color: #339933;">,</span> info<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        uint16_t out <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>out_state<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>nav_just_on<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jiffies <span style="color: #339933;">==</span> nav_on_jiffies <span style="color: #339933;">||</span> jiffies <span style="color: #339933;">==</span> nav_on_jiffies <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">goto</span> ignore<span style="color: #339933;">;</span>
        nav_just_on <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>in_state <span style="color: #339933;">^</span> in<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #808080; font-style: italic;">/*检测在方向1上有没有数值变化*/</span>
        out<span style="color: #339933;">--;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>n_state <span style="color: #339933;">^</span> in<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #808080; font-style: italic;">/*检测在方向1相对方向上有没有数值变化*/</span>
        out<span style="color: #339933;">++;</span>
ai<span style="color: #339933;">-&gt;;</span>out_state <span style="color: #339933;">=</span> out<span style="color: #339933;">;</span>
ignore<span style="color: #339933;">:</span>
        ai<span style="color: #339933;">-&gt;</span>in_state <span style="color: #339933;">=</span> in<span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">-</span> ai<span style="color: #339933;">-&gt;</span>temp_state <span style="color: #339933;">==</span> ai<span style="color: #339933;">-&gt;</span>threshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">++;</span>
        ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>temp_state <span style="color: #339933;">-</span> ai<span style="color: #339933;">-</span>out_state <span style="color: #339933;">==</span> ai<span style="color: #339933;">-&gt;</span>threshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">--;</span>
        ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>abs<span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">-</span> ai<span style="color: #339933;">-&gt;;</span>temp_state<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> ai<span style="color: #339933;">-&gt;</span>threshold<span style="color: #009900;">&#41;</span>
        ai<span style="color: #339933;">-&gt;</span>temp_state <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>out_state<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>以上函数，是最终的数据解析函数，也就是把硬件中读出来的数据，转化为实际的位置变化的函数。此函数主要做了差错控制，增加</p>
<p>了程序的鲁棒性和可订制性。</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> hero_axis_info hero_x_axis <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        .<span style="color: #202020;">threshold</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">info</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                .<span style="color: #202020;">info</span>.<span style="color: #202020;">func</span> <span style="color: #339933;">=</span> gpio_event_axis_func<span style="color: #339933;">,</span>
                .<span style="color: #202020;">count</span> <span style="color: #339933;">=</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_x_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">type</span> <span style="color: #339933;">=</span> EV_REL<span style="color: #339933;">,</span>
                .<span style="color: #202020;">code</span> <span style="color: #339933;">=</span> REL_X<span style="color: #339933;">,</span>
                .<span style="color: #202020;">decoded_size</span> <span style="color: #339933;">=</span> 1U <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_x_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">map</span> <span style="color: #339933;">=</span> hero_axis_map<span style="color: #339933;">,</span>
                .<span style="color: #202020;">gpio</span> <span style="color: #339933;">=</span> hero_x_axis_gpios<span style="color: #339933;">,</span>
                .<span style="color: #202020;">flags</span> <span style="color: #339933;">=</span> GPIOEAF_PRINT_UNKNOWN_DIRECTION <span style="color: #808080; font-style: italic;">/*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT */</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">enable_emc_protect_delay</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">*</span> NSEC_PER_MSEC<span style="color: #339933;">,</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>X轴上的info结构体的初始化</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> hero_axis_info hero_y_axis <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        .<span style="color: #202020;">threshold</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">info</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                .<span style="color: #202020;">info</span>.<span style="color: #202020;">func</span> <span style="color: #339933;">=</span> gpio_event_axis_func<span style="color: #339933;">,</span>
                .<span style="color: #202020;">count</span> <span style="color: #339933;">=</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_y_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">type</span> <span style="color: #339933;">=</span> EV_REL<span style="color: #339933;">,</span>
                .<span style="color: #202020;">code</span> <span style="color: #339933;">=</span> REL_Y<span style="color: #339933;">,</span>
                .<span style="color: #202020;">decoded_size</span> <span style="color: #339933;">=</span> 1U <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_y_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">map</span> <span style="color: #339933;">=</span> hero_axis_map<span style="color: #339933;">,</span>
                .<span style="color: #202020;">gpio</span> <span style="color: #339933;">=</span> hero_y_axis_gpios<span style="color: #339933;">,</span>
                .<span style="color: #202020;">flags</span> <span style="color: #339933;">=</span> GPIOEAF_PRINT_UNKNOWN_DIRECTION <span style="color: #808080; font-style: italic;">/*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT  */</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">enable_emc_protect_delay</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">*</span> NSEC_PER_MSEC<span style="color: #339933;">,</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Y轴上的info结构体的初始化</p>
<h1><span style="color: #000000;">6 备注</span></h1>
<p>在android的framework的代码中识别jogball设备是识别成鼠标的特性的，不仅有坐标还是由按键的，但是驱动中并没有axis中并没</p>
<p>有按键，所以在注册input设备的时候要加入按键的键值。如下代码：<br />
在drivers/input/misc/gpio_axis.c中的gpio_event_axis_func函数中</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">as<span style="color: #339933;">-&gt;</span>input_dev <span style="color: #339933;">=</span> input_dev<span style="color: #339933;">;</span>
as<span style="color: #339933;">-&gt;</span>info <span style="color: #339933;">=</span> ai<span style="color: #339933;">;</span>
&nbsp;
input_set_capability<span style="color: #009900;">&#40;</span>input_dev<span style="color: #339933;">,</span> ai<span style="color: #339933;">-&gt;</span>type<span style="color: #339933;">,</span> ai<span style="color: #339933;">-&gt;;</span>code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>type <span style="color: #339933;">==</span> EV_ABS<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        input_set_abs_params<span style="color: #009900;">&#40;</span>input_dev<span style="color: #339933;">,</span> ai<span style="color: #339933;">-&gt;</span>code<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>
        ai<span style="color: #339933;">-&gt;</span>decoded_size <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>input_set_capability(input_dev, ai->type, BT_MOUSE);</p>
<p>本文源码是基于hero手机kernel代码<br />
kernel_hero/arch/arm/mach-msm/board-hero.c<br />
下载地址 <a href="http://developer.htc.com/">http://developer.htc.com/</a></p>

	标签：<a href="http://cyher.net/tag/android" title="android" rel="tag">android</a>, <a href="http://cyher.net/tag/driver" title="driver" rel="tag">driver</a>, <a href="http://cyher.net/tag/input" title="input" rel="tag">input</a>, <a href="http://cyher.net/tag/kernel" title="kernel" rel="tag">kernel</a>, <a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/android/virualkey" title="android驱动之虚拟按键 (2010年03月22号)">android驱动之虚拟按键</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver" title="macbook pro ubuntu10.4 bcm无线网卡问题修复 (2010年05月2号)">macbook pro ubuntu10.4 bcm无线网卡问题修复</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/android/android-phone-powermanagement" title="Android 手机电源管理实例 &#8211; milestone (2010年07月25号)">Android 手机电源管理实例 &#8211; milestone</a> (1)</li>
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/android/android-driver-jogball/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>linux进程可执行文件的绝对路径</title>
		<link>http://cyher.net/programming/linux-process-absolute-path</link>
		<comments>http://cyher.net/programming/linux-process-absolute-path#comments</comments>
		<pubDate>Thu, 24 Sep 2009 08:55:46 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[proc]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637006</guid>
		<description><![CDATA[这种情况很少遇到，我们需要一个运行中进程的绝对路径，可惜的是glibc中或者系统调用中我都没有找到类似的函数。但是linux绝对不会不给你这个机会的，那就是proc文件系统了。在proc文件系统中那些数字都是运行中的进程，进入一个文件名为数字的文件夹以后，我们就可以发现以下类似文件目录结构。

&#91;cyher@cyher ~&#93;$ ls /proc/3355/
attr             cpuset   io        mountinfo   pagemap      smaps    task
auxv             cwd      latency   mounts      personality  stack    wchan
cgroup           environ  limits    mountstats  root         stat
clear_refs       exe      loginuid  net         sched        statm
cmdline          fd       maps      oom_adj     schedstat    status
coredump_filter  fdinfo   mem       oom_score   sessionid    syscall

这里就是一个进程所有的信息了大名鼎鼎的ps命令就是读取这里的内容解析出信息的，这里是ps的官方网站 http://procps.sourceforge.net/
那好了，就用这里给的信息来解析出执行文件的绝对路径吧

/*
 * =====================================================================================
 *
 *       Filename:  get_exe_path.c
 *
 *    [...]]]></description>
			<content:encoded><![CDATA[<p>这种情况很少遇到，我们需要一个运行中进程的绝对路径，可惜的是glibc中或者系统调用中我都没有找到类似的函数。但是linux绝对不会不给你这个机会的，那就是proc文件系统了。在proc文件系统中那些数字都是运行中的进程，进入一个文件名为数字的文件夹以后，我们就可以发现以下类似文件目录结构。</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>cyher@cyher ~<span style="color: #009900;">&#93;</span>$ ls <span style="color: #339933;">/</span>proc<span style="color: #339933;">/</span><span style="color: #0000dd;">3355</span><span style="color: #339933;">/</span>
attr             cpuset   io        mountinfo   pagemap      smaps    task
auxv             cwd      latency   mounts      personality  stack    wchan
cgroup           environ  limits    mountstats  root         stat
clear_refs       exe      loginuid  net         sched        statm
cmdline          fd       maps      oom_adj     schedstat    status
coredump_filter  fdinfo   mem       oom_score   sessionid    syscall</pre></div></div>

<p>这里就是一个进程所有的信息了大名鼎鼎的ps命令就是读取这里的内容解析出信息的，这里是ps的官方网站 <a href="http://procps.sourceforge.net/" target="_blank">http://procps.sourceforge.net/</a></p>
<p>那好了，就用这里给的信息来解析出执行文件的绝对路径吧</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
 * =====================================================================================
 *
 *       Filename:  get_exe_path.c
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  2009年09月23日 17时07分17秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  cyher (), cyher.net@gmail.com
 *        Company:  cyher.net
 *
 * =====================================================================================
 */</span>
&nbsp;
<span style="color: #339933;">#include</span>
<span style="color: #339933;">#include</span>
<span style="color: #339933;">#include</span>
<span style="color: #339933;">#define BUF 128</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> agrc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> buf<span style="color: #009900;">&#91;</span>BUF<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> proc<span style="color: #009900;">&#91;</span>BUF<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>p<span style="color: #339933;">;</span>
&nbsp;
    sprintf<span style="color: #009900;">&#40;</span>proc<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;/proc/%d/exe&quot;</span><span style="color: #339933;">,</span> atoi<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    readlink<span style="color: #009900;">&#40;</span>proc<span style="color: #339933;">,</span>buf<span style="color: #339933;">,</span> BUF<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*proc/pid/exe 是一个链接，用readlink读*/</span>
    p <span style="color: #339933;">=</span> strchr<span style="color: #009900;">&#40;</span>buf<span style="color: #339933;">,</span><span style="color: #ff0000;">'('</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*读出的路径后面有可能会有 (deleted)字样，删去*/</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>p ！<span style="color: #339933;">=</span> NULL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        p<span style="color: #339933;">--;</span>
        <span style="color: #339933;">*</span>p <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    puts<span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>这样就能读取出绝对路径了，不过你首先要知道pid啊 呵呵。</p>

	标签：<a href="http://cyher.net/tag/c" title="c" rel="tag">c</a>, <a href="http://cyher.net/tag/code" title="code" rel="tag">code</a>, <a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/proc" title="proc" rel="tag">proc</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
	<li><a href="http://cyher.net/gnulinux/%e6%97%b6%e9%9a%94%e5%87%a0%e4%b8%aa%e6%9c%88%ef%bc%8c%e6%b2%a1%e6%83%b3%e5%88%b0%e6%88%91%e5%8f%88%e7%94%a8%e4%b8%8alinux%e4%ba%86%e3%80%82%e3%80%82%e3%80%82" title="时隔几个月，没想到我又用上linux了。。。 (2008年06月30号)">时隔几个月，没想到我又用上linux了。。。</a> (0)</li>
	<li><a href="http://cyher.net/hardware/%e5%a4%a7%e6%95%8c%e5%bd%93%e5%89%8d-%e5%a1%9e%e7%8f%ad%e5%92%8c%e5%be%ae%e8%bd%af%e5%9d%87%e5%8f%97ubuntu%e5%a8%81%e8%83%81" title="大敌当前 塞班和微软均受Ubuntu威胁 (2007年04月21号)">大敌当前 塞班和微软均受Ubuntu威胁</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/programming/linux-process-absolute-path/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自己曾经作过的小实验</title>
		<link>http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c</link>
		<comments>http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c#comments</comments>
		<pubDate>Sun, 16 Aug 2009 13:45:50 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[嵌入式]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=636993</guid>
		<description><![CDATA[
youku链接:http://v.youku.com/v_show/id_XMTAyODE5MjEy.html

	标签：linux, 嵌入式

	相关日志
	
	自己的嵌入式学习经验, 想不到别人给拍成视频了 (0)
	科技是一种信仰(apple&#038;linux) (5)
	时隔几个月，没想到我又用上linux了。。。 (0)
	嵌入式c面试经验，与大家分享 (2)
	对于大学生嵌入式开发的认识 (2)


]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://player.youku.com/player.php/sid/XMTAyODE5MjEy/v.swf" /><embed type="application/x-shockwave-flash" width="480" height="400" src="http://player.youku.com/player.php/sid/XMTAyODE5MjEy/v.swf"></embed></object></p>
<p>youku链接:http://v.youku.com/v_show/id_XMTAyODE5MjEy.html</p>

	标签：<a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/%e5%b5%8c%e5%85%a5%e5%bc%8f" title="嵌入式" rel="tag">嵌入式</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
	<li><a href="http://cyher.net/gnulinux/%e6%97%b6%e9%9a%94%e5%87%a0%e4%b8%aa%e6%9c%88%ef%bc%8c%e6%b2%a1%e6%83%b3%e5%88%b0%e6%88%91%e5%8f%88%e7%94%a8%e4%b8%8alinux%e4%ba%86%e3%80%82%e3%80%82%e3%80%82" title="时隔几个月，没想到我又用上linux了。。。 (2008年06月30号)">时隔几个月，没想到我又用上linux了。。。</a> (0)</li>
	<li><a href="http://cyher.net/webthings/%e5%b5%8c%e5%85%a5%e5%bc%8fc%e9%9d%a2%e8%af%95%e7%bb%8f%e9%aa%8c%ef%bc%8c%e4%b8%8e%e5%a4%a7%e5%ae%b6%e5%88%86%e4%ba%ab" title="嵌入式c面试经验，与大家分享 (2008年12月16号)">嵌入式c面试经验，与大家分享</a> (2)</li>
	<li><a href="http://cyher.net/hardware/%e5%af%b9%e4%ba%8e%e5%a4%a7%e5%ad%a6%e7%94%9f%e5%b5%8c%e5%85%a5%e5%bc%8f%e5%bc%80%e5%8f%91%e7%9a%84%e8%ae%a4%e8%af%86" title="对于大学生嵌入式开发的认识 (2007年04月25号)">对于大学生嵌入式开发的认识</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自己的嵌入式学习经验, 想不到别人给拍成视频了</title>
		<link>http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c</link>
		<comments>http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c#comments</comments>
		<pubDate>Sun, 09 Aug 2009 15:01:17 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[学习]]></category>
		<category><![CDATA[嵌入式]]></category>
		<category><![CDATA[工作]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=636988</guid>
		<description><![CDATA[
见笑了&#8230;.呵呵. 说的太年轻气盛了&#8230;.别拍阿,我知错了.现在需要低调&#8230;呵呵.

	标签：linux, 学习, 嵌入式, 工作

	相关日志
	
	自己曾经作过的小实验 (0)
	嵌入式c面试经验，与大家分享 (2)
	科技是一种信仰(apple&#038;linux) (5)
	时隔几个月，没想到我又用上linux了。。。 (0)
	对于大学生嵌入式开发的认识 (2)


]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://player.youku.com/player.php/Type/Folder/Fid/3491370/Ob/1/Pt/1/sid/XOTMzNzQ1NzI=/v.swf" /><embed type="application/x-shockwave-flash" width="480" height="400" src="http://player.youku.com/player.php/Type/Folder/Fid/3491370/Ob/1/Pt/1/sid/XOTMzNzQ1NzI=/v.swf"></embed></object></p>
<p>见笑了&#8230;.呵呵. 说的太年轻气盛了&#8230;.别拍阿,我知错了.现在需要低调&#8230;呵呵.</p>

	标签：<a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/%e5%ad%a6%e4%b9%a0" title="学习" rel="tag">学习</a>, <a href="http://cyher.net/tag/%e5%b5%8c%e5%85%a5%e5%bc%8f" title="嵌入式" rel="tag">嵌入式</a>, <a href="http://cyher.net/tag/%e5%b7%a5%e4%bd%9c" title="工作" rel="tag">工作</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
	<li><a href="http://cyher.net/webthings/%e5%b5%8c%e5%85%a5%e5%bc%8fc%e9%9d%a2%e8%af%95%e7%bb%8f%e9%aa%8c%ef%bc%8c%e4%b8%8e%e5%a4%a7%e5%ae%b6%e5%88%86%e4%ba%ab" title="嵌入式c面试经验，与大家分享 (2008年12月16号)">嵌入式c面试经验，与大家分享</a> (2)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
	<li><a href="http://cyher.net/gnulinux/%e6%97%b6%e9%9a%94%e5%87%a0%e4%b8%aa%e6%9c%88%ef%bc%8c%e6%b2%a1%e6%83%b3%e5%88%b0%e6%88%91%e5%8f%88%e7%94%a8%e4%b8%8alinux%e4%ba%86%e3%80%82%e3%80%82%e3%80%82" title="时隔几个月，没想到我又用上linux了。。。 (2008年06月30号)">时隔几个月，没想到我又用上linux了。。。</a> (0)</li>
	<li><a href="http://cyher.net/hardware/%e5%af%b9%e4%ba%8e%e5%a4%a7%e5%ad%a6%e7%94%9f%e5%b5%8c%e5%85%a5%e5%bc%8f%e5%bc%80%e5%8f%91%e7%9a%84%e8%ae%a4%e8%af%86" title="对于大学生嵌入式开发的认识 (2007年04月25号)">对于大学生嵌入式开发的认识</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>unix-center.net需要帮助</title>
		<link>http://cyher.net/gnulinux/unix-center</link>
		<comments>http://cyher.net/gnulinux/unix-center#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:53:20 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=636966</guid>
		<description><![CDATA[我的邮件里有这么样子一封信http://www.unix-center.net/?p=133
看完以后，心中不知道有什么感觉，就去捐了100元。这时候有些人选择了，忽略，不信任，忘记等。。。确实这是一个自由的捐款，在自愿的情况下。但是我还是想帮助unix-center.net这个项目以及项目负责人，因为我收益于这个项目，我也知道，那些想学习linux或者unix的同学也一样，有些人有钱，有些人没钱，但是如果觉得这个项目帮助了自己或者能够帮助别人，那就请你出自己的一份力。因为在中国有这样的资源实属不多，所以我同项目负责人一样想让这个项目延续下去。说实话，这是我的一个个人信仰，也许也是这个项目负责人的信仰，帮助想要学习linux和unix系统的人。我现在只能做这些了，希望我们国家的开源和计算机事业都有源源不断的人材。
最后一句话，信任是不需要证据的，有了证据你再信任，信任就没有必要存在了。
&#8212;&#8211;送给那些不相信确有其事的人

	标签：linux, unix

	相关日志
	
	在macbook上安装各种操作系统 (0)
	Happy Hacking keyboard pro 2的艺术 (7)
	自己的嵌入式学习经验, 想不到别人给拍成视频了 (0)
	自己曾经作过的小实验 (0)
	科技是一种信仰(apple&#038;linux) (5)


]]></description>
			<content:encoded><![CDATA[<p>我的邮件里有这么样子一封信<a href="http://www.unix-center.net/?p=133" target="_blank">http://www.unix-center.net/?p=133</a></p>
<p>看完以后，心中不知道有什么感觉，就去捐了100元。这时候有些人选择了，忽略，不信任，忘记等。。。确实这是一个自由的捐款，在自愿的情况下。但是我还是想帮助unix-center.net这个项目以及项目负责人，因为我收益于这个项目，我也知道，那些想学习linux或者unix的同学也一样，有些人有钱，有些人没钱，但是如果觉得这个项目帮助了自己或者能够帮助别人，那就请你出自己的一份力。因为在中国有这样的资源实属不多，所以我同项目负责人一样想让这个项目延续下去。说实话，这是我的一个个人信仰，也许也是这个项目负责人的信仰，帮助想要学习linux和unix系统的人。我现在只能做这些了，希望我们国家的开源和计算机事业都有源源不断的人材。</p>
<p>最后一句话，信任是不需要证据的，有了证据你再信任，信任就没有必要存在了。<br />
&#8212;&#8211;送给那些不相信确有其事的人</p>

	标签：<a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/unix" title="unix" rel="tag">unix</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/apple/multi-os-on-macbook" title="在macbook上安装各种操作系统 (2009年07月26号)">在macbook上安装各种操作系统</a> (0)</li>
	<li><a href="http://cyher.net/peripherals/the-art-of-hhkb-pro-2" title="Happy Hacking keyboard pro 2的艺术 (2009年04月10号)">Happy Hacking keyboard pro 2的艺术</a> (7)</li>
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/unix-center/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>变质的奶酪,linux!</title>
		<link>http://cyher.net/gnulinux/bad_cheese_linux</link>
		<comments>http://cyher.net/gnulinux/bad_cheese_linux#comments</comments>
		<pubDate>Sat, 17 Jan 2009 18:04:15 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[自由]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=636848</guid>
		<description><![CDATA[      我个人是一个linux爱好者,这种爱好,并不是让linux给我带来更丰厚的薪水,纯纯的爱好和喜欢.记得在大学的时候,有为牛人说linux不是给所有人准备的,直到现在我还是这样认为的,但是现在的情况呢?
      网络上总是在把ubuntu和win7比,我怎么就是不能理解呢?现在ubuntu怎么了?难道想和windows一样了么?现在的关于linux的中文资讯,有多少是关于ubuntu的?我的意思是关于桌面的(包括Fedrora和SUSE),真的有意义么?google的andorid也来,linux马上就要变质了,这是一种及其个人的说法!linux在我心中是一种具有反抗,自由精神的一种载体,但是现在,它&#8221;翅膀硬了&#8221;,当在利益面前这种精神能不能保持呢?我说这些仅仅是一个技术爱好者的思维,可能一个商业运作者觉的这是一种顺理成章的事情.
      首先我觉得,linux虽然是以GPL协议发布的,但是我总是觉得用linux赚钱还是有点邪恶的,包括&#8221;不作恶的&#8221;google.在我心中,linux应该是低调的,高效的,很有技术性的,linus开发linux的初衷就是爱好或者说是一种信仰,但是看看现在中国的linux使用者,他们中有些人会说:&#8221;看!我不用windows 我用linux 我用的是ubuntu,我能用linux看rmvb,能下载BT!&#8221;这些应该值得欣喜的,但是这些不用这样高调的,这是理所应当的.在我心中一直存在一种想法就是:&#8221;windows能干的事linux也能干,windows能干的事linux干不了的事就是不需要干的事!&#8221;当然在现在这种娱乐大众,炒作的风气之下,windows能干的事,linux原来干不了,现在能干了就是值得欣喜的事&#8230;.我感到很可悲.对于linux甚至unix精神来说这就是一种蜕变!
      话说娱乐大众,windows和mac做的都是很不错的(一个同学的论点),linux原来不会娱乐大众,但是现在会了,ubuntu先会的接着就是Fedora,SUSE.linux在桌面领域那一位数的占有律说明,娱乐的还不够好!大众需要的是娱乐,不是愚弄!既然不擅长,就别跟风!最后落得个愚弄大众,自己得不偿失.
     我还是在想linux kernel的事,明白人都知道,linux 就是指kernel,并不是什么ubuntu,Fedora.对于商业的运作我真的不想考虑他们的感觉,我就是站在一个爱好者的角度或者说是传教士的角色,对初学linux的人和应用linux的人说:&#8221;对于内核,我们真应该好好看看了!&#8221; 中国人也是很强的!强!在我的理解并不是赚多少钱,看你能给人类带来多少贡献.至少,我们的大学里面,别整天学计算机基础的时候别老是教同学们一些word什么的,让一些非计算机专业的人只知道windows这个东西,让他们知道有linux,让他们知道自由,也让他们知道什么叫做版权!
     就说到这里吧,喝得有点多&#8230;..不好意思,文章很乱,思路也很奇怪,算了就这样了,我喜欢linux就是了,看看我今天吃了变质的奶酪以后,明天会不会拉肚子&#8230;.

	标签：linux, ubuntu, 自由

	相关日志
	
	在macbook上安装各种操作系统 (0)
	macbook pro ubuntu10.4 bcm无线网卡问题修复 (0)
	自己的嵌入式学习经验, 想不到别人给拍成视频了 (0)
	自己曾经作过的小实验 (0)
	科技是一种信仰(apple&#038;linux) (5)


]]></description>
			<content:encoded><![CDATA[<p>      我个人是一个linux爱好者,这种爱好,并不是让linux给我带来更丰厚的薪水,纯纯的爱好和喜欢.记得在大学的时候,有为牛人说linux不是给所有人准备的,直到现在我还是这样认为的,但是现在的情况呢?</p>
<p>      网络上总是在把ubuntu和win7比,我怎么就是不能理解呢?现在ubuntu怎么了?难道想和windows一样了么?现在的关于linux的中文资讯,有多少是关于ubuntu的?我的意思是关于桌面的(包括Fedrora和SUSE),真的有意义么?google的andorid也来,linux马上就要变质了,这是一种及其个人的说法!linux在我心中是一种具有反抗,自由精神的一种载体,但是现在,它&#8221;翅膀硬了&#8221;,当在利益面前这种精神能不能保持呢?我说这些仅仅是一个技术爱好者的思维,可能一个商业运作者觉的这是一种顺理成章的事情.</p>
<p>      首先我觉得,linux虽然是以GPL协议发布的,但是我总是觉得用linux赚钱还是有点邪恶的,包括&#8221;不作恶的&#8221;google.在我心中,linux应该是低调的,高效的,很有技术性的,linus开发linux的初衷就是爱好或者说是一种信仰,但是看看现在中国的linux使用者,他们中有些人会说:&#8221;看!我不用windows 我用linux 我用的是ubuntu,我能用linux看rmvb,能下载BT!&#8221;这些应该值得欣喜的,但是这些不用这样高调的,这是理所应当的.在我心中一直存在一种想法就是:&#8221;windows能干的事linux也能干,windows能干的事linux干不了的事就是不需要干的事!&#8221;当然在现在这种娱乐大众,炒作的风气之下,windows能干的事,linux原来干不了,现在能干了就是值得欣喜的事&#8230;.我感到很可悲.对于linux甚至unix精神来说这就是一种蜕变!</p>
<p>      话说娱乐大众,windows和mac做的都是很不错的(一个同学的论点),linux原来不会娱乐大众,但是现在会了,ubuntu先会的接着就是Fedora,SUSE.linux在桌面领域那一位数的占有律说明,娱乐的还不够好!大众需要的是娱乐,不是愚弄!既然不擅长,就别跟风!最后落得个愚弄大众,自己得不偿失.</p>
<p>     我还是在想linux kernel的事,明白人都知道,linux 就是指kernel,并不是什么ubuntu,Fedora.对于商业的运作我真的不想考虑他们的感觉,我就是站在一个爱好者的角度或者说是传教士的角色,对初学linux的人和应用linux的人说:&#8221;对于内核,我们真应该好好看看了!&#8221; 中国人也是很强的!强!在我的理解并不是赚多少钱,看你能给人类带来多少贡献.至少,我们的大学里面,别整天学计算机基础的时候别老是教同学们一些word什么的,让一些非计算机专业的人只知道windows这个东西,让他们知道有linux,让他们知道自由,也让他们知道什么叫做版权!</p>
<p>     就说到这里吧,喝得有点多&#8230;..不好意思,文章很乱,思路也很奇怪,算了就这样了,我喜欢linux就是了,看看我今天吃了变质的奶酪以后,明天会不会拉肚子&#8230;.</p>

	标签：<a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a>, <a href="http://cyher.net/tag/ubuntu" title="ubuntu" rel="tag">ubuntu</a>, <a href="http://cyher.net/tag/%e8%87%aa%e7%94%b1" title="自由" rel="tag">自由</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/apple/multi-os-on-macbook" title="在macbook上安装各种操作系统 (2009年07月26号)">在macbook上安装各种操作系统</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver" title="macbook pro ubuntu10.4 bcm无线网卡问题修复 (2010年05月2号)">macbook pro ubuntu10.4 bcm无线网卡问题修复</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/bad_cheese_linux/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>linux环境编程之进程间通信（消息队列)</title>
		<link>http://cyher.net/programming/linux%e7%8e%af%e5%a2%83%e7%bc%96%e7%a8%8b%e4%b9%8b%e8%bf%9b%e7%a8%8b%e9%97%b4%e9%80%9a%e4%bf%a1%ef%bc%88%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97</link>
		<comments>http://cyher.net/programming/linux%e7%8e%af%e5%a2%83%e7%bc%96%e7%a8%8b%e4%b9%8b%e8%bf%9b%e7%a8%8b%e9%97%b4%e9%80%9a%e4%bf%a1%ef%bc%88%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97#comments</comments>
		<pubDate>Thu, 07 Aug 2008 00:28:07 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://cyher.yo2.cn/articles/linux%e7%8e%af%e5%a2%83%e7%bc%96%e7%a8%8b%e4%b9%8b%e8%bf%9b%e7%a8%8b%e9%97%b4%e9%80%9a%e4%bf%a1%ef%bc%88%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97.html</guid>
		<description><![CDATA[/**************************************************************
* name : server.c                                *
* author : cyher                                *
* date : 2008-8-6                                *
* description : 服务端进程向消息队列里面放消息传给客户端      *
**************************************************************/
#include &#60;sys/types.h&#62;
#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;sys/ipc.h&#62;
#include [...]]]></description>
			<content:encoded><![CDATA[<p>/**************************************************************<br />
* name : server.c                                *<br />
* author : cyher                                *<br />
* date : 2008-8-6                                *<br />
* description : 服务端进程向消息队列里面放消息传给客户端      *<br />
**************************************************************/<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;sys/ipc.h&gt;<br />
#include &lt;sys/msg.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;time.h&gt;</p>
<p>struct msgbuf/*消息队列结构*/<br />
{<br />
long mtype;<br />
char mtext[256];<br />
};</p>
<p>int<br />
init_daemon(void);/*守护进程启动函数*/</p>
<p>int<br />
main()<br />
{<br />
key_t key;<br />
int msgid;<br />
char *p;<br />
time_t t;<br />
struct msgbuf msg= {100,&#8221;"};/*设置消息的id为100*/<br />
key = ftok(&#8220;/home/cyher/workspace/c/star&#8221;,&#8217;s&#8217;);/*产生一个key*/<br />
msgid = msgget(key,IPC_CREAT | 0666);/*产生一个ipc标识*/<br />
if(msgid == -1)<br />
{<br />
perror(&#8220;msgget&#8221;);<br />
exit(1);<br />
}</p>
<p>init_daemon();/*守护进程创建*/<br />
while(1)/*进入循环执行*/<br />
{<br />
t = time(NULL);<br />
p = asctime(localtime(&amp;t));<br />
strcpy(msg.mtext,p);/*把时间字符放入msg.mtext*/<br />
msgsnd(msgid,&amp;msg,strlen(msg.mtext)+1,IPC_NOWAIT);/*放入消息队列无阻塞*/<br />
sleep(2);<br />
}</p>
<p>}</p>
<p>/**************************************************************<br />
* name : client.c                                *<br />
* author : cyher                                *<br />
* date : 2008-8-6                                *<br />
* description : 客户端进程从消息队列里面取消息打印到屏幕上    *<br />
**************************************************************/<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;sys/ipc.h&gt;<br />
#include &lt;sys/msg.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;time.h&gt;</p>
<p>struct msgbuf<br />
{<br />
long mtype;<br />
char mtext[256];<br />
};</p>
<p>int<br />
main()<br />
{<br />
key_t key;<br />
int msgid;<br />
struct msgbuf msg;<br />
key = ftok(&#8220;/home/cyher/workspace/c/star&#8221;,&#8217;s&#8217;);<br />
msgid = msgget(key,IPC_CREAT | 0666);<br />
if(msgid == -1)<br />
{<br />
perror(&#8220;msgget&#8221;);<br />
exit(1);<br />
}</p>
<p>while(1)<br />
{<br />
if(msgrcv(msgid,&amp;msg,256,100,IPC_NOWAIT) == -1)<br />
{<br />
perror(&#8220;msgrcv:&#8221;);<br />
}<br />
printf(&#8220;%s&#8221;,msg.mtext);<br />
memset(&amp;msg,0,sizeof(struct msgbuf));<br />
sleep(2);<br />
}</p>
<p>}</p>
<p>/*******************************<br />
* name:init_daemon.c<br />
* author:cyher<br />
* date:2008-8-1<br />
* description:initialize a daemon process<br />
* */</p>
<p>#include &lt;unistd.h&gt;<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;sys/stat.h&gt;<br />
#include &lt;stdlib.h&gt;</p>
<p>int<br />
init_daemon()<br />
{<br />
int pid;<br />
int i;<br />
if( (pid=fork())&lt;0 )<br />
{<br />
perror(&#8220;fork&#8221;);<br />
exit(1);<br />
}<br />
else if(pid &gt; 0) //是父进程就退出<br />
{<br />
exit(0);<br />
}</p>
<p>if((pid=fork()) &lt; 0)<br />
{<br />
perror(&#8220;fork2&#8243;);<br />
exit(1);<br />
}<br />
else if (pid &gt; 0)//是第一子进程也退出<br />
{<br />
exit(0);<br />
}<br />
//<br />
//下面都是第二子进程运行<br />
sleep(2);<br />
setsid();//使子进程脱离父进程的关系，把父进程的信息改掉<br />
//脱离终端的控制<br />
//<br />
for(i=0;i&lt;1024;i++)//关闭文件描述符,节省资源<br />
close(i);<br />
chdir(&#8220;/tmp&#8221;);//改变工作目录<br />
umask(0);//重设掩码，使程序工作顺畅</p>
<p>return 0;</p>
<p>}</p>

	标签：<a href="http://cyher.net/tag/linux" title="linux" rel="tag">linux</a><br />

	<h4>相关日志</h4>
	<ul class="st-related-posts">
	<li><a href="http://cyher.net/gnulinux/%e5%ad%a6%e4%b9%a0%e7%bb%8f%e9%aa%8c" title="自己的嵌入式学习经验, 想不到别人给拍成视频了 (2009年08月9号)">自己的嵌入式学习经验, 想不到别人给拍成视频了</a> (0)</li>
	<li><a href="http://cyher.net/gnulinux/%e8%87%aa%e5%b7%b1%e6%9b%be%e7%bb%8f%e4%bd%9c%e8%bf%87%e7%9a%84%e5%b0%8f%e5%ae%9e%e9%aa%8c" title="自己曾经作过的小实验 (2009年08月16号)">自己曾经作过的小实验</a> (0)</li>
	<li><a href="http://cyher.net/apple/macos-x/technology_is_a_kind_of_belief_appl" title="科技是一种信仰(apple&#038;linux) (2009年01月12号)">科技是一种信仰(apple&#038;linux)</a> (5)</li>
	<li><a href="http://cyher.net/gnulinux/%e6%97%b6%e9%9a%94%e5%87%a0%e4%b8%aa%e6%9c%88%ef%bc%8c%e6%b2%a1%e6%83%b3%e5%88%b0%e6%88%91%e5%8f%88%e7%94%a8%e4%b8%8alinux%e4%ba%86%e3%80%82%e3%80%82%e3%80%82" title="时隔几个月，没想到我又用上linux了。。。 (2008年06月30号)">时隔几个月，没想到我又用上linux了。。。</a> (0)</li>
	<li><a href="http://cyher.net/hardware/%e5%a4%a7%e6%95%8c%e5%bd%93%e5%89%8d-%e5%a1%9e%e7%8f%ad%e5%92%8c%e5%be%ae%e8%bd%af%e5%9d%87%e5%8f%97ubuntu%e5%a8%81%e8%83%81" title="大敌当前 塞班和微软均受Ubuntu威胁 (2007年04月21号)">大敌当前 塞班和微软均受Ubuntu威胁</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/programming/linux%e7%8e%af%e5%a2%83%e7%bc%96%e7%a8%8b%e4%b9%8b%e8%bf%9b%e7%a8%8b%e9%97%b4%e9%80%9a%e4%bf%a1%ef%bc%88%e6%b6%88%e6%81%af%e9%98%9f%e5%88%97/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
