pack binary trame
-
hello,
i receive a value from 7 sensors. After that i create a binary trame to send in sigfox. But i can't send the hexa value in sigfox so i try to use the pack function but i have a probleme with the fmt . i don't know which ftm choose. For the moment my code but it's not working because i receive only
b'\x00\xb0\x00\x00\x00\x00\x00\x00'class tools: def trame(capt1,capt2,capt3,capt4): result= (1 << 4) | 0001 result = (result << 10) | capt1 result = (result << 4 ) | 0010 result = (result << 10) | capt2 result = (result << 4 ) | 0011 result= (result << 12 ) | capt3 """result = (result << 4 ) | 0100 result= (result << 8 ) | capt4""" print(hex(result)) result=pack('hhl', result) return result -
@quentho If you have three format specifiers in ustruct.pack(), you have to supply three values. The questions is, how you want to pack that into a message? And what is the value range of each sensor? And why do you add these 0001, 0010, 0011, 0100 (1,2,3,4) pattern into the string?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login