Do not drive, simple rough with Raspberry Pi drive USB printer

Source: Internet
Author: User
Tags git clone
do not drive, simple rough with Raspberry Pi drive USB printerAdmin April 14, 2015 5 Comments

Many articles on the web are how to use raspberry sent to do a universal print server, but in many scenarios, the configuration cups what is really their own zuo of the good way to die, all kinds of Linux under the driver configuration to make blood vomit. and drive a variety of thermal ticket printers, such as playing tape ah, two-dimensional code stickers Ah, small tickets and other printers because there is no Linux driver, to get up is mission imposiable. So the purpose of this article is to not drive directly with the USB interface of various types of thermal printer. Because there is no driver, so we can only use the simple and rough way through the USB direct operation of the printer. Here's a look at how to do it:

First of all, you have to have a printer, Taobao has sold, dozens of yuan to one hundred or two hundred, you can play heat-sensitive tape, so do a print server label things are also good, other uses can be developed on their own.

First connect the printer with a USB cable to the Raspberry Pi, then execute the LSUSB command on the Raspberry Pi, this time the list is connected to all the USB devices, as follows:

Bus 005 device 001:id 0000:0000
bus 001 device 001:id 0000:0000
bus 004 device 001:id 0000:0000
bus 003 Dev Ice 001:id 0000:0000
bus 002 device 006:id 15d9:0a37
Bus 002 Device 001:id 0000:0000

I don't know who the printer is at this time. But it doesn't matter, you unplug the printer's USB cable and then execute once, see who is missing, who is the printer.

The two digits separated by the ID after the colon are the vendor ID and Product ID of the USB device, which is used for a while when the connection is made.

In order to connect to the printer, you need to install the PYTHON-USB library to operate the USB device directly via the USB interface. The first pit of this article is here, because the version in the PIP library has a bug that is used in the library behind it, so it must be installed in the latest bug-removal code from GitHub without problems. So it can only be installed in such a way.

1 2 3 git clone https://github. Com/walac/pyusb. Git cd pyusb python setup.py install

After installation we can operate the printer via USB interface, because most printers support Epson's Printing protocol (very old protocol, so it is supported everywhere), so we can install a call Python-escpos Library to operate the printer with the Epson protocol via PYTHON-USB.

1 sudo pip install Python-escpos

But there is still a hole here, because this goods document basically and the actual situation is irrelevant. So let's just leave the documentation for the goods.

1 2 From escpos Import * pt = printer. USB (0x0fe6, 0x811e, 0, Out_ep = 0x03)

Here to note that OUT_EP can not use the default value, the default will not hit, but there are problems in the package can not be automatically obtained, so the following for a section of the code to get OUT_EP automatically

1 2 3) 4 5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.