[英]JAVA - Retrieve NMEA frame from a GPS Receptor -More details about RandomAccessFile WriteBytes method
我有一个GPS接收器。 我在Eclipse控制台中检索了这一帧捕获的所有NMEA帧。
编辑-这是我的完整课程:
public class GPSFrame extends Observable implements Runnable
{
static Thread myThread=null;
static BufferedReader br;
static BufferedWriter wr;
static PrintWriter out;
static InputStreamReader isr;
static OutputStreamWriter osw;
static java.io.RandomAccessFile port;
/** CONSTRUCTOR **/
public GPSFrame()
{
myThread=new Thread(this);
}
public void start()
{
try
{
port=new java.io.RandomAccessFile("COM5","rwd");
port.writeBytes("\r\n");
port.writeBytes("c,31,0,0,5\r\n");
port.writeBytes("T,1000,1\r\n");
}
catch (Exception e){ System.out.println("start "+e.toString()); }
// The thread start automatically run() method
myThread.start();
}
/**********************************************************************************************
*************************** RETRIEVE GPS FRAMES AND SEND TO SERVEUR **************************
**********************************************************************************************/
public void run()
{
System.out.println("lecture COM...");
// INFINIT LOOP - GPSFrame is always listening for the GPS receptor
for(;;)
{
String st = null;
try
{
st=port.readLine();
String[]gpsframe=st.split(",");
/* IMPORTANT - DON'T FORGET SETCHANGED() or GPSFrame'll never
* notify UPDATE() ServerBoard method - We'll never see any changes */
setChanged();
notifyObservers(st);
}
catch (IOException e){ System.out.println(e.getMessage()); }
// Show in console
System.out.println(st);
}
}
}
为此,我在网上搜索。 但是我不明白start()方法 。 c , T的含义是什么? 我们给writeBytes的数量是什么?
(我也发布了有关此代码的问题,但由于另一个原因。如果您能帮助我,我将非常感谢JAVA-GPS RECEPTOR在控制台中发送奇怪的/编码的帧 )
有人可以启发我吗?
在此先多谢! :)
最好的祝福,
豆腐
那么,作为文档writeBytes状态,它只是写字节顺序(在你的情况下正常的ASCII符号: c
, ,
, 3
, 1
等)的文件。
双引号之间的所有内容均按原样编写,没有多余的逻辑来理解T
, c
或特定数字的含义。
希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.