0

I have a GPS receptor. I retrieve all the NMEA frames captured by this one in the Eclipse console.

EDIT - This is my full class :

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);
        }
    }   
}

To do that, I searched on the net. But I don't understand the start() method. What is the signification of c, T and the number we give to writeBytes ?

(I've also posted a question about this code, but for another reason. If you can help me, I shall be extremely grateful JAVA - GPS RECEPTOR sending strange/encoded frames in console)

Can someone enlighten me please ?

Thanks a lot in advance ! :)

Best regards,

Tofuw

4

1 回答 1

0

好吧,作为writeBytes状态的文档,它只是将字节序列(在您的情况下为常规 ASCII 符号:c,31等)写入文件。

双引号之间的所有内容都按原样编写,没有额外的逻辑来理解Tc特定数字可能意味着什么。

希望有帮助。

于 2013-12-19T09:22:01.877 回答