背景
最近使用SONY-X898MD打印机时,发现每次打印后都会触发usblp detach然后再attach的情况,导致我写的udev rule被重复执行引发各种奇怪的问题。进一步了解到,其实cups是支持针对个别打印机进行特殊设置的,针对这个打印机可以设置no-reattach。
具体方法参照如下介绍:
I.
First, run the command lsusb -v | less
.
The output will help you to identify two items:
- Vendor USB ID
- Product USB ID
Both these are in the format 0xABCD
, where ABCD is a hex representation of the ID.
What you may need for this particular model (Epson PictureMate 100) is to apply a certain USB quirk for its operation.
I believe, that the USB Vendor ID for Epson is 0x04b8
, but you better check with your printer attached and running lsusb -v
. The USB Product ID you have to find out yourself.
II.
Make yourself familiar with the USB quirks currently known to CUPS. CUPS knows the following USB quirks:
# blacklist Printer is not functional at all with the USB backend.
# no-reattach Do no re-attach usblp kernel module after printing.
# soft-reset Do a soft reset after printing for cleanup.
# unidir Only supported unidirectional I/O.
# usb-init Needs vendor USB initialization string.
# vendor-class Uses vendor-specific class or subclass.
# whitelist The printer is functional with the USB backend.
III.
Have a look into the file /usr/share/cups/usb/org.cups.usb-quirks
for a list of pre-defined, well-known USB quirks for more than 80 different printers. Here is, to give an impression for readers who cannot lookup this file on their own systems, a listing of the first and the last three models:
# HP DeskJet 895C 0x03f0 0x0004 unidir # HP DeskJet 880C 0x03f0 0x0104 unidir # HP DeskJet 815C 0x03f0 0x0204 unidir [...] # Canon SELPHY CP780 0x04a9 0x31dd blacklist # Lexmark E238 () 0x043d 0x00d7 no-reattach # Lexmark E238 (STR #4448) 0x043d 0x009a no-reattach
IV.
The format of these lines is described in the initial comments of the same file:
# USB backend 'quirks' file. # # This file lists known issues with various vendors or printers. Each # line contains either a comment (starting with #) or the USB vendor ID, # product ID (omit for all vendor products), and a list of known issues:
V.
From your description I guess that the quirk you need to enable for your printer is the no-reattach
one.
VI.
Therefor, now add the following lines to the org.cups.usb-quirks
file:
# Seiko Epson PictureMate 100:
0x04b8 0x<ABCD> no-reattach
(Replace the 0x<ABCD>
with the actual USB Product ID which you found out with lsusb -v
!)
VII.
Alternatively, instead of adding above lines to the existing quirks file (which will be overwritten by Raspian package updates), you can also create a new file in the same directory with a name of, say, epson-picturemate-100.usb-quirks
where you put in the two lines.
CUPS will read all the quirks files in the /usr/share/cups/usb/
directory before running the USB backend.
This way you protect your local modification(s) from being overwritten by the Raspian package management actions.
VIII.
If above single USB quirk (no-reattach
) does not work, you may need to enable multiple quirks, like that:
# Seiko Epson PictureMate 100:
0x04b8 0x<ABCD> no-reattach soft-reset unidir
IX.
I'm not really sure about this point... but you may be able to test the effectiveness of my above advice in advance by running this command (without starting to mess around with *.usb-quirks files):
lpadmin -p name_of_your_printer -o usb-no-reattach-default=true
解释内容转自: