Cannot configure print server

Hi,
I follow this guide to configure print server for printer HP LaserJet 1018, I have installed and configured everything, added printer on RAW port 9100, created firewall rule, but after hit print on Windows PC nothing happens.

root@OpenWrt:~#  ls /dev/usb/lp*
/dev/usb/lp0

root@OpenWrt:~# lsusb -v
-ash: lsusb: not found

config rule
        option name 'Allow_Printer'
        list proto 'tcp'
        option src 'lan'
        option dest_port '9100'
        option target 'ACCEPT'

root@OpenWrt:~# cat sihp1018.dl > /dev/usb/lp0
-ash: can't create /dev/usb/lp0: Resource busy

Device is TP-Link WR902AC v3 with OpenWrt 21.02.1 r16325-88151b8303

Lsusb requires the usbutils package.

You don't need any firewall rules for accessing a printer hosted on the same subnet as the clients.

Unplug and reconnect the printer, what does dmesg say?

2 Likes

without usb printer connected:

[  107.875489] usb 1-1: new high-speed USB device number 2 using ehci-platform
[  108.064085] usblp 1-1:1.0: usblp0: USB Bidirectional printer dev 2 if 0 alt 0 proto 2 vid 0x03F0 pid 0x4117
[  238.813055] usb 1-1: USB disconnect, device number 2
[  238.818522] usblp0: removed

with printer connected:

[   37.580925] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
[  107.875489] usb 1-1: new high-speed USB device number 2 using ehci-platform
[  108.064085] usblp 1-1:1.0: usblp0: USB Bidirectional printer dev 2 if 0 alt 0 proto 2 vid 0x03F0 pid 0x4117

It looks like the printer device is /dev/usblp0 not what you are trying to use (/dev/usb/lp0.)

You can't access the print device directly while p910nd is holding it open. Stop p910nd then try to cat a file direct to the printer USB device.

And the firewall rule is not needed since the default on the lan zone is to allow input to any port on the router.

I downloaded firmware sihp1018.dl and uploaded in /usr/lib/
then created script 20-printer in /etc/hotplug.d/usb

#!/bin/sh
  
  set -e
  
  # change this to the location where you put the .dl file:
  FIRMWARE="/usr/lib/sihp1018.dl"
  DEVICE=`uci get p910nd.@p910nd[0].device`
  LOGFILE=/var/log/hp
  PROD_ID="3f0/4117/100"
  DEV_TYPE="usb_device"
  
  daemon_restart() {
      echo "$(date) : (Re)Starting print daemon" >> $LOGFILE
      /etc/init.d/p910nd restart
  }
  daemon_stop() {
      echo "$(date) : Stopping print daemon" >> $LOGFILE
      /etc/init.d/p910nd stop
  }
  send_firmware() {
      echo "$(date) : Sending firmware to printer" >> $LOGFILE
      cat $FIRMWARE > $DEVICE
      echo "$(date) : done." >> $LOGFILE
  }
  
  
  if [ "$PRODUCT" = "${PROD_ID}" ]; then
      case "$ACTION" in
          add)
              sleep 1
              # Check whether dev is character type
              if [ -c $DEVICE ]; then
                  # Check whether the hotplug devtype is usb_device 
                  if [ "$DEVTYPE" = "${DEV_TYPE}" ]; then
                      send_firmware
                      daemon_restart
                  fi
              fi
              ;;
          remove)
              daemon_stop
              ;;
          #Also available:
          bind)
              ;;
      esac
  fi

I see in logger that this is working:

root@OpenWrt:/tmp/log# cat hp
Sat Jan 22 18:55:24 CET 2022 : Stopping print daemon
Sat Jan 22 18:55:24 CET 2022 : Stopping print daemon
Sat Jan 22 18:55:27 CET 2022 : Sending firmware to printer
Sat Jan 22 18:55:28 CET 2022 : done.
Sat Jan 22 18:55:28 CET 2022 : (Re)Starting print daemon

But my problem is that the printer prints the document but it stays in the print queue so I can't print anything else.

https://misc.openbsd.narkive.com/JhVygvtB/hp-laserjet-1018-hplj1018-firmware-upload
In short, "junk" that's never going to work with p910nd...

Someone who wrote this guide: https://openwrt.org/docs/guide-user/services/print_server/p910ndprinterserver
also uses this printer, so I guess he prints somehow.

The strangest thing is that the printer only prints once, then I have to restart the printer to print again.