Multiple Printers

Add multiple printers on Tomato firmware router with hotplug

Tomato firmware in default only recognize one printer. If more printers are detected, it assign the first detected printer to lp0. When a printer is plugged into the Tomato router and turned on, the printer port is assigned. To add a second p910nd instance, you need to manually run it with p910nd -f /dev/usb/lp1 1, and add -b for bidirectional if needed.

When sharing one printer using p910nd in Tomato firmware, the first printer will be assigned to default port 9100. If you plug in more than one printers, the usb printer kernel module assigns /dev/usb/lp devices in the order printers are turned on/off. When a printer is turned on and recognized on the usb bus, it receives the first free device name in /dev/usb/lp. If you are using more than one printers and turn them on and off all the time, you have to change device assignments for p910nd dynamically.

The following configuration uses the Hotplug script to pair printers to designed ports. This allows multiple printers to be recognized, assigned ports based on the product ID, same ports assigned will resume when printers are connected/turned on. Works on both usb printer and parallel printer using serial to USB adapter.

Step 1: Turn on "Core USB Support", "USB 2.0 Support", "USB 1.1 Support (Optional)", "USB Printer Support", and "USB Storage Support" under "USB Support".

Step2: Unplug all printers. Copy and paste the following code into the "Hotplug script" box.

The following code is a demo of sharing three printers.

#!/bin/sh # log printers Interface, VID, and PID information echo Product:${PRODUCT} Interface: ${INTERFACE}>> /var/log/hotplug # process printers only # usb port # parallel to usb port if [ "$INTERFACE" = "7/1/1" ] || [ "$INTERFACE" = "7/1/2" ] then # set -x DEV="none" # Printer_1 if [ "$PRODUCT" = "4f9/33/100" ] then VID="04f9" PID="0033" DEV="Printer_1" port="0" fi # Printer_2 if [ "$PRODUCT" = "1645/6/100" ] then VID="1645" PID="0006" DEV="Printer_2" port="1" fi # Printer_3 if [ "$PRODUCT" = "4f9/2028/100" ] then VID="04f9" PID="2028" DEV="Printer_3" port="2" fi if [ "$DEV" != "none" ] then if [ -n "$port" ]; then for pid in `ps | grep -i p910${port}d | grep -v grep | cut -c1-5` ; do kill -9 $pid done if [ "$ACTION" = "add" ] then # search for last printer assignment in syslog (/var/log/syslog.log or logread) LP=`dmesg | grep -i "usblp.: USB Bidirectional printer dev .* if .* alt .* proto .* vid 0x$VID pid 0x$PID" | grep -io "lp[0-9]" | tail -n 1` if [ "$LP" != "" ] then echo $LP >/var/run/$DEV.lp ln -s /dev/usb/$LP /dev/$DEV p910nd -b -f /dev/$DEV $port fi fi if [ "$ACTION" = "remove" ] then # LP = `cat /var/run/$DEV.lp` rm /var/run/$DEV.lp rm /dev/$DEV fi fi fi fi

Tomato Printers Tomato Printers

Step 3: plug each printer one by one into the router, check "/var/log/hotplug", copy and paste printers' PRODUCT, VID, and PID information into the hotplug code above.

Step 4: Turn off "USB Printer Support", this will disable the default printer support and port assignation.

Step 5: Copy and paste the following code into "init" under "Administration" "Scripts"

This will load the printer support when the router start.

modprobe usblp

Step 6: This is it. Reboot and test

Note: Hotplug script box needs "USB Storage Support" be turned on at least.
If you don't want USB Storage Support, you can turn it off by using the code into "init" under "Administration" "Scripts".

modprobe -r usb_storage

Leave a Reply

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