Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

tkinter - Using pySerial to send gcode

This may be a bit of a long shot but I can't figure out the problem here. I'm trying to build an interface on my laptop using tkinter and pySerial to control my 3D-printer. I've got a function that contains this piece of code (Yes, I imported time and serial):

ser = serial.Serial('COM3', 115200)
time.sleep(2)
ser.write(str.encode("G28
"))
time.sleep(1)
ser.close()

This sends the gcode "G28" to the 8bit mainboard of my 3d printer (Ender3), which makes it home. This is very hit and miss however. One time it works, the other it doens't. When it doesn't, it seems to reset/restart the printer. Anyone have a clue what could cause this?

question from:https://stackoverflow.com/questions/65904566/using-pyserial-to-send-gcode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have found the problem. Arduino and similar 8bit boards reset when running 'ser.close()'. Removing that line fixed it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...