jsntwdj Posted April 4, 2022 Share Posted April 4, 2022 (edited) 一、参数信息: 打印机:HP LaserJet 1020 unraid识别:总线 001 设备 004: ID 03f0:2b17 惠普激光打印机 1020 打印机每次开机 docker 按自带的模板,安装cups,olbat/cupsd 参数设置正确 二、基本情况: 打印测试页,下发打印任务之后,会发现,打印机根本没反应。 查到网上的原因说明:主机型打印机(也叫windows 打印机,GDI打印机)需要每次上传固件,正巧,HP1020就是这种打印机 解决思路:用cat命令,将打印机固件传入HP1020中 提取到LaserJet 1020固件:sihp1020.dl,上传到 /etc 主机中运行:cat /etc/sihp1020.dl >/dev/usb/lp0 打印机开始有启动的声音。 cups 打印测试页,下发打印任务之后,可以打印,初步解决了这个问题 三、需要解决的问题: 需求:打印机平时关机,再次开机后,unriad 根据识别新增usb端口及相关参数,自动执行"cat /etc/sihp1020.dl >/dev/usb/lp0" 1、新建 hp1020.sh 内容:cat /etc/sihp1020.dl >/dev/usb/lp0 保存后,上传到 /etc 2、chmod 755 /etc/hp1020.sh 给他运行权限 3、新建hp1020.规则 内容: # hp 1020ACTION =="add", SUBSYSTEMS=="usb", KERNEL=="lp0", RUN+="/etc/hp1020.sh" 4 、上传hp1020.rules 到/etc/udev/rules.d/ 5、chmod 755 /etc/udev/rules.d/hp1020.rules 6、执行 udevadm control --reload-rules 更新udev规则 问题:打印机关机,开机后,并不能自动向打印机发送固件,导致不能自动加载,无法自动打印 四、请教一下 1、ACTION=="add", SUBSYSTEMS=="usb", KERNEL=="lp0" 这个参数是否正确?如何查询到本打印机的相关参数? 2、如何才能自动加载? 3、请大神帮忙指点一下,就差一步,自动加载的设定了。 在此跪拜! Edited April 7, 2022 by jsntwdj Quote Link to comment
jsntwdj Posted April 4, 2022 Author Share Posted April 4, 2022 (edited) 查询到如下 sudo udevadm info -a /dev/usb/lp0 Udevadm info starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device. looking at device '/devices/pci0000:00/0000:00:15.0/usb1/1-8/1-8:1.0/usbmisc/lp0': KERNEL=="lp0" SUBSYSTEM=="usbmisc" DRIVER=="" looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1/1-8/1-8:1.0': KERNELS=="1-8:1.0" SUBSYSTEMS=="usb" DRIVERS=="usblp" ATTRS{bAlternateSetting}==" 0" ATTRS{ieee1284_id}=="MFG:Hewlett-Packard;MDL:HP LaserJet 1020;CMD:ACL;CLS:PRINTER;DES:HP LaserJet 1020;" ATTRS{authorized}=="1" ATTRS{bInterfaceSubClass}=="01" ATTRS{bInterfaceNumber}=="00" ATTRS{bInterfaceProtocol}=="02" ATTRS{bInterfaceClass}=="07" ATTRS{bNumEndpoints}=="02" ATTRS{supports_autosuspend}=="1" looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1/1-8': KERNELS=="1-8" SUBSYSTEMS=="usb" DRIVERS=="usb" ATTRS{configuration}=="" ATTRS{bMaxPacketSize0}=="64" ATTRS{bDeviceClass}=="00" ATTRS{bcdDevice}=="0100" ATTRS{bNumInterfaces}==" 1" ATTRS{bConfigurationValue}=="1" ATTRS{manufacturer}=="Hewlett-Packard" ATTRS{bNumConfigurations}=="1" ATTRS{authorized}=="1" ATTRS{speed}=="480" ATTRS{idProduct}=="2b17" ATTRS{urbnum}=="10" ATTRS{devnum}=="35" ATTRS{product}=="HP LaserJet 1020" ATTRS{maxchild}=="0" ATTRS{bmAttributes}=="c0" ATTRS{bDeviceSubClass}=="00" ATTRS{bMaxPower}=="98mA" ATTRS{rx_lanes}=="1" ATTRS{removable}=="removable" ATTRS{idVendor}=="03f0" ATTRS{version}==" 2.00" ATTRS{avoid_reset_quirk}=="0" ATTRS{serial}=="FN2D9WM" ATTRS{bDeviceProtocol}=="00" ATTRS{tx_lanes}=="1" ATTRS{ltm_capable}=="no" ATTRS{devpath}=="8" ATTRS{busnum}=="1" ATTRS{quirks}=="0x0" 依据上面的特征查找: /etc/udev/rules.d/hp1020.rules 改动如下 # hp 1020 KERNELS=="1-8", SUBSYSTEMS=="usb", ATTRS{idProduct}=="2b17", ATTRS{idVendor}=="03f0", RUN+="/etc/hp1020.sh" udevadm control --reload-rules 经测试,依然不行。 Edited April 4, 2022 by jsntwdj Quote Link to comment
lyqalex Posted April 5, 2022 Share Posted April 5, 2022 因为没有类似的打印机进行测试,所以无法提出解决方法。但我觉得或者换一种思路,1020只有win版驱动,可以运行一个win7虚拟机?或者寻求更低资源占用,测试虚拟机ubuntu是否有自带1020驱动? Quote Link to comment
jsntwdj Posted April 5, 2022 Author Share Posted April 5, 2022 (edited) 3 hours ago, lyqalex said: 因为没有类似的打印机进行测试,所以无法提出解决方法。但我觉得或者换一种思路,1020只有win版驱动,可以运行一个win7虚拟机?或者寻求更低资源占用,测试虚拟机ubuntu是否有自带1020驱动? 一、感谢 @lyqalex谢谢您的解答,1020有linux版驱动,也能运行,关键问题:是打印机没有固件,每次开机后,手动将固件写入usb 这个操作已经没有问题了。 现在的问题,如何在udev 中,让手动写入固件的命令,在打印机开机后,自动依据端口的设备参数,自动判别,自动运行。 二、另一个问题也解决了: unraid开机后,是运行中内存中的,在/etc中的新建的文件,重启后,会丢失。 我把文件存在/boot目录中,在go文件中,添加cp命令至/etc/udev/rules.d/hp1020.rules 重启后,不影响 三、疑惑 我在N1盒子,armbian(debian10) 上这么设置,是可以实现,并可靠运行的,完美解决这个问题。 我在想,参数设置,都没问题,是不是unraid 对此做了某些限制,不能让这些操作生效? Edited April 5, 2022 by jsntwdj Quote Link to comment
always67 Posted May 17, 2022 Share Posted May 17, 2022 docker版的CUPS也有差不多的问题,打印机休眠之后,需要重启docker容器才能识别打印机,有没有脚本可以控制一下识别打印机插入后,自动重启CUPS的docker? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.