Printing on serial printer via cups

5,469

I wouldn't go through cups:

CUPS is very problematic about RAW devices.

It's much easier to do it like so:

#!/bin/bash
cu -E `` /dev/ttyAMA0 < $1

(I can't remember for sure if you are requiring back-ticks (``) or single-quotes ('').

  • cu calls up the modem.
  • [-E ``] sets the escape sequence to null.
  • < redirects $1 to the modem over the serial line.
  • cu provides systematic modem locking, assuring you can't call up the modem in the middle of a call.

However, you also require to invoke the stty command to set your baud rate, parity, data bits, and stop bit.

STTY Manual

And one last thing... Make sure your serial device is owned by the user you are intending to run the command from:

chown user:group /dev/ttyAMA0

Invocation:

$> yourScriptIJustMadeForYou yourFileThatYouArePrinting

Then tie that script in /usr/bin to be interoperable with your broader requirement. You can also setup a new printer with no device in CUPS which, enable this script in it as a filter. Voila. Done.

Share:
5,469

Related videos on Youtube

bluepawel
Author by

bluepawel

Updated on September 18, 2022

Comments

  • bluepawel
    bluepawel over 1 year

    I'm trying to set up my serial printer with cups, but I can't see any serial port in cups config page nor via lpinfo -v. I have serial port at /dev/ttyAMA0. I was trying to set proper permissions for /dev/ttyAMA0 and /usr/lib/cups/backend/serial, but without success.

  • bluepawel
    bluepawel about 10 years
    Yeah, but I can't see any serial ports in cups, so I can't select "Serial Port #1" option.
  • slm
    slm about 10 years
    Don't you see /dev/tty...? That's the device to select.
  • slm
    slm about 10 years
    Can you get us the output of lshw?
  • bluepawel
    bluepawel about 10 years
    I don't have lshw and it isn't available in repository for my system (Arch Linux).
  • slm
    slm about 10 years
    That's strange, I'm pretty sure that's avail. for Arch. Do you have hwinfo?