How to run gcode commands remotely on a Duet3 + RPi?



  • I have a Duet3 6HC board connected with a Raspberry Pi. It works, I can print files, view the web interface, etc. Is there a way I can programmatically (Python) run commands remotely on this setup? I have it set up where I can telnet into the RPi, but obviously entering gcode commands in the console doesn't work.

    I also have a Duet2 Wifi board where I can telnet into the board and just send commands to run them. I'm essentially looking for the same functionality on the Duet3 + SBC setup.



  • There is a phyton api if you search the forum

    and if you just want to run code from the console then on the pi do/opt/dsf/bin/CodeConsole (sudo if needed?)



  • Running sudo /opt/dsf/bin/CodeConsole from the console seems to work.

    Here's my code to log in using Python with the default user/pass. After this, sending commands works:

    tn = telnetlib.Telnet(printer_ip)
    print(tn.read_until(b"login: ").decode('utf=8', errors='ignore'))
    tn.write(b'pi\n')
    print(tn.read_until(b"Password: ").decode('utf=8', errors='ignore'))
    tn.write(b'raspberry\n')
    print(tn.read_until(b"$ ").decode('utf=8', errors='ignore'))
    tn.write(b'sudo /opt/dsf/bin/CodeConsole\n')
    print(tn.read_until(b"Connected!").decode('utf=8', errors='ignore'))
    
    tn.write(b'M114\n')
    sleep(1.0)
    print(tn.read_very_eager().decode('utf=8', errors='ignore'))
    


  • @TDK said in How to run gcode commands remotely on a Duet3 + RPi?:

    Running sudo /opt/dsf/bin/CodeConsole from the console seems to work.

    they've started moving away from running as root so wasn't sure if that applied to CodeConsole or not.

    you can also pipe commands for a one off echo M114 | sudo /opt/dsf/bin/CodeConsole
    (edit: you could also run the whole thing securely over ssh from another host as single command ssh pi@printer_ip "echo M114 | sudo /opt/dsf/bin/CodeConsole" (use with public key in authorized_keys (ssh-keygen and ssh-copy-id pi@printer_ip) and specify ssh -t or set up sudo on the remote host to not require password for the command in question))


Log in to reply