Join Amazon Student FREE Two-Day Shipping for College Students!
23430

Add multiple usb printers to OpenWrt firmware router via p910nd using Hotplug

p910nd allow to use multiple printers through a socket connection to port 910n (where n=1, 2, 3 …). So, we can share more than one printer to OpenWrt.

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. Make sure the printer has usb essentials or support for the parallel port

Step 2. Install support for printers.

opkg update
opkg install kmod-usb-printer kmod-lp luci-app-p910nd

Step 3. Plug in the printer, record VID and PID.

SSH to the printer and run:

lsusb -v

or

dmesg | grep printer

Mark down the vid and pid for the printer. Repeat this process for all printers.

Step 4. Add this to /etc/hotplug.d/usb/11-multi-printers

The following code is a demo configuration for a Brother HL2140 on port 9100, a Zebra Eltron LP 2442 Label Thermal Printer on port 9101, and a Brother QL570 on port 9102.

Note: $PRODUCT" = "4f9/27/100" represents your printer's VendorId/ProductId/BcdVersion(1.00 = 100). VID=04f9, PID=0027

#!/bin/sh

# process USB and parallel printers only
if [ "$INTERFACE" = "7/1/1" ] || [ "$INTERFACE" = "7/1/2" ]
then

# set -x
DEV="none"

# Brother HL2140

if [ "$PRODUCT" = "4f9/33/100" ]
then
VID="04f9"
PID="0033"
DEV="hl2140"
fi

# Zebra LP2442

if [ "$PRODUCT" = "1645/6/100" ]
then
VID="1645"
PID="0006"
DEV="lp2442"
fi

# Brother QL570

if [ "$PRODUCT" = "4f9/2028/100" ]
then
VID="04f9"
PID="2028"
DEV="ql570"
fi

if [ "$DEV" != "none" ]
then
if [ "$ACTION" = "add" ]
then

# search for last printer assignment using dmesg

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
fi

fi

if [ "$ACTION" = "remove" ]
then
# LP = `cat /var/run/$DEV.lp`
rm /var/run/$DEV.lp
rm /dev/$DEV

fi
fi
fi

Step 5. Log in to OpenWrt -> service -> p910nd -> Printer server. Finish the configuration

Device = "/dev/Device name from the code above"
Port = Assigned port from the code above

p910nd-LuCI

Step 6. Reboot the router and test.

Leave a Reply

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

 

Your browser is out-of-date. Upgrade your browser today! Internet Explorer | FireFox | Chrome

X