最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Python writing list of bytes to serial port - Stack Overflow

programmeradmin1浏览0评论

From reading serial data input I have a queue named rxQueue, which is copied to a list named rxData.
Then, for testing, the list should be send back to the sender over serial.
But writing to serial, I always get the Exception " 'bytes' object cannot be interpreted as an integer ".
I've read many posts, but none of the solutions seem to work for me. (Python 3.13.2 )
What am I doing wrong?

rxQueue shows in the debugger (in this case) something like

    0 = b'\x02'
    1 = b'\x01'
    2 = b'\x01'
    3 = b'\x00'
    4 = b'\x01'
    5 = b'\x00'
    6 = b'E'
    7 = b'T'
    8 = b'X'
    9 = b'\x03'
    len() = 10

    COMport = serial.Serial(COMportName, baudrate=baudRate, timeout=.5)

    rxData = list (rxQueue.queue)  # rxData looks the same as rxQueue in the debugger

    byteArray = bytearray(rxData)  # Exception: " 'bytes' object cannot be interpreted as an integer "

    COMport.write(byteArray)
发布评论

评论列表(0)

  1. 暂无评论