<?xml version="1.0" encoding="gbk"?>
<rss version="2.0">
<channel>
 <title><![CDATA[串口读数据时，read（）函数怎么用？]]></title>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758]]></link>
 <description><![CDATA[Latest 20 replies of 串口读数据时，read（）函数怎么用？]]></description>
 <copyright><![CDATA[Copyright(C) ]]></copyright>
 <generator><![CDATA[PHPWind Forums by PHPWind Studio]]></generator>
 <lastBuildDate><![CDATA[Sun, 26 Jul 2026 07:19:48 +0000]]></lastBuildDate>
  <image>
 <url><![CDATA[images/rss.gif]]></url>
 <title><![CDATA[PHPWind Board]]></title>
 <link><![CDATA[http://121.40.142.80]]></link>
 <description><![CDATA[]]></description>
  </image>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[我的代码是：

package com.yxl.testserial.mini6410;
import android.R.integer;
import android.R.string;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView; 

import android.view.View;
import android.view. ..]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#115928]]></link>
 <author><![CDATA[rubin0513]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Wed, 07 Sep 2011 06:25:11 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[logcat看到的东西是

09-07 14:16:03.700: INFO/System.out(1679): byte len:4string len :12data:7e 45 00 ff 
09-07 14:16:03.700: INFO/System.out(1679): byte len:11string len :33data:ff 00 00 02 00 89 03 02 f0 41 7e 
09-07 14:16:04.680: INFO/System.out(1679): byte len:15string len :45data:7e 45 00 ff f ..]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#115926]]></link>
 <author><![CDATA[rubin0513]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Wed, 07 Sep 2011 06:21:56 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[为什么用20楼的代码，数据能在logcat看到，但是我的其他控件就卡住了]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#115925]]></link>
 <author><![CDATA[rubin0513]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Wed, 07 Sep 2011 06:20:47 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 20楼(ywkady) 的帖子]]></title>
 <description><![CDATA[不要用全局变量度数据，把数据封装了在线程中传递。]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#95310]]></link>
 <author><![CDATA[lxyc2001]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Sat, 18 Jun 2011 15:39:17 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[我也遇到过同样的问题，不过后解决了，把代码贴出来，分享一下，大家多多指教。

import com.friendlyarm.AndroidSDK.HardwareControler;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

public class MapGuider_Activity  ..]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#94354]]></link>
 <author><![CDATA[ywkady]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Wed, 15 Jun 2011 14:10:24 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 18楼(life173) 的帖子]]></title>
 <description><![CDATA[[s:3] 恩 这个你说的这样，这样子就没有乱码了。爱死你了！灰常感谢呀，这个终于解决了]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92741]]></link>
 <author><![CDATA[风月连城]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Fri, 10 Jun 2011 02:59:31 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[seri.read(fd, str1, 300);
String str=str1.toString();
myView.setText(str);

这段应该有问题，byte[]转到string，不能用toString()这个函数吧，你改下这样试试：
int len = seri.read(fd, str1, 300);
String str = new String(str1,0,len);
myView.setText(str);]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92727]]></link>
 <author><![CDATA[life173]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Fri, 10 Jun 2011 02:13:35 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 16楼(life173) 的帖子]]></title>
 <description><![CDATA[这个就要楼主慢慢查找原因了。]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92724]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Fri, 10 Jun 2011 02:08:07 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 12楼(风月连城) 的帖子]]></title>
 <description><![CDATA[会不会是端口参数设置的问题，两边设置需要一样才行，int openSerialPort(String devName,long baud,int dataBits,int stopBits )，里面有波特率，数据位，停止位，两边都需要一样，不然有可能出现数据不准的情况~]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92723]]></link>
 <author><![CDATA[life173]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Fri, 10 Jun 2011 02:03:42 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 14楼(风月连城) 的帖子]]></title>
 <description><![CDATA[是的，我第一次不会接受的到乱码。你检查一下那里出的问题。]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92694]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Fri, 10 Jun 2011 00:57:13 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 13楼(fll8888) 的帖子]]></title>
 <description><![CDATA[我这个情况还没到你那一步，我第一次发数据来就是乱码，你是已经能接受数据正确形式后出现的错乱情况啊]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92636]]></link>
 <author><![CDATA[风月连城]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 14:17:14 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 12楼(风月连城) 的帖子]]></title>
 <description><![CDATA[那是因为你没有清楚之前的数据，你查查linux的串口驱动怎么清楚数据的函数就可以的了。我那时候也是搞了那个清除很久的。]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92627]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 14:01:36 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 7楼(life173) 的帖子]]></title>
 <description><![CDATA[我把程序像你说的改过后，数据是有了，但却是一些不知所谓的乱码。我从调试工具发1234过来，结果str1值为49505152，发abcd过来结果str1值为979899100，然后再str=str1.tostring（）后str值为 【B@4725cf0&nbsp;&nbsp;[s:12]&nbsp;&nbsp;而且每次把相同的str1 tostring后都得到不同的值，只有前面的【B@4是一样的，后面几位 ..]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92626]]></link>
 <author><![CDATA[风月连城]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 13:57:01 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 10楼(风月连城) 的帖子]]></title>
 <description><![CDATA[嗯嗯，你很好很强大啊]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92425]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 04:52:22 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 7楼(life173) 的帖子]]></title>
 <description><![CDATA[恩 非常感谢 [s:6]&nbsp;&nbsp;我也发现了这个 上午弄出来了 但结果发现是错码 进一步研究中]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92418]]></link>
 <author><![CDATA[风月连城]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 04:02:34 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[我在c文件里面再做select和read函数的读取数据的。]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92400]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 03:28:15 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[你试试这样。

Timer timer = new Timer();
final Handler handler = new Handler(){
public void handleMessage(Message msg){
EditText readdisplay = (EditText) findViewById(R.id.readdisplay);
switch(msg.what){
case 1:{
readdisplay.setText(readserial.toString());
}
break;
}
super.handleMessage(msg);
}
}; ..]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92398]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 03:25:27 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[]]></title>
 <description><![CDATA[byte[] str1=null;
 seri.read(fd, str1, 300);

这个问题吧，读数据的缓冲区不能是null，它不会帮你分配内存再返回给你的，你要自己new，改做
 byte[] str1=new byte[300];
 seri.read(fd, str1, 300);

试试]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92377]]></link>
 <author><![CDATA[life173]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 03:05:41 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 5楼(fll8888) 的帖子]]></title>
 <description><![CDATA[我把程序改了下，但数据来了还是一运行到read（）就退出。你帮看看能不能改善下啊 原意是一按button按钮就接受数据显示在EditText里的，但运行的时候要是有数据来，到read（）程序就退出，我晕死，导师说进度完全停滞了。。。。帮帮我啊大哥[s:12]

public class Read4 extends Activity {
&nbsp;&nbsp;&nbsp;&nbsp;/** C ..]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#92323]]></link>
 <author><![CDATA[风月连城]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Thu, 09 Jun 2011 01:31:19 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[回 4楼(风月连城) 的帖子]]></title>
 <description><![CDATA[把select放在线程里面用好点吧！]]></description>
 <link><![CDATA[http://121.40.142.80/read.php?tid=12758#89750]]></link>
 <author><![CDATA[fll8888]]></author>
 <category><![CDATA[Android技术交流区]]></category>
 <pubdate><![CDATA[Tue, 31 May 2011 14:30:27 +0000]]></pubdate>
</item>
</channel></rss>