Linux Debian(Ubuntu)上のCUPS 1.4以降を使用したHP LJ 1010/1015/1018/1020プリンターの接続

CUPSバージョンを更新するときに、ロードされたusbplモジュールとの非互換性の問題がありました。これは、ファームウェアをプリンターにダウンロードするために必要です。 同時に動作すると、USBバスで競合が発生し(同時アクセス)、次のように/ var / log / syslogシステムのログに反映されます。
-----------------------
Jul 1 02:18:57 kernel: [ 3115.009361] usb 1-2.5: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
-----------------------

この問題の解決策:
-プリンターの電源をオンにした直後にモジュールをダウンロードします
-フィルムウェアを注いだ直後にモジュールをアンロードします

これを行うには、次を実行します。


0)プリンターの電源を切ります
1)必要なパッケージをインストールする
  aptitude install cupsys gs-esp foomatic-bin foo2zjs cups-pdf 

2)プリンターに必要なフィルムウェアをダウンロードし、変換して適切なフォルダーに配置します。
  wget http://foo2zjs.rkkda.com/firmware/sihp1018.tar.gz tar xvzf sihp1018.tar.gz arm2hpdl sihp1018.img > sihp1018.dl cp sihp1018.dl /usr/share/foo2zjs/firmware cp sihp1018.img /usr/share/foo2zjs/firmware cp sihp1018.dl /lib/firmware/hp cp sihp1018.img /lib/firmware/hp 

3)プリンターの電源がオンになったときにモジュールをロードするために、udevデバイスマネージャーのルールを作成します。
  vi /etc/udev/rules.d/11-hplj10xx.rules 

プリンターのVidとPidを指定してください! 1018の例を示します。
 #Own udev rule for HP Laserjet 1018 SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4117", RUN+="modprobe usblp" 


4)udevデバイスマネージャーを再起動します
  /etc/init.d/udev restart 

5)プリンターが検出されたときに実行されるfoo2zjsスクリプトを編集します(ファームウェアをロードした直後にusbplカーネルモジュールを無効にします)。 ファイル名はプリンタのモデルによって異なります!(1000/1005/1018/1020の場合-/ usr / sbin / hplj1018)
  vi /usr/sbin/hplj1018 

ファームウェアのダウンロードプロセスを探して調整しています
 # # Procedure to load a single device with firmware # load1() { _dev="$1" fw="$FWDIR/sihp$FWMODEL.dl" if [ ! -f "$fw" ]; then log "Missing HP LaserJet $MODEL firmware file $fw" log "...read foo2zjs installation instructions and run ./getweb $MODEL" return 1 fi log "loading HP LaserJet $MODEL firmware $fw to $_dev ..." # There is a timeout problem with udev and FC4, so spin it off. ( if cat $fw > $_dev; then log "... download successful." sleep 15 rmmod usblp #  usblp log " ... kernel module usblp disable now... " else log "... download failed." fi ) & return 0 } # # OK, now download firmware to any printers that need it # if [ "$DEV" != "" ]; then # # force downloading to a specific device # load1 "$DEV" elif [ -x $PRINTERID ]; then # # Sniff around for printers that need a firmware download # usblps=`find /dev/usb -name 'lp*'`" "`find /dev -name 'usblp*'` for dev in $usblps; do status=`$PRINTERID $dev 2>/dev/null | grep -y "hp LaserJet $MODEL"` if [ "$status" != "" ]; then # This is a LaserJet 100x chmod 0666 $dev status=`$PRINTERID $dev | grep 'FWVER'` if [ "$status" = "" ]; then # Firmware is not yet loaded load1 "$dev" else log "HP LaserJet $MODEL firmware already loaded into $dev" sleep 15 rmmod usblp #  usblp log " ... kernel module usblp disable now... " fi fi done else log "HP LaserJet $MODEL firmware was not downloaded..." log "...couldn't find $PRINTERID and DEV is not set" fi 


変更は行の追加に帰着します
  sleep 15 rmmod usblp log " ... kernel module usblp disable now... " 


6)プリンターの電源を入れ、ログを確認します
  tail -f /var/log/syslog 

正しく動作する場合、次のものがあります。
--------------------
Jul 1 01:56:12 kernel: [ 1749.871946] CE: hpet increased min_delta_ns to 20113 nsec
Jul 1 02:18:39 kernel: [ 3097.400294] usb 1-2.5: new high speed USB device number 8 using ehci_hcd
Jul 1 02:18:40 kernel: [ 3097.512010] usb 1-2.5: New USB device found, idVendor=03f0, idProduct=4117
Jul 1 02:18:40 kernel: [ 3097.512084] usb 1-2.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jul 1 02:18:40 kernel: [ 3097.512098] usb 1-2.5: Product: HP LaserJet 1018
Jul 1 02:18:40 kernel: [ 3097.512109] usb 1-2.5: Manufacturer: Hewlett-Packard
Jul 1 02:18:40 kernel: [ 3097.512120] usb 1-2.5: SerialNumber: KP03QAY
Jul 1 02:18:40 mtp-probe: checking bus 1, device 8: "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.5"
Jul 1 02:18:40 mtp-probe: bus: 1, device: 8 was not an MTP device
Jul 1 02:18:40 udev-configure-printer: add /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.5/1-2.5:1.0
Jul 1 02:18:40 udev-configure-printer: parent devpath is /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.5
Jul 1 02:18:40 udev-configure-printer: Device vendor/product is 03F0:4117
Jul 1 02:18:40 udev-configure-printer: MFG:Hewlett-Packard MDL:HP LaserJet 1018 SERN:- serial:KP03QAY
Jul 1 02:18:40 kernel: [ 3097.779667] usblp1: USB Bidirectional printer dev 8 if 0 alt 0 proto 2 vid 0x03F0 pid 0x4117
Jul 1 02:18:40 kernel: [ 3097.781597] usbcore: registered new interface driver usblp
Jul 1 02:18:40 udev-configure-printer: add /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.5/1-2.5:1.0/usb/lp1
Jul 1 02:18:41 kernel: [ 3098.989429] usb 1-2.5: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
Jul 1 02:18:43 /usr/sbin/hplj1018: foo2zjs: loading HP LaserJet 1018 firmware /lib/firmware/hp/sihp1018.dl to /dev/usb/lp1 ...
Jul 1 02:18:43 /usr/sbin/hplj1018: foo2zjs: ... download successful.
Jul 1 02:18:56 udev-configure-printer: parent devpath is /devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2.5
Jul 1 02:18:56 udev-configure-printer: MFG:Hewlett-Packard MDL:HP LaserJet 1018 SERN:- serial:KP03QAY
Jul 1 02:18:57 kernel: [ 3115.009361] usb 1-2.5: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
Jul 1 02:18:58 kernel: [ 3116.139386] usbcore: deregistering interface driver usblp
Jul 1 02:18:58 kernel: [ 3116.139675] usblp1: removed
Jul 1 02:18:58 /usr/sbin/hplj1018: foo2zjs: ... kernel module usblp disable now...
--------------------

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


All Articles