int fd = HardwareControler.openSerialPort("/dev/s3c2410_serial2",
9600, 8, 1);
int len = 1000;
byte[] buf = new byte[len];
if (HardwareControler.select(fd, 2, 20) == 1) {
int n = -1;
String str = null;
while (n == -1) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HardwareControler.read(fd, buf, buf.length);
str =new String(buf);
n = str.indexOf("$GPGGA,");
}
str = str.substring(n, 50);
txtview.setText(str);
HardwareControler.close(fd);
} else {
txtview.setText("无数据");
}
自己顶一个。目前能接收到数据,只是接收的数据比较乱