从设备读取数据?

时间:2012-04-02 05:48:34

标签: java gps netty

开发Netty应用程序。在那里我正在读取来自客户端的数据包。但是有一种名为Teltonika的设备。该设备首先发送IMEI号码,一旦我们确认,它就会发送TrackPacket。

但这里的问题是它发送了正确的IMEI号码,但发送的TarckPacket仍然是一种不可读的格式。请帮帮我。

'IMEI NO: [0, 15, 51, 53, 50, 56, 52, 56, 48, 50, 50, 55, 57, 49, 55, 49, 53]'

发送IMEI号码的设备格式正确,但下面的跟踪数据包格式不正确。

跟踪数据包:

[0,0,0,0,0,0,0,-61,8,4,0,0,1,53,-117,86,80,-56,0,46,60,22 ,-128,7,-60,-27,40,3,-118,1,92,10,0,0,0,6,2,1,1,2,0,3,9,0,23 ,10,0,13,24,0,0,1,-57,0,0,0,0,0,0,1,53,-117,85,101,-18,0,46, 60,22,-128,7,-60,-27,-112,3,-119,1,92,9,0,0,0,6,2,1,1,2,0,3,9 ,0,27,10,0,10,24,0,0,1,-57,0,0,0,0,0,0,0,5,5,17,84,123,21,0 ,46,60,22,-128,7,-60,-27,-112,3,-121,1,92,8,0,0,0,6,2,1,1,2,0, 3,9,0,27,10,0,12,24,0,0,1,-57,0,0,0,0,0,0,1,53,-117,83,-115 ,-78,0,46,60,22,-128,7,-60,-27,-48,3,-121,1,91,11]

我做了什么:

StringBuffer sbs = new StringBuffer(); 
buf = (ChannelBuffer) e.getMessage();
while(buf.readable()) 
{
sbs.append((char) buf.readByte()); 
} 
msg = sbs.toString();
System.out.println(msg);
byte[] request = new byte[] { 0x01 };    
e.getChannel().write(ChannelBuffers.wrappedBuffer(request)); 
System.out.flush();

1 个答案:

答案 0 :(得分:0)

如果是移动gsm或cdma设备,则搜索“AT命令” 触发这些命令COM端口,返回被激活命令所需的结果..