Page 1 of 1
Decode Little Endian
Posted: Tue Jul 11, 2023 9:51 pm
by hrcap
Hi All
I am receiving data from a GPS receiver which comes out as the below:
µbˇP–±Á17h~N-˙¶·ù€vÅ˚Œ+
$H∆oê_@ÉPωˇºˇÎˇo
The user manual for the GPS reads:
Packets are sent and received in U-Blox UBX binary format, consisting of a header, optional payload, and a checksum. The header is used to identify the packet start, contents, and payload length. The checksum is used to verify the packet transmission.
Data in the packet is encoded in Little-Endian and uses only integer fields - all double values are multiplied with some value and rounded to the nearest integer. Up to 32-bit values are used.
the link to the user manual is here
https://www.racebox.pro/products/racebo ... 1856094c08
... and the relevant info starts on Page 2
Can anybody assist as to how I might go about decoding this into readable data please?
Many Thanks
Re: Decode Little Endian
Posted: Wed Jul 12, 2023 2:57 pm
by dunbarx
Hi.
Little Endian only specifies whether byte order is most-to-least significant or least-to-most.
The string you have returned looks rather more foreign. I tried to find some sort of guide to the U-Blox thing, but could not really get a handle on it.
Craig
Re: Decode Little Endian
Posted: Wed Jul 12, 2023 3:08 pm
by hrcap
Hi Craig
Thanks for your reply... im starting to make a little bit of progress. I have decoded the original data into:
Code: Select all
put urlencode(t_endian) into t
replace "%" with " " in t
...gives:
B5b FF 01P 00 90 88 00 00 E4 07 08 02 00 00 22 F0 FF FF FF FF 00p89 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 98 BD FF FF FF FF FF FF 00v 84 DF 00 00 00 00 00 00 00 00+N 00 00 80 A8 12 01 0F 27 00I 11 00 2C 00 E9 03 E3 FF B9 FF E9 FFk FD
This looks a little bit more like it should... however in trying to convert the relevant parts of the above into what it should be I'm stuck again... for example the manual states:
E6 07 should equal 2022
I've tried all of the following but can't find a way to get it to come out to 2022..:
Code: Select all
put baseConvert("E607" ,16,10) into t
... this comes out as 58887
Code: Select all
put baseConvert("E6" ,16,10) into t
... this comes out as 230
Code: Select all
put baseConvert("07" ,16,10) into t
... this comes out as 7
where the manual gives a shorter example of e.g. :
0A should equal 10
Code: Select all
put baseConvert("0A" ,16,10) into t
... gives the correct result of 10
.... so my knowledge is too limited here to know how to convert any more than one pair of digits
... any ideas?
Many Thanks
Re: Decode Little Endian
Posted: Wed Jul 12, 2023 3:20 pm
by Thierry
I've tried all of the following but can't find a way to get it to come out to 2022..:
Code: Select all
put baseConvert("E607" ,16,10) into t
... this comes out as 58887
Hi,
As said in the subject: little Endian.
Have you tried reversing the 2 bytes, as:
Code: Select all
put baseConvert("07E6" ,16,10) into t
Regards,
Thierry
Re: Decode Little Endian
Posted: Wed Jul 12, 2023 3:59 pm
by FourthWorld
Look into the binaryDecode function. I believe you'll want the options specifying host byte order.
https://livecode.fandom.com/wiki/BinaryDecode
Re: Decode Little Endian
Posted: Thu Jul 13, 2023 9:08 am
by hrcap
Ok thank you very much for the replies guys.
• Thierry: your suggestion of reversing the order worked, thank you.
• FourthWorld: I am still trying to get my head around binaryDecode
...however I think my stumbling block may be in my first steps
the raw data received from the device is e.g:
µbˇP†dIÁ
3Ûˇˇˇˇ˜ß%&‰òΩˇˇˇˇˇˇvÑfl NÄ®'d·˝Î˝i˝[˚àc[
when I convert that raw using:
Code: Select all
put urlencode(t_raw_data) into t_data_in_pairs
replace "%" with " " in t_data_in_pairs
it comes out as:
B5b FF 01P 00 A0dI 16 E7 07 07 0D 073 1E F3 FF FF FF FF F7 A7 25 26 00 00 E4 00 00 00 00 00 00 00 00 00 00 00 00 00 98 BD FF FF FF FF FF FF 00v 84 DF 00 00 00 00 00 00 00 00+N 00 00 80 A8 12 01 0F 27 00d E1 FD EB FDi 02 1D FD 5B FB 88 06c 5B
Now this is mostly correct but not perfect... for example:
• the user manual says the:
- 1st 4 digits should be: B5 62
- 2nd 4 digits should be: FF 01
• you will also notice that some of the data isn't pairs of numbers, for example:
- 01P
- A0dl
- 00v
- 00+N
- 00d
- FDi
- 06c
any ideas on why this might be please?
Re: Decode Little Endian
Posted: Thu Jul 13, 2023 12:22 pm
by hrcap
... and there we go after spending all day on this yesterday and deciding I need to ask the question on here, I end up working out the answer 5 minutes after asking the question
this should have been the initial decode from little endian:
Code: Select all
put the c_endian of me into t_data_raw --raw data in little endian
---
--decode the endian into hexadecimal
put binarydecode("H*", t_data_raw, t_data_hex) into theNumConversions
---
Re: Decode Little Endian
Posted: Thu Jul 13, 2023 9:10 pm
by jacque
hrcap wrote: ↑Thu Jul 13, 2023 12:22 pm
... and there we go after spending all day on this yesterday and deciding I need to ask the question on here, I end up working out the answer 5 minutes after asking the question
It's always like that. All you need to do is ask.
This is a story my father told. He said both men in the conversation swore it was true. Names have been changed to protect the innocent.
Two men in the office elevator:
Man 1: What is Joe's last name?
Man 2: Joe who?
Man 1: Joe Smith.
Man 2: I don't know.