我有一个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 sending strange/encoded frames in console)
有人可以开导我吗?
提前多多感谢! :)
致以最诚挚的问候,
Tofuw
答案 0 :(得分:0)
好吧,作为writeBytes状态的文档,它只是写入字节序列(在您的情况下是常规ASCII符号:c
,,
,3
,{{ 1}}等)到文件。
双引号之间的所有内容都是按原样编写的,没有额外的逻辑来理解1
或T
或特定数字可能意味着什么。
希望有所帮助。