Search code examples
pythongpshex

Python how to decode code from GPS to NMEA?


I am trying to program a GPS (I have a GPS "here2" + CubeOrange + Raspberry PI 4 Model B).

From the circuit I get this result:

`b'3DA\x95F\xaa?p%b=,XIB\n'

3344470000000000000000cf19c93f0a

b'3DT\x00\x00\x00\x00\x00\n'

334441f959aa3f31895f3df15749420a

b'3DG\x00\x00\x00\x00\x00\x00\x00\x00\xcf\x19\xc9?\n'

33445400000000000a

b'3DA\xa0_\xaa?T\xb7]=\xa4WIB\n'

3344470000000000000000cf19c93f0a` ...

I have a question - what format is this b'3DA\x95F\xaa?p%b=,XIB\n' (I can't find information anywhere on the internet)

I converted it to hex 3344470000000000000000cf19c93f0a but I don't know if it's right. I need in decimal to have information about speed, altitude, position (above is just a code snippet). I made it hex but in my opinion it is wrong.

'b'3.. - is the headline, \n-newline character, the rest I do not understand..

Thank you for your help.

I searched for information on the Internet but did not find an answer.


Solution

  • I guess the data is packed info byte-array to unpack data use the Python struct library

    >>> import struct
    >>> data = b'3DA\x95F\xaa?p%b=,XIB\n'
    >>> struct.unpack("ffff",data)
    (-3.902983930259824e-26, 2.372699393234608e+29, 2.6912996570899184e-12, 9.354554656484993e-33)
    >>>