CUPS and Multiple Identical Printers

CUPS (Common Unix Printing System) and multiple identical printers can be a pain in the butt. Especially, if the printer manufacturers are naughty and do not make the printers serial number public on usb connect.

This shall be a little how-to for all those people who discover the same trouble!

The setup I had to deal with:
– Ubuntu (x64 Server)
– CUPS 1.2.8
– 2x Kyocera Mita FS-1030D attached via USB

The problem:
If you connect both printers, they both get the same ID:

# lsusb
Bus 004 Device 093: ID 0482:0015 Kyocera Corp.
Bus 004 Device 092: ID 0482:0015 Kyocera Corp.

AND (even worse) are both mapped to usb://Kyocera/FS-1030D

An auto-installation on the cups web interface will result in a success, BUT you’ll only be able to print on the first of the two USB devices. So not a good solution.

OK, this is where you want to go:

1. Set up the printer(s) using the web interface.
2. Fire up your console and goto /dev/
3. Find the files usblp0 and usblp1 (depending on your system, there might be a sub folder named ‘usb’. If so, see if there are two files named ‘lp0′ and ‘lp1′ in existance) and pad yourself on the back ;)
4. Edit /etc/cups/printers.conf with your favourite editor.
5. You’ll find the first printer which looks like this:

<Printer Kyocera_FS-1030D_USB_1>
Info Kyocera FS-1030D
Location Local Printer
DeviceURI usb://Kyocera/FS-1030D
State Idle
StateTime 1231879830
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job


Leave it like this!! (Otherwise, CUPS web interface will harass you with newly found printers.)

6. Right under the first printer you’ll find the second printer (and the third, the fourth, […]) named <Printer Kyocera_FS-1030D_USB_2> for example. THERE (and on possibly other following identical printers) change the following line

DeviceURI usb://Kyocera/FS-1030D

to

DeviceURI file:/dev/usblp1

The other printers below need their equivalent usb device link. You could to a

# echo usblp1 > /dev/usblp1

which will actually print the word ‘usblp1′ on the printer. If you do so with all of your printers, you’ll know the device link ;)

Ok, we are not quite there, yet. I found a strange behaviour of CUPS, when you switch the printers off over night and turn them on again the next morning. Somehow, having this configuration, CUPS simply quits without following any shutdown procedures. No log entries, no good bye letter, nothing.

In order to detect and overcome this situation, this little script monitors the cups daemon and restarts it if necessary:


#!/bin/bash
#
# cupsMon.sh -- A Monitor for CUPS
#
# @author Henning Weiler
# @version 1.0
#

if [ -r /var/run/cups/cupsd.pid ]; then
CUPSPID=$(cat /var/run/cups/cupsd.pid)

if ps --pid $CUPSPID | grep "cupsd" >/dev/null; then
exit 0
else
rm -f /var/run/cups/cupsd.pid /var/run/cups/cups.sock
/etc/init.d/cupsys start
fi
else
/etc/init.d/cupsys start
fi

I put it in my root home directory and gave it a little ‘chmod +x’.

In your /etc/crontab add the following line:

9 * * * * root /root/cupsMon.sh >> /dev/null

This will run the monitor every 9 minutes. I did not want to run it every minute, since switching on multiple printers may take a while.

If you have any questions or concerns, please comment.

8 Comments

  • Dagobert

    Hi,
    Das ist sehr interessant! Vielleicht oder eher sogar wahrscheinlich kann man was wegen der usb/dev geschichte mit den guten udev-rules machen. In der ct gab es zu dem Thema letztlich einen guten Artikel, der mich endlich im Bezug auf udev erleuchtet hat.
    Insbesondere solltest du noch einmal gr?ºndlich uberlegen, ob du dich darauf verlassen willst, dass lp1 nicht vielleicht die Druckerzuordnung wechselt, weil die Drucker in einer anderen Reihenfolge angeschaltet werden.
    Da kann dann wirklich nur noch udev helfen!

    Greets

  • J??rn Frenzel

    Yeah!

    Vielen herzlichen Dank f?ºr die ausf?ºhrliche Anleitung. Genau dieses Problem qu?§lt uns schon sehr lang.

    Gr?º?üe

    J.Frenzel

  • Milton

    Hi. Thank you for this post, was really useful for me. Now I have my two Samsung ML-1665 printers working, but I found a problem.

    Although both printers are working, sometimes the system change the usb ports, and the usblp0 device points to the printer B, and the usblp1 one to the printer A. This happens randomly. It may be working two months without problems, and then it gets crazy again for a few days.

    Did you have a similar problem?

    Thanks!

  • Harold

    Just find the printer serial numbers and use that to seperate them.

    use lpinfo -v to find them:

    direct usb://Samsung/ML-1660%20Series?serial=Z4ZFBKBZ400457W.
    direct usb://Samsung/ML-1660%20Series?serial=Z4MSBKFZA00183H.

    Then use that to setup the printer.conf:
    DeviceURI usb://Samsung/ML-1660%20Series?serial=Z4MSBKFZA00183H.
    etc…

  • bmxpert1

    Thanks for this delightful post, it got me out of quite a jam.

    Milton,
    I have the same issue you are having but with some Zebra TLP2844s. My solution was to create a “dummy” printer with the DeviceURI = usb://Zebra/TLP2844 and then the 2 printers I actually want to use I am able to use the file:/dev/usbl0, and file:/dev/usblp1. From the tests I have done thus far, restarting is fine, powering down is cool, powering printers off is no problem. The only thing that breaks it is if you plug them into different usb ports obviously, but I only found this to break once you restart after switching ports. Anywho, maybe this will help someone.

    Harold’s solution would have worked for me but apparently Zebra doesn’t think it’s necessary to give the printers serial numbers, which is why this post was created in the first place.

  • henning

    Thank you, bmxpert1! People should definitely have a look at your article!
    It looks a bit tricky, indeed. Does the blacklist thing fit in with Dagobert’s comment above concerning udev rules? Not quiet sure, just some food for thought.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>