How to read GPS position direct from LAN using Python

In this Post: Accessing GPS Info from Pepwave MAX Routers - #3 by MartinLangmaid
@Guido_Biosca wanted to access the GPS data from a MAX over the LAN using python to open the NEMA socket on.60660. I tried knocking out a Python 3 script to do just that but didn’t have a MAX to hand with an active GPS so couldn’t test it.

Well I tested it and it didn’t work as expected. I managed to grab the positioning data from the socket:

$GPRMC,185546.0,A,5141.058053,N,00013.149088,W,50.8,94.9,180517,0.0,E,A*1B

but assumed incorrectly that the positioning data just needed to be pulled out of that string eg:
5141.058053N, 13.149088W

Of course in hindsight I should have easily spotted that it wasn’t valid lat longs. So what is it? Well its a decimal-decimal value, so it needs to be converted to degrees and minutes before its useful to us eg:

5141.058053 (ddmm.mmmmmm) = 51 41.058053 = 51 + 41.058053/60 = 51.684301 degrees

The following code does exactly that and now finally works hooray! :wink:

Example Output:

6 Likes

@MartinLangmaid: I’ve noticed an issue with occasionally getting a strange double sentence from the BR1-LTE (which has caused problems further downstream) and now always count the @ characters and just discard the sentence if there is more than one. Hope this helps. Kind regards, JG

3 Likes