Python 3.4 decode HEX string

442 Views Asked by At

I'm facing issues to decode the following hex string in python 3.4:

b'"\x00\x08\x00\x83\x80\x00\x00\x00\x86\x11\x1dBA\x8c\xdb\xc0\\p\xfe@NR09G06654\x00\x00\x00'

I'm trying with a simple:

data = b'"\x00\x08\x00\x83\x80\x00\x00\x00\x86\x11\x1dBA\x8c\xdb\xc0\\p\xfe@NR09G06654\x00\x00\x00'

print(data.decode('ascii'))

But I am getting the following error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 4: ordinal not in range(128)

I have also tried to change to UTF-8

print(data.decode('utf-8'))

But with no success as the error is:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte

I have no clue what the problem could be.

1

There are 1 best solutions below

0
Roland Smith On

There are many communication protocols for GPS devices. A lot of devices use NMEA0183, but that is a plain text protocol and this is clearly not plain text.

If you're not running ms-windows, you should check if your GPS is supported by gpsd. It translates the signals from the GPS into something understandable. It has Python bindings available.