The web app now streams gcode over web sockets

This commit is contained in:
Sohel
2024-11-20 15:49:55 +01:00
parent ec5c788e92
commit 4896e64074
4 changed files with 107 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
import threading, websocket, time
ws = websocket.WebSocket()
ws.connect("ws://192.168.0.1:81")
# Reception needs to be done in a separate thread; you cannot
# assume that a given command will always result in exactly one
# response at a predictable time
# def receiver():
# while True:
# for l in ws.recv().splitlines():
# if isinstance(l, str):
# print(l)
# else:
# print(str(l, 'utf-8'))
# t = threading.Thread(target=receiver)
# t.start()
# ws.send("?") # realtime characters need no line terminator
# ws.send("$/axes/x\n") # line-oriented commands need \n at the end
ws.send("\r\n\r\n")
print(ws.recv())
ws.send("G0 X10\n")
print(ws.recv())