今天在做串口通信(下位机为plc)的时候发现同一份源码,timeout 一个设置为1,一个设置为0.01,但返回UI的速度完全不一样,前者慢的要死
我擦,这个竟然对通信有影响,赶紧查看官方文档:
- timeout = None: wait forever / until requested number of bytes are received
- timeout = 0: non-blocking mode, return immediately in any case, returning zero or more, up to the requested number of bytes
- timeout = x: set timeout to x seconds (float allowed) returns immediately when the requested number of bytes are available, otherwise wait until the timeout expires and return all bytes that were received until then.