开源改变世界

打开串行连接时意外重置。 #160

推推 grbl 3年前 (2023-01-21) 155次浏览

关闭
doenerkebap 打开了这个问题 2017 年 3 月 22 日 · 5 条评论
关闭

打开串行连接时意外重置。#160

doenerkebap 打开了这个问题 2017 年 3 月 22 日 · 5 条评论

注释

打开串行连接时意外重置。 #160

我正在尝试将 grbl 与一个小的 python 脚本连接起来。
但是当我打开连接时,grbl 似乎重置了,这是意想不到的。
通过 HTerm 连接到 grbl 时,我可以毫无问题地连接和断开连接。

import serial

# initialize serial connection
ser = serial.Serial(None, 115200, timeout=2)
# specify port separately to prevent auto-connecting
ser.port = 'COM3'

# open and print welcome message
ser.open()
welcome_message = ser.readlines()
print(welcome_message)

# close
ser.close()

# now open again
ser.open()
welcome_message = ser.readlines()
print(welcome_message) # <- im expecting this message to be empty.
# but apparently grbl reset, lost all coordinates, and shows welcome message again!
打开串行连接时意外重置。 #160
贡献者

这是 Arduinos 的正常行为。他们在重新连接时重置。

打开串行连接时意外重置。 #160
作者

这很有趣,因为我可以在不重置 Arduino 的情况下连接和重新连接 HTerm。

打开串行连接时意外重置。 #160
贡献者

HTerm 可能不会完全断开连接。如果您进行快速搜索,有很多在线资源可以解释连接时的重置。

打开串行连接时意外重置。 #160
作者
烤肉 评论了 2017 年 3 月 22 日  

我找到了解决方案:
pyserial/pyserial#124

添加一个简单的

ser.dtr = None
ser.open()

在公开通话阻止 Arduino 重置之前。

谢谢!

打开串行连接时意外重置。 #160

您还可以通过在 GND 和 RESET 引脚之间放置一个 10uF 电解电容来防止 Arduino 复位。
这意味着它永远不会通过 USB 端口的命令重置,因此您必须在闪烁时按下重置按钮。

喜欢 (0)