I'm working on a project for my masters where I'm trying to detect print errors using object detection and I want to be able to pause the printer when a potential fault is detected. However I can't seem to figure out the correct way to send G-code to my printer from a Python script. Does anyone happen to know how this works?
The process is pretty straightforward, you open a serial connection and send the instructions over the serial connection. The printer reports "
OK" when received (not when the command has been executed).
You can use pySerial to connect to a USB port with the correct speed, then send the command you want to execute (include the newline char).
You need to be aware that commands are buffered, if the buffer is full, the printer sends "OK" when there is a spot free in the buffer.