send hexa number to sigfox
-
Hello,
I would like to send a 12 bytes hex number via sigfox.
But I need to transform this into bytes via the package (stuck.pack) and I can't because the biggest one is: double with 8 bytes.
this is my code :def bytes_trame(self): """cette fonction divise la trame de 12 octets en 3 trames de 4 octets pour ensuite les enpaqueter en bytes""" self.trame() trame_bytes=pack('>Q',int(self.trame_bin)) print("trame_bytes",trame_bytes) return trame_bytes
and this is the result :
rame_dec [0, 6, 1, 217, 2, 394] bin: 0b1000000001100001110110010010110001010 trame hex 0x100c3b258a trame_bytes b'\x00\x00\x00\x10\x0c;%\x8a'
It is not the same value between trame hex and trame_bytes
thank you for your reply
-
This post is deleted!
-
@quentho It is not the same value between trame hex and trame_bytes
For me it's the same value, it's only the printed output that differ
Have a Look
0x100c3b258a
is same as
0x000000100c3b258a (with all 0)b'\x00\x00\x00\x10\x0c;%\x8a'
so until \x10,\x0c no visible difference
then we have ";%", let look a the hexadecimal value in ascii code ';'=0x3B and '%'=0x25 , so it exactly the same number.
Try
import ubinascii
print(ubinascii.hexlify(trame_bytes)
if you have any doubt