I've been looking for an answer at my problem, and I can't find anything really similar to my problem.
The thing is that I'm dealing with a value coming from a sensor in binary and I cast it into a hex value. Until that point there is no problem, but after it depends on my sensor but I can have a non define value of bytes.
My idea is to pack those bytes in groups of two bytes.
Here is what i'm doing :
val # This is the value of my sensor in binary
hexval = binascii.b2a_hex(val) # val casted into an hexadecimal value of n bytes
split = [hexval[i:i+2] for i in range(0, len(hexval), 2)] # Here split is an array of n words of two bytes.
With this code my problem is that all of my values are mixed, it doesn't seems that I'm packing my values as I should.
If someone can give me an hand with this.
Thanks
Louis