mirror of
https://github.com/usatiuk/EggbotWireless.git
synced 2025-10-26 08:47:49 +01:00
simple tool to send gcode
Signed-off-by: Stepan Usatyuk <usaatyuk@ustk.me>
This commit is contained in:
33
Utils/sendcode.py
Normal file
33
Utils/sendcode.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import serial
|
||||
import os
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Not 2 arguments")
|
||||
exit()
|
||||
|
||||
gcode = sys.argv[1]
|
||||
if not os.path.isfile(gcode):
|
||||
print("File doesn't exist!")
|
||||
exit()
|
||||
|
||||
ser = serial.Serial()
|
||||
ser.baudrate = 115200
|
||||
ser.port = sys.argv[2]
|
||||
ser.open()
|
||||
|
||||
if not ser.is_open:
|
||||
print("Can't open port")
|
||||
exit()
|
||||
|
||||
gcodef = open(gcode, "r")
|
||||
for line in gcodef:
|
||||
print(line)
|
||||
ser.write(line.encode())
|
||||
response = ser.readline().decode("utf-8").strip()
|
||||
if response != "OK":
|
||||
print("Error: " + response)
|
||||
exit()
|
||||
|
||||
ser.close()
|
||||
gcodef.close()
|
||||
Reference in New Issue
Block a user