如何在C#中收到imei代码后从Teltonika FM1100获取gps nmea数据

时间:2013-11-29 11:17:05

标签: c# gps

在收到C#中的imei代码后,我没有从Teltonika FM1100获取gps nmea数据。请帮助我

课程计划     {         static IPAddress ipAd = IPAddress.Parse(“192.168.1.107”);

    static TcpListener myList = new TcpListener(ipAd, 3306);

    static Socket s;
    public void start()
    {

        myList.Start();

        Console.WriteLine("The server is running at port 3306...");

        Console.WriteLine("The local End point is  :" +
                          myList.LocalEndpoint);

        Console.WriteLine("Waiting for a connection.....");

        s = myList.AcceptSocket();

        Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);

        byte[] b = new byte[s.ReceiveBufferSize];

        int k = s.Receive(b);

        Console.WriteLine("Recieved...");

        for (int i = 0; i < k; i++)

            Console.Write(Convert.ToChar(b[i]));

        ASCIIEncoding asen = new ASCIIEncoding();

发送1字节数据作为确认

s.Send(asen.GetBytes( “T”));

//在确认后获取gps数据             byte [] ack = new byte [s.ReceiveBufferSize];

        int y = Program.s.Receive(ack);

        for (int q = 0; q < y; q++)
        {
            Console.WriteLine(Convert.ToChar(ack[q]));
        }

        s.Close();

        myList.Stop();


    }


    static void Main(string[] args)
    {


            Program pg = new Program();

            Thread th = new Thread(new ThreadStart(pg.start));

            th.Start();

    }
}

}

2 个答案:

答案 0 :(得分:0)

发送1字节数据作为确认

s.Send(asen.GetBytes("T"));

您需要发送01

喜欢

byte[] msg = new byte[] { 0x01 };

s.Send(msg );

答案 1 :(得分:0)

Teltonika FM1100不发送ASCII NMEA数据,您必须知道协议Codec12才能从teltonika读取GPS数据。