📜 ⬆️ ⬇️

We make a network printer from HP LJ1000

The HP LaserJet 1000 is a great workhorse, fast and trouble-free USB printer with a low print cost. In the article I will describe the complexity and subtleties of setting up HP soft printers to work through a router over the network using the example of my LJ1000. Well under the cat!

There are a lot of articles on connecting printers via routers on the network, the essence of the majority comes down to a general algorithm - install alternative firmware on the router (for example, OpenWrt), install USB support, printers and p910nd daemon, then prescribe the demon configs and additional settings.

The peculiarity of the HP 1000, 1005, 1006, 1007, 1007, 1018, 1020, 1505 soft printers is that they do not have a full-fledged control firmware on board, it is loaded by the driver every time the printer is turned on. This article should be suitable for any of the listed printers, however, it is tested only on HP LJ1000.

The main difficulty in connecting such a printer via a router is to load “firmware” into it, which almost no router with printer support “out of the box” can do, as well as specialized “print servers”, although I admit that there are models that can do this, however I could not find them live.
')
Enhanced study of the issue gave two methods for solving the problem of downloading the firmware to the router - on the client side or on the router side. In the first version, the router is configured as for a regular printer, the “firmware” needs to be sent to print before using the printer for the first time from a computer:

1. --CMD 2.    COPY :\__\.prn \\dnsXXXX\lp (: COPY c:\tmp\sihp1020.prn \\dns323\lp) 

I consider this method insolvent, for it is inconvenient. The printer should work without additional gestures.

The second method of solving the problem is to upload the firmware by the router itself. Moreover, it is desirable that the firmware be loaded not only by turning on the router, but also by the printer's hotplug.

Now I will describe the configuration process on the hardware I have. In my case, the D-Link DIR-620 Rev A1 router is used. I have already tried a lot of firmware with this router, Zyxel Keenetic v1 turned out to be very convenient, however HP LJ1000 does not work with Keenetic, dances with tambourines did not help. As evidenced by technical support Zyxel: http://forum.zyxmon.org/topic160-keenetic-i-hp-lj-1000.html

I used the latest available version of OpenWrt: 14.07 .

As a basis for customization, I used an article on the OpenWrt wiki . The script is remade for a normal hotplag and a steady start for the p910nd daemon.

After flashing the router, we change the default password, activate the SSH operation, configure the network interfaces. It is most convenient to do all further settings through a terminal client, I used Putty. The settings assume that the router has access to the Internet.

So, let's go:

  1. Install the necessary packages for the printer, plus a simple editor:
     opkg update opkg install kmod-usb-printer usbutils p910nd nano 

  2. Write to the file system of the router firmware for the desired printer. The easiest way to download the firmware from Oleg: http://oleg.wl500g.info/hplj . In my case, I need the firmware for HP LJ1000 - and download it:
     cd /usr/lib/ wget http://oleg.wl500g.info/hplj/sihp1000.dl 

  3. Create a script to handle the hotplug event so that the firmware is sent to the printer each time it is connected:
     nano /etc/hotplug.d/usb/20-printer 

    Script code:

     #!/bin/sh FIRMWARE="/usr/lib/sihp1000.dl" DEVICE=/dev/usb/lp0 if [ "$PRODUCT" = "3f0/517/120" ] then case "$ACTION" in add) /etc/init.d/p910nd stop echo "`date`: Sending firmware to printer." >> /tmp/hl1000 cat $FIRMWARE > $DEVICE sleep 15 echo "`date`: hl1000 added" >> /tmp/hl1000 /etc/init.d/p910nd start echo "Done." >> /tmp/hl1000 ;; remove) echo "`date`: hl1000 removed" >> /tmp/hl1000 /etc/init.d/p910nd stop echo "Done." >> /tmp/hl1000 ;; esac fi 

    A little bit about script setup: first you need to make sure that your printer is located along the path / dev / usb / lp0: the ls / dev / usb command should give a list of devices among which there will be lp0. Some firmware may create a printer's dexryptor at / dev / lp0.

    Next, you need to register the path to the file "firmware", and specify the VID / PID of the printer. We look that is on USB:

     lsusb -v | grep "ID\|bcdUSB" 


    Answer:

     Bus 001 Device 004: ID 030:0517 Hewlett-Packard LaserJet 1000 bcdUSB 1.20 

    3f0 / 517 is the VID and PID of the HP LJ 1000 printer (the first zeros are deleted 0 3f0). 120 is the BCD version without a dot.
  4. Open the p910nd configuration file:

     nano /etc/config/p910nd 

    If there is already an entry for the printer, you need to make sure that the path to the printer descriptor is correct. If not, copy this text:

     config p910nd option device /dev/usb/lp0 option port 0 option bidirectional 0 option enabled 1 

    If only one printer is used with the router, then we leave this text as it is, but several printers can be used. Then for each of them you will need to specify your port (by default 9100).
  5. In my case, the print daemon is started by the script after downloading the firmware to the printer, so make sure that it does not start itself when the router is turned on:

     /etc/init.d/p910nd disable 

    Otherwise, a daemon running too early fell with the following error:

     Tue Feb 4 02:29:43 2014 lpr.err p9100d[1207]: bind: Cannot assign requested address Tue Feb 4 02:29:43 2014 lpr.err p9100d[1207]: accept: Bad file descriptor 


Reboot the router. If everything is configured correctly, then with the loading of the router the printer is reinitialized (you can hear how it restarts). Just in case, we make sure that there are no p9100 errors in System Log, we connect via SSH, we check the hotplug script operation:

 nano /tmp/hl1000 

There should be a log like this:

 Sending firmware to printer. hl1000 added Done. 

Check that the daemon has started:

 ps | grep p910nd 

The process list for the command should be p910nd :

 root@OpenWrt:~# ps | grep p910nd 1597 root 780 S {p910nd} /usr/sbin/p9100d -b -f /dev/usb/lp0 0 1849 root 1492 S grep p910nd 

At this setting on the side of the router can be considered complete.

Further we set up the connection from the customers. In my case, these were computers running Windows XP, where the drivers for the desired printer were already installed.

Open the properties of the printer:



Add a new port -> Standard TCP / IP Port -> New port -> Next -> enter the IP address of the router -> generic Network Card-> Done.

Be sure to uncheck "bidirectional exchange." About this where few write. Other models of printers except 1000 normally work with the installed one, but it was with my 1000 that the printing did not work until I unchecked and rebooted (it’s important that it will not work without rebooting).

The print from Windows 7 is also configured in the same way, you also need to uncheck the “bidirectional exchange” box. I didn’t check it on newer ones, but I don’t see any obstacles for it to work.

PS: Setting up bidirectional exchange in p910nd ( bidirectional ) does not affect operation, unlike setting up bidirectional exchange on the client side. I tried with the flag turned on and off, the behavior of the printer did not change. Therefore, it is important to observe the disconnection only on the client side.

Source: https://habr.com/ru/post/267029/


All Articles