Pazar, Şubat 05, 2017

Onion Omega2 üzerinde HP Laserjet 1020

Kaynaklar:

Omega2'nin Printer Server olarak kurulumu
    http://community.onion.io/topic/1256/print-server/8
Omega2'nın HP Laserjet 1020 ile çalışabilmesi için gerekenler
    https://wiki.openwrt.org/doc/howto/p910nd.server
HP Laserjet 1020'nin firmware'i
    https://github.com/inveneo/hub-linux-ubuntu/blob/master/install/overlay/usr/share/foo2zjs/firmware/sihp1020.dl


Yaptıklarım

1- Update USB-Essentials
    opkg update
    opkg install kmod-usb2 --force-depends
2- Update USB Printer Driver
    opkg install kmod-usb-printer --force-depends

3- Enable Default LEDE repo:
    vi /etc/opkg/distfeeds.conf
    src/gz reboot_core http://downloads.lede-project.org/snapshots/targets/ramips/mt7688/packages
    src/gz reboot_base http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/base
    src/gz reboot_packages http://downloads.lede-project.org/snapshots/packages/mipsel_24kc/packages
4- Enable TCP Port 9100
    vi /etc/config/firewall
    #Allow attached network printer
    config rule
        option src 'apcli0'
        option proto 'tcp'
        option dest_port '9100'
        option target 'ACCEPT'

5- Install p910nd daemon
    opkg install p910nd

6- Configure daemon
    vi /etc/config/p910nd
    config p910nd
       option device /dev/usb/lp0
       option port 0
       option bidirectional 1
       option enabled 1

7- Restart daemon
    /etc/init.d/p910nd restart

    /etc/init.d/p910nd enable
8-Download firmware and upload to /usr/lib/ on Omega2
9-Create a hotplug file, to upload firmware everytime the printer is plugged in.
  vim /etc/hotplug.d/usb/20-hplj1020
#!/bin/sh
    set -e    
# change this to the location where you put the .dl file:
    FIRMWARE="/usr/lib/sihp1020.dl"
    DEVICE=/dev/usb/lp0
    LOGFILE=/var/log/hp
    if [ "$PRODUCT" = "3f0/2b17/100" -a "$ACTION" = "add" ]; then
      for i in $(seq 30); do
        if [ -c $DEVICE ]; then
          echo "$(date) : Sending firmware to printer..." > $LOGFILE
          cat $FIRMWARE > $DEVICE
          echo "$(date) : done." .. $LOGFILE
          exit
        fi
        sleep 1
  done
    fi
10- Make avahi-daemon to announce with zeroconf
    vim /etc/avahi/services/printer.service
<?xml version="1.0" standalone='no'?><!–*-nxml-*–>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">HP LaserJet 1020 on %h</name> <service> <type>_pdl-datastream._tcp</type> <port>9100</port> <txt-record>qtotal=1</txt-record> <txt-record>note=I forgot where I placed my printer</txt-record> <txt-record>ty=HP LaserJet 1020</txt-record> <txt-record>product=(HP LaserJet 1020 Printer)</txt-record> <txt-record>usb_MFG=Hewlett-Packard</txt-record> <txt-record>usb_MDL=HP LaserJet 1020</txt-record> <txt-record>Color=F</txt-record> <txt-record>Duplex=F</txt-record> <txt-record>Bind=F</txt-record> <txt-record>Collate=F</txt-record> <txt-record>Sort=F</txt-record> <txt-record>Staple=F</txt-record> <txt-record>Punch=F</txt-record> <txt-record>PaperMax=legal-A4</txt-record> </service> </service-group>