Mobile GMaps Home Page
 FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups   RegisterRegister  
 ProfileProfile    Log in to check your private messagesLog in to check your private messages    Log inLog in 

A program/script to Converting from NMEA to Binary Hex (or v

 
Post new topic   Reply to topic   printer-friendly view    MGMaps Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
kocoman
Junior


Joined: 12 Oct 2007
Posts: 9

Phone Type: Unknown

PostPosted: Tue Apr 21, 2009 4:40 am    Post subject: A program/script to Converting from NMEA to Binary Hex (or v Reply with quote

I've search the web but can't seem to find such a thing:

Here is an c&p of the howto:

Converting from NMEA to Binary Hex:
Before the latitude and Longitude can be transmitted via Binary messages, it must be converted to hex data. The formula for converting is as follows:
First extra precision must be removed.
RMC Latitude = 3259.816776 N
Latitude = 3259.816
RMC Longitude = 09642.858868 W
Longitude = 09642.858
Now the decimal must be removed.
Latitude = 3259.816 * 1000
Latitude = 3259816
Longitude = 09642.858 * 1000
Longitude = 09642858
Add the sign bit if necessary and then convert to hex.
If latitude Direction is South then
Latitude = latitude * -1 Latitude = 3259816
Latitude = 31BDA8
If longitude Direction = West then
Longitude = Longitude * -1
Longitude = -09642858
Longitude = FF6CDC96
Converting From Binary HEX:
The longitude is transmitted as 4 bytes big endian Format
Converting back from HEX to Decimal can be more complicated.
Because of the word size, not all conversion routines can correctly convert the sign bit.
It is more reliable to remove the sign bit ,perform the conversion, and reapply the sign bit.
Note: Some languages do not allow a –0 for degrees. If the sign bit must be stored as part of the Latitude and Longitude, it is recommended that the Latitude and longitude be stored and passed as decimal Degrees.
Note: The following based on an integer being 32 bits. If the integer used is not 32 bits, then different algorithms might be necessary.
Converting Latitude:
Latitude = 3259816
Latitude = 31BDA8
The latitude is transmitted as 3 bytes (big endian) format
Latitude = 31BDA8 is transmitted as 31,BD,A8
Note: Since the upper word is removed, a filter will need to be implemented to determine if the latitude is negative.
latitude(2) = 31
latitude(1) = BD
latitude(0) = A8
Check to see if the Latitude is negative, by testing the MSB of the first byte.
Note: This will work accurately up to 84 degrees. 84 degrees and above will need either NMEA data or other filtering performed.
If latitude(2) && 0x80
{
\* must be negative
latitude(3) = 0xFF
}
else
{
\* must be positive
latitude(3) = 0x00
}
Now rebuild the raw integer
latTempInteger = latitude(3)
latTempInteger = latTempInteger << 8
latTempInteger += latitude(2)
latTempInteger = latTempInteger << 8
latTempInteger += latitude(1)
latTempInteger = latTempInteger << 8
latTempInteger += Latitude(0)
latTempInteger should now equal 3259816
Grab the sign bit
latitudeSign = sign(latTempInteger)
Remove the sign bit
latTempInteger = absolute(latTempInteger)
To get the degrees, just divide by 100000 and truncate after the decimal point
To get the decimal Minutes, just subtract degrees * 100000 from latTempInteger and divide the results by 1000
latitudeDegrees = integer( latTempInteger / 100000)
latitudeDecimalMinutes = (latTempInteger - (latitudeDegrees * 100000)) / 1000
Now all the elements are separated and can be used to perform any other conversions necessary.
latitudeSign
latitudeDegrees
latitudeDecimalMinutes
Converting Longitude:
The longitude is transmitted as 4 bytes (big endian format)
Longitude = -09642858
Longitude = FF6CDC96
The Longitude is transmitted as 4 bytes (big endian format)
Longitude = FF6CDC96is transmitted as FF,6C,DC,96
longitude (3) = FF
longitude (2) = 6C
longitude (1) = DC
longitude (0) = 96
Now rebuild the raw integer
longTempInteger = longitude (3)
longTempInteger = longTempInteger << 8
longTempInteger += longitude (2)
longTempInteger = longTempInteger << 8
longTempInteger += longitude (1)
longTempInteger = longTempInteger << 8
longTempInteger += longitude (0)
longTempInteger should now equal -09642858
Grab the sign bit
longitudeSign = sign(longTempInteger)
Remove the sign bit
longTempInteger = absolute(longTempInteger)
To get the degrees, just divide by 100000 and truncate after the decimal point
To get the decimal Minutes, just subtract degrees * 100000 from longTempInteger and divide the results by 1000
longitudeDegrees = integer( longTempInteger / 100000)
longitudeDecimalMinutes = (longTempInteger - (longitudeDegrees * 100000)) / 1000
Now all the elements are separated and can be used to perform any other conversions necessary.
longitudeSign
longitudeDegrees
longitudeDecimalMinutes

(search for the file GSM2000AN010_-_MT_Decoding_NMEA_Messages_for_Mapping_SW_-_Revision_1.01.pdf in google, see page 4-6)

TIA
Back to top
View user's profile Send private message
Cristian Streng
Founder


Joined: 28 Oct 2005
Posts: 4585

Phone Type: (many)

PostPosted: Tue Apr 21, 2009 8:04 pm    Post subject: Re: A program/script to Converting from NMEA to Binary Hex ( Reply with quote

kocoman wrote:
(search for the file GSM2000AN010_-_MT_Decoding_NMEA_Messages_for_Mapping_SW_-_Revision_1.01.pdf in google, see page 4-6)

Not found. But why would you need such a conversion? Is it for a specific device or software?
Back to top
View user's profile Send private message Visit poster's website
kocoman
Junior


Joined: 12 Oct 2007
Posts: 9

Phone Type: Unknown

PostPosted: Wed May 06, 2009 11:57 pm    Post subject: Reply with quote

Its ok I figure it partly out, the other part I can get with a memory patch

I am trying to convert some 1x and evdo tower gps location. I think its a requirement (According to arcx or gacobach, I forgot which site) says that it must have a gps thinggy at the tower.

Is this Firefox for mobile? It seems all pages are in korean

(look at the Base_Lat, Base_Long, divide the number by 14400, and put them in the google map)

HTTP_PHONE_SYSTEM_PARAMETER => BASE_ID:36884,NID:29,SID:2189,BASE_LAT:539812,BASE_LONG:1830280
HTTP_PROXY_INFO => PNAME:pasgw3;PTIME:20070305080819
Accept => */*
User-Agent => Mozilla/1.22 (compatible;KUN/2.1.0;LG-KB1500;CellPhone)

----

User-Agent: Mozilla/1.01 (compatible: MSMB101; HANS71_1.0; CellPhone)
HTTP_PHONE_NUMBER: 820163303044
HTTP_PHONE_SYSTEM_PARAMETER: BASE_ID:387, NID:24, SID:2180, BASE_LAT:540280,
BASE_LONG:1829180

----
samsung anycall BEX0178GK
GET / HTTP/1.0
Host: www.shindong.net:8080
User-Agent: Mozilla/1.22(compatible; PICO1.1;CellPhone)
Pragma: no-cache
HTTP_PHONE_NUMBER:019368xxxx
HTTP_PHONE_SYSTEM_PARAMETER : BASE_ID:9, NID:2, SID:2190, BASE_LAT:15977, BASE_LONG:59910
---
etc, search for HTTP_PHONE_SYSTEM_PARAMETER and base_lat in google.

there is a few that is wrong, ie: maps to 2N, 2E.. but most others are correct (maps to somewhere in Korea)

When converting the base_long (W/E) from Telus/Bell towers, the "W" part is not work with 14400 (or 0.25 per second), sorry I am bad at math.
, I had to use QCAT with a memory patch to put it in to work. (I have not solve the problem completely yet) can post about it later if anyone is interested.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MGMaps Forum Index -> Miscellaneous All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
MGMaps topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group