为什么在 python 中使用 serial.tools.list_ports 检查串行端口时 Arduino 会重置?

Why Arduino reset when I check for serial port using serial.tools.list_ports in python?

当 DTR 信号变低时,Arduino 将重置通常发生在我们连接到串行端口时。 但是当我使用模块 serial.tools.list_ports 在 python 中编写代码时。当我检查可用端口时,Arduino 总是重置,除非我在其他程序中使用 Arduino 端口。 这是我的代码。

def serial_ports():
   return [p.device for p in serial.tools.list_ports.comports(include_links=True)]

为什么我会发生以及如何阻止它?

正如您正确提到的那样

Arduino will reset when the DTR signal goes Low, usually happens when we connect to Serial port.

您可以尝试在 5V 引脚和复位引脚之间连接一个 100 欧姆的电阻,以阻止复位信号随着 DTR 信号变低。