Skip to content

Instantly share code, notes, and snippets.

@amrithmmh
Created February 20, 2019 10:25
Show Gist options
  • Save amrithmmh/b22c9dc4e8bd610e7158d8586133b602 to your computer and use it in GitHub Desktop.
Save amrithmmh/b22c9dc4e8bd610e7158d8586133b602 to your computer and use it in GitHub Desktop.
import time
import serial
ser = serial.Serial( port='/dev/ttyUSB0', baudrate=250000)
if ser.isOpen():
ser.close()
ser.open()
ser.isOpen()
ser.write(("M114\r").encode())
out = ''# let's wait one second before reading output (let's give device time to answer)
time.sleep(1)
while ser.inWaiting() > 0:
out += str(ser.read(40))
if out != '':
print(">>" + out)
ser.close()
@ywtSteven
Copy link

Hi do you use this code to control 3D printer with Marlin firmware via USB connection using G codes and M codes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment