使用 Pyserial,为什么在实例化 Serial class 和用于写入数据的 Serial 对象之间需要延迟?

Using Pyserial, why would a delay be required between the time that a Serial class is instantiated and the Serial object being used to write data?

已解决: 貌似打开端口的class实例化后,板子开机大约需要1秒后才能写入数据。不过,我不确定是否有任何解决方法。

原题: 我有一个基本脚本,它通过 USB type-B 将 G 代码发送到 Einsy Retro 打印机控制器板,从而转动步进电机。它工作正常,但前提是我在实例化串行对象和将 G 代码写入电路板之间强制延迟 909 毫秒。我使用 time.sleep() 让程序等待,任何小于 909 毫秒的延迟都会导致电机不旋转。我在两台不同的计算机上确认了这一点。

这是我正在使用的代码:

from serial import Serial
import time

_serial = Serial(str('COM3'), 115200, timeout=3, writeTimeout=3) # Instantiate Serial class

time.sleep(0.909) # 909 millisecond delay

_serial.write(b'G1 X300\n') # Write the GCode to the board

已解决:似乎在实例化打开端口的class后,板子启动大约需要1秒才能写入数据。不过,我不确定是否有任何解决方法。