Pyserial Sending More than One Byte

后端 未结 1 1665
梦毁少年i
梦毁少年i 2021-01-15 16:14

First time poster.

Before I start, I just want to say that I am a beginner programmer so bear with me, but I can still follow along quite well.

I have a wire

相关标签:
1条回答
  • 2021-01-15 16:59

    You'll likely need to pull your number apart into multiple bytes, and send the pieces in little endian or big endian order.

    EG:

    low_byte = number % 256
    high_byte = number // 256
    

    That should get you up to 65535. You can reconstruct the number on the other side with high_byte * 256 + low_byte.

    0 讨论(0)
提交回复
热议问题