问题描述
我试图从GPS追踪设备转换GPS数据。该公司提供了协议手册,但尚不清楚。我能够从我从设备收到的数据包中解码大部分数据。通信是通过TCP / IP进行的。我在解码经度和纬度的十六进制值时遇到问题。下面是手册中的一个例子:
例子:22º32.7658'=(22X60 + 32.7658)X3000 = 40582974,然后转换成十六进制数字
40582974 (Decimal)= 26B3F3E(十六进制)
最后的值是0x02 0x6B 0x3F 0x3E。
我想知道如何从十六进制反转为经度和纬度。该设备将发送26B3F3E。我想知道获得22º32.7658的过程。
这个协议适用于GT06和相邻的908。
-
将所有四个值存储在无符号的32位变量中。 code>,
v2 = 0x6b
,v3 = 0x3f
,v4 = 0x3e
。 -
计算
(v4
-
将其转换为浮点数并将其除以30,000.0(您的3,000是一个错误),这会给你1,352.765
-
砍成整数并除以60.这会给你22个。
> -
将步骤4中得到的数字乘以60,然后从步骤3中得到的数字中减去它。这会给你
1352.765 - 22 * 60
或32.765。
Store all four values in unsigned 32-bit variables.
v1 = 0x02
,v2 = 0x6b
,v3 = 0x3f
,v4 = 0x3e
.Compute
(v4 << 48) | (v3 << 32) | (v2 << 16) | v1
this will yield a variable holding the value 40582974 decimal.Convert this to a float and divide it by 30,000.0 (your 3,000 was an error), this will give you 1,352.765
Chop to integer and divide by 60. This will give you the 22.
Multiply the number you got in step 4 by 60 and subtract it from the number you got in step 3. This will give you
1352.765 - 22*60
or 32.765.
您的回答 22
, 32.765
。
I am trying to convert GPS data from GPS tracking device. The company provided protocol manual, but it's not clear. Most of the data I was able to decoding from the packets I received from the device. The communication is over TCP/IP. I am having a problem decoding the hex value of the longitude and latitude. Here is an example from the manual:
Example: 22º32.7658’=(22X60+32.7658)X3000=40582974, then converted into a hexadecimal number40582974(Decimal)= 26B3F3E(Hexadecimal)at last the value is 0x02 0x6B 0x3F 0x3E.
I would like to know how to reverse from the hexadecimal to longitude and latitude. The device will send 26B3F3E. I want to know the process of getting 22º32.7658.
This protocol applies to GT06 and Heacent 908.
There's your answer 22
, 32.765
.
这篇关于如何将GPS经度和纬度从十六进制转换而来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!