To configureCONFIG_USB_PRINTER=y
inux The kernel runs the printer by default nucleus drive, Directly on the configurationCONFIG_USB_PRINTER=y Just add it. make menuconfig
ChooseUSB Printer options: Device Drivers ---> [*] USB support ---> <*> USB Printer support
Insert the printer to see/dev/usb/lp0 Device node
Insert the printer to print as follows, Proof node generation, Recognition equipment
:/dev/usb # [ [email protected]] usb 1-1: new high-speed USB device number 3 using
xhci-hcd [ [email protected]] usblp 1-1:1.1: usblp0: USB Bidirectional printer dev 3
if 1 alt 0 proto 2 vid 0x03F0 pid 0x5817 :/dev/usb # /dev/usb # ls -al total 0
drwxr-xr-x2 root root 80 2018-01-16 20:42 . drwxr-xr-x 18 root root 14160 2018-
01-16 20:39 .. crw------- 1 root root 180, 0 2018-01-16 20:42 lp0 lrwxrwxrwx 1
root root12 2018-01-16 20:42 usbmisc1-1:1.1 -> /dev/usb/lp0
The upper layers are all operations/dev/usb/lp0
or/dev/lp0 This node,USB The equipment is self-reported.usb There is a special printing protocol in the protocol, Kernel is「 No production information is just a porter between hardware and software」
Using kernelusblp.c Just because it's a channel, Not purpose, The purpose is to transfer data to the printer. Uselibusb( Application levelusb Communication Bank) Direct transmission is the same, See alsohplip Implementation; Really arriveAndroid Use inusb
host api It's the same, See alsoGoogle play in USB PrintingAPP Implementation