<?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>乐天无用de自留地</title>
	<atom:link href="http://letian.name/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://letian.name/blog</link>
	<description>人生就是如此。。。</description>
	<lastBuildDate>Fri, 28 Oct 2011 04:00:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>AT指令发送PDU短信详解</title>
		<link>http://letian.name/blog/?p=47</link>
		<comments>http://letian.name/blog/?p=47#comments</comments>
		<pubDate>Fri, 28 Oct 2011 04:00:54 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[编码]]></category>
		<category><![CDATA[GSM]]></category>
		<category><![CDATA[PDU短信]]></category>
		<category><![CDATA[SMS]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=47</guid>
		<description><![CDATA[摘录，待验证： 本文以一个实例来解说AT指令发送PDU短信的全过程，假如我要发送下面的短信： 接收号码：＋8613602433649 短信内容：工作愉快！ 短信中心号码：＋8613800200500 一、短信中心号码处理：用字符串 addr 表示 1、将短信息中心号码去掉+号，看看长度是否为偶数，如果不是，最后添加F 即 addr = &#8220;+8613800200500&#8243; =&#62; addr = &#8220;8613800200500F&#8221; 2、将奇数位和偶数位交换。 =&#62; addr = &#8220;683108200005F0&#8243; 3、将短信息中心号码前面加上字符91，91是国际化的意思 =&#62; addr = &#8220;91683108200005F0&#8243; 4、算出 addr 长度，结果除2，格式化成2位的16进制字符串，16 / 2 = 8 =&#62; &#8220;08&#8243; =&#62; addr = &#8220;0891683108200005F0&#8243; 二、手机号码处理：用字符串 phone 1、将手机号码去掉+号，看看长度是否为偶数，如果不是，最后添加F 即 phone = &#8220;+8613602433649&#8243; =&#62; phone = &#8220;8613602433649F&#8221; 2、将手机号码奇数位和偶数位交换。 =&#62; phone = [...]]]></description>
			<content:encoded><![CDATA[<p>摘录，待验证：</p>
<blockquote><p>本文以一个实例来解说AT指令发送PDU短信的全过程，假如我要发送下面的短信：<br />
接收号码：＋8613602433649<br />
短信内容：工作愉快！<br />
短信中心号码：＋8613800200500</p>
<p>一、短信中心号码处理：用字符串 addr 表示<br />
1、将短信息中心号码去掉+号，看看长度是否为偶数，如果不是，最后添加F<br />
即 addr = &#8220;+8613800200500&#8243;<br />
=&gt; addr = &#8220;8613800200500F&#8221;<br />
2、将奇数位和偶数位交换。<br />
=&gt; addr = &#8220;683108200005F0&#8243;<br />
3、将短信息中心号码前面加上字符91，91是国际化的意思<br />
=&gt; addr = &#8220;91683108200005F0&#8243;<br />
4、算出 addr 长度，结果除2，格式化成2位的16进制字符串，16 / 2 = 8 =&gt; &#8220;08&#8243;<br />
=&gt; addr = &#8220;0891683108200005F0&#8243;</p>
<p>二、手机号码处理：用字符串 phone<br />
1、将手机号码去掉+号，看看长度是否为偶数，如果不是，最后添加F<br />
即 phone = &#8220;+8613602433649&#8243;<br />
=&gt; phone = &#8220;8613602433649F&#8221;<br />
2、将手机号码奇数位和偶数位交换。<br />
=&gt; phone = &#8220;683106423346F9&#8243;</p>
<p>三、短信息部分处理：用字符串 msg 表示<br />
1、转字符串转换为Unicode代码，例如“工作愉快！”的unicode代码为 5DE54F5C61095FEBFF01，<br />
(转换函数见最后附录)<br />
2、将 msg 长度除2，保留两位16进制数，即 5DE54F5C61095FEBFF01 = 20 / 2 =&gt; &#8220;0A&#8221;，再加上 msg<br />
=&gt; msg = &#8220;0A5DE54F5C61095FEBFF01&#8243;</p>
<p>四、组合<br />
1、手机号码前加上字符串 11000D91（1100：固定，0D：手机号码的长度，不算＋号，十六进制表示，91：发送到手机为91，发送到小灵通为81），<br />
即 phone = &#8220;11000D91&#8243; + phone<br />
=&gt; 11000D91683106423346F9<br />
2、手机号码后加上 000800 和刚才的短信息内容，000800也写死就可以了<br />
即 phone = phone + &#8220;000800&#8243; + msg<br />
即 11000D91683106423346F9 + 000800 + 0A5DE54F5C61095FEBFF01<br />
=&gt; phone = 11000D91683106423346F90008000A5DE54F5C61095FEBFF01<br />
3、phone 长度除以2，格式化成2位的十进制数<br />
即 11000D91683106423346F90008000A5DE54F5C61095FEBFF01 =&gt; 50位 / 2 =&gt; 25</p>
<p>五、所以要发送的内容为<br />
AT+CMGF=0 &lt;回车&gt;<br />
OK<br />
AT+CMGS=25&lt;回车&gt;<br />
&gt; addr+phone &lt;Ctrl+Z发送&gt;</p>
<p>六、如果返回不是ERROR，恭喜你，发送成功了^_^<br />
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
// 7bit编码<br />
// 输入: pSrc &#8211; 源字符串指针<br />
//        nSrcLength &#8211; 源字符串长度<br />
// 输出: pDst &#8211; 目标编码串指针<br />
// 返回: 目标编码串长度<br />
int gsmEncode7bit(const char* pSrc, unsigned char* pDst, int nSrcLength)<br />
{<br />
int nSrc;   // 源字符串的计数值<br />
int nDst;   // 目标编码串的计数值<br />
int nChar;   // 当前正在处理的组内字符字节的序号，范围是0-7<br />
unsigned char nLeft; // 上一字节残余的数据<br />
// 计数值初始化<br />
nSrc = 0;<br />
nDst = 0;<br />
// 将源串每8个字节分为一组，压缩成7个字节<br />
// 循环该处理过程，直至源串被处理完<br />
// 如果分组不到8字节，也能正确处理<br />
while (nSrc &lt; nSrcLength)<br />
{<br />
// 取源字符串的计数值的最低3位<br />
nChar = nSrc &amp; 7;<br />
// 处理源串的每个字节<br />
if(nChar == 0)<br />
{<br />
// 组内第一个字节，只是保存起来，待处理下一个字节时使用<br />
nLeft = *pSrc;<br />
}<br />
else<br />
{<br />
// 组内其它字节，将其右边部分与残余数据相加，得到一个目标编码字节<br />
*pDst = (*pSrc &lt;&lt; (8-nChar)) | nLeft;<br />
// 将该字节剩下的左边部分，作为残余数据保存起来<br />
nLeft = *pSrc &gt;&gt; nChar;<br />
// 修改目标串的指针和计数值<br />
pDst++;<br />
nDst++;<br />
}<br />
// 修改源串的指针和计数值<br />
pSrc++;<br />
nSrc++;<br />
}<br />
// 返回目标串长度<br />
return nDst;<br />
}<br />
// 7bit解码<br />
// 输入: pSrc &#8211; 源编码串指针<br />
//        nSrcLength &#8211; 源编码串长度<br />
// 输出: pDst &#8211; 目标字符串指针<br />
// 返回: 目标字符串长度<br />
int gsmDecode7bit(const unsigned char* pSrc, char* pDst, int nSrcLength)<br />
{<br />
int nSrc;   // 源字符串的计数值<br />
int nDst;   // 目标解码串的计数值<br />
int nByte;   // 当前正在处理的组内字节的序号，范围是0-6<br />
unsigned char nLeft; // 上一字节残余的数据<br />
// 计数值初始化<br />
nSrc = 0;<br />
nDst = 0;</p>
<p>// 组内字节序号和残余数据初始化<br />
nByte = 0;<br />
nLeft = 0;<br />
// 将源数据每7个字节分为一组，解压缩成8个字节<br />
// 循环该处理过程，直至源数据被处理完<br />
// 如果分组不到7字节，也能正确处理<br />
while(nSrc&lt;nSrcLength)<br />
{<br />
// 将源字节右边部分与残余数据相加，去掉最高位，得到一个目标解码字节<br />
*pDst = ((*pSrc &lt;&lt; nByte) | nLeft) &amp; 0x7f;<br />
// 将该字节剩下的左边部分，作为残余数据保存起来<br />
nLeft = *pSrc &gt;&gt; (7-nByte);<br />
// 修改目标串的指针和计数值<br />
pDst++;<br />
nDst++;<br />
// 修改字节计数值<br />
nByte++;<br />
// 到了一组的最后一个字节<br />
if(nByte == 7)<br />
{<br />
// 额外得到一个目标解码字节<br />
*pDst = nLeft;<br />
// 修改目标串的指针和计数值<br />
pDst++;<br />
nDst++;<br />
// 组内字节序号和残余数据初始化<br />
nByte = 0;<br />
nLeft = 0;<br />
}<br />
// 修改源串的指针和计数值<br />
pSrc++;<br />
nSrc++;<br />
}<br />
// 输出字符串加个结束符<br />
*pDst = &#8216;\0&#8242;;<br />
// 返回目标串长度<br />
return nDst;<br />
}</p>
<p>// 正常顺序的字符串转换为两两颠倒的字符串，若长度为奇数，补&#8217;F'凑成偶数<br />
// 如：&#8221;8613851872468&#8243; &#8211;&gt; &#8220;683158812764F8&#8243;<br />
// 输入: pSrc &#8211; 源字符串指针<br />
//        nSrcLength &#8211; 源字符串长度<br />
// 输出: pDst &#8211; 目标字符串指针<br />
// 返回: 目标字符串长度<br />
int gsmInvertNumbers(const char* pSrc, char* pDst, int nSrcLength)<br />
{<br />
int nDstLength;   // 目标字符串长度<br />
char ch;    // 用于保存一个字符<br />
// 复制串长度<br />
nDstLength = nSrcLength;<br />
// 两两颠倒<br />
for(int i=0; i&lt;nSrcLength;i+=2)<br />
{<br />
ch = *pSrc++;   // 保存先出现的字符<br />
*pDst++ = *pSrc++; // 复制后出现的字符<br />
*pDst++ = ch;   // 复制先出现的字符<br />
}<br />
// 源串长度是奇数吗？<br />
if(nSrcLength &amp; 1)<br />
{<br />
*(pDst-2) = &#8216;F&#8217;; // 补&#8217;F&#8217;<br />
nDstLength++;   // 目标串长度加1<br />
}<br />
// 输出字符串加个结束符<br />
*pDst = &#8216;\0&#8242;;<br />
// 返回目标字符串长度<br />
return nDstLength;<br />
}</p>
<p>// PDU编码，用于编制、发送短消息<br />
// 输入: pSrc &#8211; 源PDU参数指针<br />
// 输出: pDst &#8211; 目标PDU串指针<br />
// 返回: 目标PDU串长度<br />
int gsmEncodePdu(const SM_PARAM* pSrc, char* pDst)<br />
{<br />
int nLength;    // 内部用的串长度<br />
int nDstLength;    // 目标PDU串长度<br />
unsigned char buf[256]; // 内部用的缓冲区<br />
// SMSC地址信息段<br />
nLength = strlen(pSrc-&gt;SCA); // SMSC地址字符串的长度<br />
buf[0] = (char)((nLength &amp; 1) == 0 ? nLength : nLength + 1) / 2 + 1; // SMSC地址信息长度<br />
buf[1] = 0&#215;91;   // 固定: 用国际格式号码<br />
nDstLength = gsmBytes2String(buf, pDst, 2);   // 转换2个字节到目标PDU串<br />
nDstLength += gsmInvertNumbers(pSrc-&gt;SCA, &amp;pDst[nDstLength], nLength); // 转换SMSC号码到目标PDU串<br />
// TPDU段基本参数、目标地址等<br />
nLength = strlen(pSrc-&gt;TPA); // TP-DA地址字符串的长度<br />
buf[0] = 0&#215;11;      // 是发送短信(TP-MTI=01)，TP-VP用相对格式(TP-VPF=10)<br />
buf[1] = 0;       // TP-MR=0<br />
buf[2] = (char)nLength;    // 目标地址数字个数(TP-DA地址字符串真实长度)<br />
buf[3] = 0&#215;91;      // 固定: 用国际格式号码<br />
nDstLength += gsmBytes2String(buf, &amp;pDst[nDstLength], 4);   // 转换4个字节到目标PDU串<br />
nDstLength += gsmInvertNumbers(pSrc-&gt;TPA, &amp;pDst[nDstLength], nLength); // 转换TP-DA到目标PDU串<br />
// TPDU段协议标识、编码方式、用户信息等<br />
nLength = strlen(pSrc-&gt;TP_UD); // 用户信息字符串的长度<br />
buf[0] = pSrc-&gt;TP_PID;    // 协议标识(TP-PID)<br />
buf[1] = pSrc-&gt;TP_DCS;    // 用户信息编码方式(TP-DCS)<br />
buf[2] = 0;       // 有效期(TP-VP)为5分钟<br />
if(pSrc-&gt;TP_DCS == GSM_7BIT)<br />
{<br />
// 7-bit编码方式<br />
buf[3] = nLength;    // 编码前长度<br />
nLength = gsmEncode7bit(pSrc-&gt;TP_UD, &amp;buf[4], nLength+1) + 4; // 转换TP-DA到目标PDU串<br />
}<br />
else if(pSrc-&gt;TP_DCS == GSM_UCS2)<br />
{<br />
// UCS2编码方式<br />
buf[3] = gsmEncodeUcs2(pSrc-&gt;TP_UD, &amp;buf[4], nLength); // 转换TP-DA到目标PDU串<br />
nLength = buf[3] + 4;   // nLength等于该段数据长度<br />
}<br />
else<br />
{<br />
// 8-bit编码方式<br />
buf[3] = gsmEncode8bit(pSrc-&gt;TP_UD, &amp;buf[4], nLength); // 转换TP-DA到目标PDU串<br />
nLength = buf[3] + 4;   // nLength等于该段数据长度<br />
}<br />
nDstLength += gsmBytes2String(buf, &amp;pDst[nDstLength], nLength);   // 转换该段数据到目标PDU串<br />
// 返回目标字符串长度<br />
return nDstLength;<br />
}</p>
<p>// 初始化GSM状态<br />
BOOL gsmInit()<br />
{<br />
char ans[128];   // 应答串<br />
// 测试GSM-MODEM的存在性<br />
WriteComm(&#8220;AT\r&#8221;, 3);<br />
ReadComm(ans, 128);<br />
if (strstr(ans, &#8220;OK&#8221;) == NULL)   return FALSE;<br />
// ECHO OFF<br />
WriteComm(&#8220;ATE0\r&#8221;, 5);<br />
ReadComm(ans, 128);<br />
// PDU模式<br />
WriteComm(&#8220;AT+CMGF=0\r&#8221;, 10);<br />
ReadComm(ans, 128);<br />
return TRUE;<br />
}<br />
// 发送短消息，仅发送命令，不读取应答<br />
// 输入: pSrc &#8211; 源PDU参数指针<br />
int gsmSendMessage(SM_PARAM* pSrc)<br />
{<br />
int nPduLength;   // PDU串长度<br />
unsigned char nSmscLength; // SMSC串长度<br />
int nLength;   // 串口收到的数据长度<br />
char cmd[16];   // 命令串<br />
char pdu[512];   // PDU串<br />
char ans[128];   // 应答串<br />
nPduLength = gsmEncodePdu(pSrc, pdu); // 根据PDU参数，编码PDU串<br />
strcat(pdu, &#8220;\x01a&#8221;);   // 以Ctrl-Z结束<br />
gsmString2Bytes(pdu, &amp;nSmscLength, 2); // 取PDU串中的SMSC信息长度<br />
nSmscLength++;   // 加上长度字节本身<br />
// 命令中的长度，不包括SMSC信息长度，以数据字节计<br />
sprintf(cmd, &#8220;AT+CMGS=%d\r&#8221;, nPduLength / 2 &#8211; nSmscLength); // 生成命令<br />
// TRACE(&#8220;%s&#8221;, cmd);<br />
// TRACE(&#8220;%s\n&#8221;, pdu);<br />
WriteComm(cmd, strlen(cmd)); // 先输出命令串<br />
nLength = ReadComm(ans, 128); // 读应答数据<br />
// 根据能否找到&#8221;\r\n&gt; &#8220;决定成功与否<br />
if(nLength == 4 &amp;&amp; strncmp(ans, &#8220;\r\n&gt; &#8220;, 4) == 0)<br />
{<br />
return WriteComm(pdu, strlen(pdu));   // 得到肯定回答，继续输出PDU串<br />
}<br />
return 0;<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=47</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I2S &amp; PCM</title>
		<link>http://letian.name/blog/?p=46</link>
		<comments>http://letian.name/blog/?p=46#comments</comments>
		<pubDate>Wed, 26 Oct 2011 16:04:57 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[I2S]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[PCM]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=46</guid>
		<description><![CDATA[IIS通常会包括：时钟信号(BClk) ，数据线出 SDO，数据线入SDI （全双工的情况），还有是LRClk（专门用来区分左右声道，以此来同步。低电平代表左声道，高电平代表右声道）。每根数据线只传输2路信号（立体声），如果要传输6路信号，通常就是有3根数据出，以及3根数据入。 PCM有PCM-clock、PCM-sync、PCM-in、PCM-out四根线，其中PCM_SYNC用来同步帧，有long fram sync和short frame sync等模式，但并不专门区分左右声道。 I2S是音频数字化后数据排列的一种格式，说传输的就是PCM，支持单声道和立体声。 PCM（PCM-clock、PCM-sync、PCM-in、PCM-out）脉冲编码调制，模拟语音信号经过采样量化以及一定数据排列就是PCM了。理论上可以传输单声道，双声道立体声和多声道。是数字音频的raw data。 上图I2S时序 上图PCM时序]]></description>
			<content:encoded><![CDATA[<blockquote><p>IIS通常会包括：时钟信号(BClk) ，数据线出 SDO，数据线入SDI （全双工的情况），还有是LRClk（专门用来区分左右声道，以此来同步。低电平代表左声道，高电平代表右声道）。每根数据线只传输2路信号（立体声），如果要传输6路信号，通常就是有3根数据出，以及3根数据入。<br />
PCM有PCM-clock、PCM-sync、PCM-in、PCM-out四根线，其中PCM_SYNC用来同步帧，有long fram sync和short frame sync等模式，但并不专门区分左右声道。</p>
<p>I2S是音频数字化后数据排列的一种格式，说传输的就是PCM，支持单声道和立体声。<br />
PCM（PCM-clock、PCM-sync、PCM-in、PCM-out）脉冲编码调制，模拟语音信号经过采样量化以及一定数据排列就是PCM了。理论上可以传输单声道，双声道立体声和多声道。是数字音频的raw data。</p>
<p><img class="alignnone" title="I2S时序" src="http://farm7.static.flickr.com/6044/6283573976_4f5f5a684e_b.jpg" alt="" width="729" height="264" /></p>
<p>上图I2S时序</p>
<p><img class="alignnone" title="PCM时序" src="http://farm7.static.flickr.com/6092/6283573984_a357508f29_b.jpg" alt="" width="722" height="324" /></p>
<p>上图PCM时序</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=46</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu下PL2303串口卡驱动</title>
		<link>http://letian.name/blog/?p=44</link>
		<comments>http://letian.name/blog/?p=44#comments</comments>
		<pubDate>Thu, 28 Apr 2011 02:38:19 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PL2303]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[技术宅de技能]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=44</guid>
		<description><![CDATA[1、将设备u口插入pc 2、输入 ＃lsmod 先看看能否检测到这个设备，就看有没有pl2303字眼能了。如果有，则不必再装驱动。如果没有则需要驱动程式，一般硬件厂商都会提供，安装完毕后再输入这个命令瞧瞧，是否安装成功。 3、检测步骤，检测步骤和PCI转串口的8条以后内容如下，只是需要主意的是设置串口设备的时候可能不是ttyS2了，有可能是ttyUSB0之类的。 1、插入PCI卡到主机 2、启动 Linux，打开终端 3、输入命令：＃setserial  /dev/ttyS0 -a   (COM-1) 显示内容：/dev/ttyS0, Line 0,  UART: 16550A, Port: 0x3f8, irq: 4 Baud_base: 115200, clos_delay: 50, divisor: 0 closing_wait: 3000, closing_wait2: infinite Flags: spd_normal skip_test 4、输入命令：＃setserial  /dev/ttyS2 -a   (COM-3) 显示内容：/dev/ttyS2, Line 2,  UART: unknown, Port: 0x3e8, irq: 4 Baud_base: 115200, clos_delay: 50, divisor: 0 closing_wait: 3000, [...]]]></description>
			<content:encoded><![CDATA[<p>1、将设备u口插入pc</p>
<p>2、输入</p>
<blockquote><p>＃lsmod</p></blockquote>
<p>先看看能否检测到这个设备，就看有没有pl2303字眼能了。如果有，则不必再装驱动。如果没有则需要驱动程式，一般硬件厂商都会提供，安装完毕后再输入这个命令瞧瞧，是否安装成功。</p>
<p>3、检测步骤，检测步骤和PCI转串口的8条以后内容如下，只是需要主意的是设置串口设备的时候可能不是ttyS2了，有可能是ttyUSB0之类的。</p>
<blockquote><p>1、插入PCI卡到主机<br />
2、启动 Linux，打开终端<br />
3、输入命令：＃setserial  /dev/ttyS0 -a   (COM-1)<br />
显示内容：/dev/ttyS0, Line 0,  UART: 16550A, Port: 0x3f8, irq: 4<br />
Baud_base: 115200, clos_delay: 50, divisor: 0<br />
closing_wait: 3000, closing_wait2: infinite<br />
Flags: spd_normal skip_test<br />
4、输入命令：＃setserial  /dev/ttyS2 -a   (COM-3)<br />
显示内容：/dev/ttyS2, Line 2,  UART: unknown, Port: 0x3e8, irq: 4<br />
Baud_base: 115200, clos_delay: 50, divisor: 0<br />
closing_wait: 3000, closing_wait2: infinite<br />
Flags: spd_normal skip_test<br />
第3、4步操作的目的主要是对主机自带串口及PCI扩展串口的区别。区别在于4显示的内容中UART:未unknow。不过若您检测这一步的时候 UART为16550A而不是unknow，证明你的系统已经认识了扩展的串口，不需要进一步设置，直接跳入第8步测试就可以了。<br />
5、需要输入命令查看一下您当前PCI检测的状态，以便对扩展串口进行设置<br />
＃more  /proc/pci<br />
会显示出一堆的信息，不要因为看不懂而吓坏了。只要看到类似于这个PCI的信息，比如：PCI communication。。。或者Board with Nm9835CV part。。。   可能就是这个卡了，主要看看它的终端是多少，即irq多少及分配的地址是多少。例如：(不一定完全一样）<br />
Board with Nm9835CV part  irq:11<br />
I/O at 0xc000 [0xc001] serial port 1<br />
I/O at 0xc400 [0xc401] serial port 2<br />
I/O at 0xc800 [0xc801] not used<br />
I/O at 0xd000 [0xd001] not used<br />
I/O at 0xd400 [0xd401] not used<br />
I/O at 0xd800 [0xd801] not used<br />
6、知道PCI扩展卡的终端为11   串口1地址为0xc000  串口2地址为0xc400..<br />
就可以设置扩展的串口了。输入命令：<br />
setserial  /dev/ttyS2 port 0xc000 UART 16550A<br />
irq 11 Baud_base 115200<br />
另一个串口也类似的这么操作<br />
7、设置完毕后，就可以看看设置的情况了，输入第2步的命令看看，UART是否就是16500A 而不是 unknow了，如果是16500A恭喜，可能设置好咯，如果不是那就再检查一下吧。<br />
8、设置好了后是不是需要测试一下是否能够通讯呢？最好的办法是两台pc相连。如果pc为windows操作系统就用超级终端，是linux呢就用minicom吧<br />
9、装有linux的机器，首先需要设置一下监听的串口参数，输入命令<br />
＃minicom -s<br />
进入界面后有个框弹出来，如果你还认识点英文单词的话，就回知道选择哪个的。应该是第三个吧，串口设置。<br />
将第一行更改为  /dev/ttyS2<br />
波特率也更改您所需要的。<br />
更改完后保存，保存的那个菜单应该是 save &#8230; df1<br />
最后 exit<br />
10、在另外一台机器发送数据，这台机器minicom界面就能够收到信息了，成功后觉得挺有意思。另外不要把两个COM顺序弄翻了，如果弄错了哪个是COM3  COM4测试可就不灵便咯。</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=44</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用Gmail的SyncML同步通讯录</title>
		<link>http://letian.name/blog/?p=42</link>
		<comments>http://letian.name/blog/?p=42#comments</comments>
		<pubDate>Thu, 24 Feb 2011 13:31:58 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[SyncML]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=42</guid>
		<description><![CDATA[“远程数据库”输入contacts，必须是小写字母。 “服务器识别码”为Google，字母G必须是大写。 “主机地址”输入https://m.google.com/syncml， “端口”为443，用户名为你的Gmail用户名，密码为Gmail密码。]]></description>
			<content:encoded><![CDATA[<p>“远程数据库”输入contacts，必须是小写字母。<br />
“服务器识别码”为Google，字母G必须是大写。<br />
“主机地址”输入https://m.google.com/syncml， “端口”为443，用户名为你的Gmail用户名，密码为Gmail密码。</p>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何在iPhone上同步GoogleCalendar主日历以外的日历</title>
		<link>http://letian.name/blog/?p=37</link>
		<comments>http://letian.name/blog/?p=37#comments</comments>
		<pubDate>Sun, 20 Feb 2011 08:24:05 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Calendar]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Sync]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=37</guid>
		<description><![CDATA[By default only your primary calendar will be synced to your device. You can sync additional calendars by visiting the following page from any web browser: https://www.google.com/calendar/iphoneselect (Google Apps users can go to https://www.google.com/calendar/hosted/your_domain/iphoneselect, replacing &#8216;your_domain&#8217; with your actual domain name.) Select the calendars you&#8217;d like to sync, and click Save. The selected calendars will [...]]]></description>
			<content:encoded><![CDATA[<p>By default only your primary calendar will be synced to your device. You can sync additional calendars by visiting the following page from any web browser:</p>
<p>https://www.google.com/calendar/iphoneselect</p>
<p>(Google Apps users can go to https://www.google.com/calendar/hosted/your_domain/iphoneselect, replacing &#8216;your_domain&#8217; with your actual domain name.)</p>
<p>Select the calendars you&#8217;d like to sync, and click Save. The selected calendars will display on your device at the time of the next sync.</p>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=37</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu Server安装Apache＋MySQL</title>
		<link>http://letian.name/blog/?p=38</link>
		<comments>http://letian.name/blog/?p=38#comments</comments>
		<pubDate>Sat, 04 Dec 2010 13:20:03 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Ubuntu Server]]></category>
		<category><![CDATA[技术宅de技能]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=38</guid>
		<description><![CDATA[1、 Apache $ sudo apt-get install apache2 2、Mysql $ sudo apt-get install mysql-server 3、PHP $ sudo apt-get install php5 4、MySQL for Apache PHP （通信模板） $ sudo apt-get install libapache2-mod-auth-mysql $ sudo apt-get install php5-mysql 5、phpmyadmin $ sudo apt-get install phpmyadmin 安裝後 1、打開 http://localhost 可以看到 It works!           表示apache正常運行 2、在終端輸入： sudo netstat -tap &#124; grep mysql tcp [...]]]></description>
			<content:encoded><![CDATA[<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 23.0px; font: 16.0px Verdana} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 23.0px; font: 16.0px 'Microsoft YaHei'} span.s1 {font: 16.0px 'Microsoft YaHei'} span.s2 {font: 16.0px 'Lucida Grande'} span.s3 {font: 16.0px Verdana} -->1、 Apache</p>
<blockquote><p>$ sudo apt-get install apache2</p></blockquote>
<p>2、Mysql</p>
<blockquote><p>$ sudo apt-get install mysql-server</p></blockquote>
<p>3、PHP</p>
<blockquote><p>$ sudo apt-get install php5</p></blockquote>
<p>4、MySQL for Apache PHP （通信模板）</p>
<blockquote><p>$ sudo apt-get install libapache2-mod-auth-mysql<br />
$ sudo apt-get install php5-mysql</p></blockquote>
<p>5、phpmyadmin</p>
<blockquote><p>$ sudo apt-get install phpmyadmin</p></blockquote>
<p>安裝後</p>
<p>1、打開 http://localhost 可以看到<br />
It works!           表示apache正常運行</p>
<blockquote><p><a href="http://letian.name/blog/wp-content/uploads/2010/12/Screen-shot-2010-12-04-at-9.05.16-PM.png"><img class="size-full wp-image-39 alignnone" title="It works!" src="http://letian.name/blog/wp-content/uploads/2010/12/Screen-shot-2010-12-04-at-9.05.16-PM.png" alt="" width="782" height="426" /></a></p></blockquote>
<p>2、在終端輸入：</p>
<blockquote><p>sudo netstat -tap | grep mysql</p></blockquote>
<blockquote><p>tcp 0 0 localhost.localdomain:mysql *:* LISTEN -      表示mysql正常運行<br />
<a href="http://letian.name/blog/wp-content/uploads/2010/12/Screen-shot-2010-12-04-at-9.07.33-PM.png"><img class="alignnone size-full wp-image-40" title="MySQL" src="http://letian.name/blog/wp-content/uploads/2010/12/Screen-shot-2010-12-04-at-9.07.33-PM.png" alt="" width="800" height="579" /></a></p></blockquote>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 23.0px; font: 16.0px Verdana} span.s1 {font: 16.0px 'Microsoft YaHei'} -->3、phpMyAdmin，會自動安裝在/usr/share/phpMyAdmin下<em>（本人尝试多次未找到该目录，解决方案见后文）</em></p>
<p>在終端輸入</p>
<blockquote><p>cp -r /usr/share/phpMyAdmin /var/www</p></blockquote>
<p>將phpmyadmin文件復制到www文件夾下</p>
<p>打開 http://localhost/phpmyadmin                        打開mysql管理界面。</p>
<p><em>参考文献：http://www.pyoix.com/a/1228.html 《Ubuntu 10.10安裝Apache+MySQL+PHP環境》</em></p>
<p>＝＝＝＝＝＝＝＝＝＝＝＝＝技术宅的分割线＝＝＝＝＝＝＝＝＝＝＝＝＝</p>
<p>Should you get a 404 &#8220;Not Found&#8221; error when you point your browser to the location of phpMyAdmin (such as: http://localhost/phpmyadmin) this is likely caused by not checking the &#8216;Apache 2&#8242; selection during installation. To redo the installation run the following:</p>
<blockquote><p>sudo dpkg-reconfigure -plow phpmyadmin</p></blockquote>
<p>Then select Apache 2 for the webserver you wish to configure.</p>
<p>If this does not work, then you can do the following to include the phpMyadmin-shipped Apache configuration into Apache:</p>
<blockquote>
<div id="_mcePaste">sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf</div>
</blockquote>
<blockquote>
<div id="_mcePaste">sudo /etc/init.d/apache2 reload</div>
</blockquote>
<p>参考文献：https://help.ubuntu.com/community/phpMyAdmin</p>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=38</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SleepCycle 88</title>
		<link>http://letian.name/blog/?p=35</link>
		<comments>http://letian.name/blog/?p=35#comments</comments>
		<pubDate>Fri, 26 Nov 2010 22:40:46 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[APP]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[SleepCycle]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=35</guid>
		<description><![CDATA[SleepCycle应用只不过是在预设的起床时间前后测到翻身动作后提前闹铃而已，并无实际提高睡眠作用。他将退出我的iPhone桌面。]]></description>
			<content:encoded><![CDATA[<p>SleepCycle应用只不过是在预设的起床时间前后测到翻身动作后提前闹铃而已，并无实际提高睡眠作用。他将退出我的iPhone桌面。</p>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=35</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>好吧，我承认我寂寞了一把。。。</title>
		<link>http://letian.name/blog/?p=36</link>
		<comments>http://letian.name/blog/?p=36#comments</comments>
		<pubDate>Fri, 06 Aug 2010 17:28:06 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[为人处世de参考]]></category>
		<category><![CDATA[乐天诚品]]></category>
		<category><![CDATA[凡客体]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=36</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="乐天诚品" src="http://farm5.static.flickr.com/4136/4866666848_12e529a213_b.jpg" alt="" width="1024" height="576" /></p>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=36</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>电池电量检测</title>
		<link>http://letian.name/blog/?p=31</link>
		<comments>http://letian.name/blog/?p=31#comments</comments>
		<pubDate>Fri, 09 Jul 2010 03:15:03 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[硬件]]></category>
		<category><![CDATA[电量检测]]></category>
		<category><![CDATA[电池]]></category>
		<category><![CDATA[Fairchild]]></category>
		<category><![CDATA[FAN4010]]></category>
		<category><![CDATA[技术宅de技能]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=31</guid>
		<description><![CDATA[电压检测： 4.20V—100%，3.85V—75%，3.75V—50%，3.60V—25%，3.40V—5%。电池电压会随着RFPA的功率发射发生突变，通常会变小0.2V-0.3V。当前工程师们的普遍方法是利用软件算法进行均值滤波，对一段时间内的电池电压进行均值化，如果该时间段的平均电池电压确实下降了，则预估电量确实变少了，否则即认为电量并未变化。 电量检测： 通过库仑计实时监测电池消耗电量而计算剩余电量的方法则非常准确。Fairchild的FAN4010是一颗电流检测传感器，专门用于检测便携式设备电池的充电/耗电电流，能将通过精密检测电阻的电流信号转换为ADC可以检测到的电压信号，从而计算一段时间内消耗的真实电量。]]></description>
			<content:encoded><![CDATA[<p>电压检测：</p>
<blockquote><p>4.20V—100%，3.85V—75%，3.75V—50%，3.60V—25%，3.40V—5%。电池电压会随着RFPA的功率发射发生突变，通常会变小0.2V-0.3V。当前工程师们的普遍方法是利用软件算法进行均值滤波，对一段时间内的电池电压进行均值化，如果该时间段的平均电池电压确实下降了，则预估电量确实变少了，否则即认为电量并未变化。</p></blockquote>
<p>电量检测：</p>
<blockquote><p>通过库仑计实时监测电池消耗电量而计算剩余电量的方法则非常准确。Fairchild的<a href="http://www.fairchildsemi.com/pf/FA/FAN4010.html" target="_blank">FAN4010</a>是一颗电流检测传感器，专门用于检测便携式设备电池的充电/耗电电流，能将通过精密检测电阻的电流信号转换为ADC可以检测到的电压信号，从而计算一段时间内消耗的真实电量。</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=31</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone 4 芯片</title>
		<link>http://letian.name/blog/?p=29</link>
		<comments>http://letian.name/blog/?p=29#comments</comments>
		<pubDate>Sat, 26 Jun 2010 10:42:13 +0000</pubDate>
		<dc:creator>Letian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[硬件]]></category>
		<category><![CDATA[芯片]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone 4]]></category>
		<category><![CDATA[技术宅de技能]]></category>

		<guid isPermaLink="false">http://letian.name/blog/?p=29</guid>
		<description><![CDATA[Apple iPhone 4 &#8211; Front Skyworks SKY77541 GSM/GPRS Front End Module Triquint TQM666092 Power Amp Skyworks SKY77452 W-CDMA FEM Triquint TQM676091 Power Amp Apple 338S0626 Infineon GSM/W-CDMA Transeiver Skyworks SKY77459 Tx-Rx FEM for Quad-Band GSM/GPRS/EDGE Apple AGD1 STMicro 3-axis digital gyroscope Apple A4 Processor Broadcom BCM4329FKUGB 802.11n with Bluetooth 2.1 + EDR and FM receiver [...]]]></description>
			<content:encoded><![CDATA[<p>Apple iPhone 4 &#8211; Front</p>
<blockquote>
<ul>
<li>Skyworks SKY77541 GSM/GPRS Front End Module</li>
<li>Triquint TQM666092 Power Amp</li>
<li>Skyworks SKY77452 W-CDMA FEM</li>
<li>Triquint TQM676091 Power Amp</li>
<li>Apple 338S0626 Infineon GSM/W-CDMA Transeiver</li>
<li>Skyworks SKY77459 Tx-Rx FEM for Quad-Band GSM/GPRS/EDGE</li>
<li>Apple AGD1 STMicro 3-axis digital gyroscope</li>
<li>Apple A4 Processor</li>
<li>Broadcom BCM4329FKUGB 802.11n with Bluetooth 2.1 + EDR and FM receiver</li>
<li>Broadcom BCM4750IUB8 single-chip GPS receiver</li>
</ul>
<p><img class="alignnone" title="Apple iPhone 4 - Front" src="http://farm5.static.flickr.com/4098/4734775167_dcc3c284c8_b.jpg" alt="" width="900" height="469" /></p></blockquote>
<p>Apple iPhone 4 -Back</p>
<blockquote>
<ul>
<li>Apple 343S0499 &#8211; Texas Instruments Touchscreen controller</li>
<li>The Cirrus Logic 338S0589 audio codec</li>
<li>Samsung K9PFG08U5M 256G bit, x8 Flash MEMORY</li>
<li>338S0867 Dialog (Die marks D1815A &#8216;Ashley&#8217;) Power Management Unit</li>
<li>3383 Infineon X-GOLD 61x Baseband Processor</li>
<li>Intel 36My1EF &#8211; ELPIDA 128Mbits Mobile DDR SDRAM &amp; 28F128FM Intel/Numonyx NOR</li>
</ul>
<p><img class="alignnone" title="Apple iPhone 4 - Back" src="http://farm5.static.flickr.com/4101/4735414644_c99fda00c0_b.jpg" alt="" width="900" height="469" /></p></blockquote>
<blockquote>
<ul>
<li>Omnivision OV5650  5百万像素 CMOS QSXGA image sensor</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://letian.name/blog/?feed=rss2&#038;p=29</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

