3

I want to plug in my drivers from the printer into my Raspberry Pi. I want to control the printer's axes by sending G-code directly from the Raspberry Pi command line (if possible) to the drivers.

Is that possible and if yes does anyone know how? As I stated above without using any 3rd party program/software.

agarza
  • 1,559
  • 2
  • 15
  • 33

3 Answers3

2

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.

craftxbox
  • 834
  • 5
  • 20
0

You can send the data to the serial port using echo, but you'll have to use cat to get the response.

Greenonline
  • 6,308
  • 8
  • 36
  • 65
user77232
  • 2,418
  • 11
  • 20
  • Your answer was flagged by the system as being a little short. Could you [edit] and expand your answer and provide examples of the commands in use (maybe with dummy data)? – Greenonline Aug 05 '21 at 14:56
0

Sending G-code to a printer via a serial interface is a bidirectional operation that requires waiting for acknowledgment from the printer before sending further commands. In theory, this shouldn't be needed and hardware flow control (or even XON/XOFF flow control if the hardware is not available) should be used, but that's not the way things were done. Thus, sending G-code with "dumb" commands like "cat" does not work.

If you want to send individual commands manually, you can use a program like Minicom (or screen's built-in serial terminal support) and process the acknowledgments yourself. But if you want to really stream print jobs, you need at least a minimal program for it. This can be written in a few lines of Python or Perl if you like. I know there are examples of such but I don't have the links handy and haven't tried any of them to be able to recommend one, anyway.

agarza
  • 1,559
  • 2
  • 15
  • 33