Ruida laser skill: prepare and load jobs, never run them
FreeCAD/DXF to .rd conversion, named upload to controller memory with idle check and read-back verification, read-only status/file listing, and a fake controller for dry runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
4e957509cc
11 files changed
+695
No files matched your search
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""fake_ruida.py: a stand-in Ruida controller on 127.0.0.1:50200 for dry runs.
|
||||
|
||||
Logs every command it receives (unswizzled hex) to the .log file, ACKs, answers the status and
|
||||
document-name reads the way the real controller does (no reply past the last file), and adds
|
||||
uploaded file names to its list. Pass "busy" to report a running job so you can watch
|
||||
rdupload.py refuse. Test here first; never point untested code at a real laser.
|
||||
|
||||
usage: fake_ruida.py [busy] fake.log
|
||||
"""
|
||||
import socket, sys
|
||||
from meerk40t.ruida.rdjob import swizzles_lut, encode32, decodeu14
|
||||
SW, UN = swizzles_lut(0x88)
|
||||
BUSY = len(sys.argv) > 1 and sys.argv[1] == "busy"
|
||||
files = ["PART01", "PART02"]
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.bind(("127.0.0.1", 50200))
|
||||
log = open(sys.argv[-1] if sys.argv[-1].endswith(".log") else "fake.log", "a")
|
||||
upload = bytearray()
|
||||
def send(addr, raw): s.sendto(bytes(SW[b] for b in raw), addr)
|
||||
while True:
|
||||
pkt, addr = s.recvfrom(2048)
|
||||
data = bytes(UN[b] for b in pkt[2:])
|
||||
log.write("RX " + data.hex() + "\n"); log.flush()
|
||||
if data[:2] != b"\xe8\x01" or decodeu14(data[2:4]) <= len(files): send(addr, b"\xcc")
|
||||
if data[:2] == b"\xda\x00":
|
||||
mem = data[2:4]
|
||||
v = {b"\x04\x00": 1 if BUSY else 0, b"\x02\x00": 21 if BUSY else 22, b"\x02\x05": len(files)}.get(mem, 0)
|
||||
send(addr, b"\xda\x01" + mem + encode32(v))
|
||||
elif data[:2] == b"\xe8\x01":
|
||||
n = decodeu14(data[2:4])
|
||||
if n <= len(files): send(addr, data[:4] + files[n - 1].encode() + b"\x00")
|
||||
else:
|
||||
upload += data
|
||||
if b"\xe7\x01" in upload and upload.endswith(b"\xd7"):
|
||||
i = upload.index(b"\xe7\x01") + 2
|
||||
files.append(upload[i:upload.index(b"\x00", i)].decode()); upload = bytearray()
|
||||
Reference in new issue
Block a user