Skip to content
Discussion options

You must be logged in to vote

There is an inconsistency in your code. For pressure_adc you take 3 bytes from the buffer, while using ustruct() only the first two bytes are packed into the pressure_value, no matter how long the buffer is, which you supply. You could as well supply self.buf directly. Struct does not know 3 byte quantities. You could use >i with a 4 byte buffer, where the first byte is set to 0 and the remaining three bytes are from your returned data.
Edit: like
pressure_value=ustruct.unpack(">i", b'\x00' + self.buf)[0]

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@labodezao
Comment options

@robert-hh
Comment options

@jimmo
Comment options

@robert-hh
Comment options

Answer selected by labodezao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants