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

p910nd allow multiple printers through a socket connection to port 910n (where n=1, 2, 3 …). So, we can share more than one printer to OpenWrt. In default, port number when you unplug and plug in different printers. 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.

1. Make sure the printer has usb essentials or support for the parallel port

2. Install support for printers.

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

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

SSH to the printer and run:

1
lsusb -v

or

1
dmesg  grep printer

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/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

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

6. Reboot the router and test.

Bridge Multiple LAN ports/NICs in pfSense 2.1 Configure sendmail to use a different port for outgoing mail other than 25

Comments