从GPS数据包中提取ID
我正在尝试为我的系统配置 GPS 设备。 GPS 设备按以下格式将数据包发送到我的 IP:
$$�W��¬ÿÿÿÿ™U042903.000,A,2839.6408,N,07717.0905,E,0.00,,230111,,,A*7C|1.2|203|0000÷
我能够提取纬度、经度和其他信息,但无法从字符串中提取跟踪器 ID。
根据手册,ID 是十六进制格式。数据包的格式是
$$<L(2 bytes)><ID(7 bytes)><command (2 bytes)><data><checksum (2 bytes)>\r\n
我不知道如何处理它,我尝试将其转换为十六进制..但它不起作用。
任何帮助将不胜感激。
I am trying to configure a GPS device to my systems. The GPS device send the data packet to my IP in the following format :
$�W��¬ÿÿÿÿ™U042903.000,A,2839.6408,N,07717.0905,E,0.00,,230111,,,A*7C|1.2|203|0000÷
I am able to extract the latitude, longitude and other information but I am not able to extract the Tracker ID out of the string.
According to the manual the ID is in hex format.And the format of the packet is
$<L(2 bytes)><ID(7 bytes)><command (2 bytes)><data><checksum (2 bytes)>\r\n
I don't know what to do with it, I have tried converting this to hex..but it didn't work.
Any help will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
了解更多信息怎么样?什么GPS?什么接口(USB、串口)?您使用什么语言工作?
你的数据看起来确实很奇怪。根据我使用 GPS 数据的经验,它通常是字母数字和分隔符,但看起来您要么有损坏的字符串,要么有非字母数字值。
根据您提供的附加信息进行更新:
您提供的 GPRS 手册解释了格式:
如果我理解正确,$$ 之后和数据字段之前的乱码字符不是可打印的 ASCII 字符。它们是实际的数值,一次提供一个字节。如果您将每个字节转换为十六进制格式的字符串并显示它,您应该明白我的意思。
我不太记得我的 PHP 了,但我认为 ID 可以通过如下方式形成十六进制格式的字符串:(
另外,根据文档的示例,删除或忽略任何 0xFF 值)
How about more information? What GPS? What interface (USB, serial)? What language are you working in?
Your data certainly looks odd. In my experience with GPS data, it's generally alphanumeric and separators, but it looks like you have either a corrupt string or non-alphanumeric values.
Update based upon additional information you provided:
The GPRS manual you supplied explains the format:
If I understand correctly, the gibberish characters after $$ and before the data field are not printable ASCII characters. They're actual numeric values, provided one byte at a time. If you convert each byte to a hexadecimal-formatted string and display it, you should see what I mean.
I don't remember my PHP well, but I think the ID could be formed into a hexadecimal-formatted string by something like this:
(also, strip out or ignore any 0xFF values, as per the documentation's example)