A very dumb, simple way to send GCODE to your printer from the terminal can be achieved with:
echo "gcode here" > /dev/ttyS0
/dev/ttyS0 can vary, It may be /dev/ttyACM0, /dev/ttyUSB0, or any similar with a different number.
You can figure out which path is correct for your printer with the command ls /dev/tty*
and comparing the results with your printer plugged in and unplugged, Whichever device pops up new should be your printer.
As well, Some printers may appear in /dev/serial/by-id/
instead of /dev/tty*
, so if you can't find your printer normally, try ls /dev/serial/by-id/
instead.
If this doesn't seem to work, you may need to change the serial settings using the command sudo stty -f /dev/ttyS0 115200
, replacing /dev/ttyS0 and 115200 to the device path and printer baud rate respectively.
If you are looking for a more bi-directional solution, you can use the command screen
, which is usually installed by default. You can use it like this:
screen /dev/ttyS0 115200
and exit by Control+A, then pressing D
Another solution would be the pronsole
utility from Printrun/Pronterface, which can be installed using sudo apt install printrun
and invoked with pronsole.py
and you can then connect to your printer with the syntax
connect /dev/ttyS0 115200
or simply connect
, as pronsole has the ability to autoconnect to your printer. Exit with the exit
command.