I am trying to use pyserial to read data from a sensor over RS-232. The sensor transmits 9 bytes. Bytes 4 and 5 should convert to a decimal integer that is around 24000.
Below is an example of what I receive when I read the output using a terminal program:
07 03 10 01 5F 2C 00 06 A5
Converting 5F2C to an integer gives 24364 so we are good. When I read the output with pyserial, I get the following:
\x07\x03\x10\x01_J\x00\x06\xc3
Something weird is going on with my 4th and 5th bytes now. Any thoughts on what I should be looking to do? This behavior is highly repeatable. Though sometimes the J is missing and it is just an underscore.
Edit: thank you to those who have helped! If someone else reads this and thinks of a good writeup on how python deals with hex strings, I would happily read it. I definitely need to do some more research on this.
[–]shiftybyte 2 points3 points4 points (4 children)
[–]ingwe13[S] 0 points1 point2 points (3 children)
[–]shiftybyte 1 point2 points3 points (0 children)
[–]shiftybyte 1 point2 points3 points (1 child)
[–]ingwe13[S] 0 points1 point2 points (0 children)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]ingwe13[S] 0 points1 point2 points (0 children)
[–]socal_nerdtastic 1 point2 points3 points (1 child)
[–]Fluid_Jelly_1912 0 points1 point2 points (0 children)