to configure CONFIG_USB_PRINTER=y
inux The kernel runs the printer by default nucleus drive , Directly on the configuration CONFIG_USB_PRINTER=y Just add it . make menuconfig
Select USB 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 , Identification 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 , The kernel is 「 No production information is just a porter between hardware and software 」
Using kernel usblp.c Just because it's a channel , Not the purpose , The purpose is to transfer data to the printer . use libusb( Application layer's usb Communication library ) Direct transmission is the same , See hplip Implementation of ; Really Android Used in usb
host api It's the same , See Google play in USB Printing APP Implementation of