我已经在C#中配置了GPS设备并创建了一个监听器应用程序。我只从设备接收IMEI编号,而不接收任何GPS NMEA数据。但为了检查,当我在GPS Gate Server中检查时,它会在地图中显示移动。任何建议!
下面是数据处理的执行方式
TcpClient client = (TcpClient)tcpClient;
Byte[] bytes = new Byte[10000];
String data = null;
int i;
NetworkStream stream = client.GetStream();
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
}
Console.WriteLine(data);当它进入while循环时,它只是等待和休眠:(
发布于 2013-07-16 12:39:26
我认为这个设备的模式就像
Step1:接收IMEI号后
Step2:将"01“状态重放到相同的newwork
代码:
TcpClient newClient = (TcpClient)client;
NetworkStream ns = newClient.GetStream()
byte[] bytes = new byte[1024];
bytes = Encoding.ASCII.GetBytes("X");
Console.WriteLine("X");
ns.Write(bytes, 0, bytes.Length);发布于 2014-02-13 19:02:55
参考文献:
FMXXXX协议V2.7
发布于 2012-11-23 16:58:34
我认为你需要这样做(简单的解决方案)。如果您可以让它工作,也许您应该检查一些异步套接字/tcp连接
TcpClient client = (TcpClient)tcpClient;
Byte[] bytes = new Byte[10000];
String data = null;
int i;
NetworkStream stream = client.GetStream();
// Will get data as long as data is available after 1st read
do
{
i = stream.Read(bytes, 0, bytes.Length)
data = String.Concat(data, System.Text.Encoding.ASCII.GetString(bytes, 0, i));
}
while(stream.DataAvailable);
// Write the data to console (first time it should be IMEI
Console.WriteLine(data);
// Write 1 to the stream, note it must probably be byte value 1 -> 0x01
// Flush output stream after writing to prevent buffering
data = "";
// Now try if more data comes in after IMEI and 0x01 reply
do
{
i = stream.Read(bytes, 0, bytes.Length)
data = String.Concat(data, System.Text.Encoding.ASCII.GetString(bytes, 0, i));
}
while(stream.DataAvailable);
// Write date to console - move inside the while loop if data keeps coming in
Console.WriteLine(data); https://stackoverflow.com/questions/13524210
复制相似问题