How to get USB thermal printer to work in Linux?

Red Squirrel

No Lifer
May 24, 2003
67,194
12,025
126
www.anyf.ca
I was hoping it would just show up as a /dev/ device but it's not. I do get an error, not finding much help on google.

This is the dmesg output when I plug it in:

Code:
[2715176.060204] usb 3-10.4.5.2: new full-speed USB device number 21 using xhci_hcd
[2715176.153892] usb 3-10.4.5.2: New USB device found, idVendor=0416, idProduct=5011
[2715176.153895] usb 3-10.4.5.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[2715176.153897] usb 3-10.4.5.2: Product: POS58 USB Printer
[2715176.153898] usb 3-10.4.5.2: Manufacturer: GD32 Microelectronics
[2715176.153899] usb 3-10.4.5.2: SerialNumber: Printer
[2715181.154159] usblp: can't set desired altsetting 0 on interface 0


Any idea how to get this printer to work? This is the one, hoping it's compatible...

https://www.amazon.ca/gp/product/B06XWCMV75/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

Would be my luck that it's not, or has some weird quirk that requires a complicated work around.

I'm trying on Mint right now but plan will be to get it going on a Raspberry PI. I just want to at least get it going so I can test it at my desk so I can then figure out the commands so I can code the application that will use it.
 
  • Like
Reactions: Oyeve

Red Squirrel

No Lifer
May 24, 2003
67,194
12,025
126
www.anyf.ca
I found this when searching but don't have that file unfortunately. Typically my luck that files in tutorials don't exist on my system. I tried to do modprobe -r usblp though but not sure if that does the same.
 

Red Squirrel

No Lifer
May 24, 2003
67,194
12,025
126
www.anyf.ca
Yeah I want to write to it without needing a driver. The problem is that because of that error It does not show up at all in /dev. It should be showing up in /dev/usb/lpx but it does not.

As a side note, it's so annoying how every single linux system seems to be different. I tried it on another system, get same error and all, but I just noticed that there is no /dev/usb at all. So even if it does work I don't know where it would even go.

On this particular system /etc/modprobe/blacklist.conf does exist though, so I will try those steps. On the one I was trying at home that file did not exist.
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
67,194
12,025
126
www.anyf.ca
How do I know something is even going to read it though? I've seen this before where a file does not exist and they say I can just create it, but if it's not there in first place then where does the system store the config that would normally be in that place?

But anyway on this particular system I've been testing on today, that file does exist, so trying to blacklist it did nothing. Played on and off with this all day at work on my down time and got nowhere.

Think I'm going to buy a genuine Epson printer and try that. Hopefully can find one locally to make return easy if it does not work. (they arn't cheap) Maybe the issue lies with this off brand Amazon printer. Maybe it's just not compatible.
 

Red Squirrel

No Lifer
May 24, 2003
67,194
12,025
126
www.anyf.ca
Good news!

So I bought an Epson TM-T20II here as a test to see if this was an issue with the cheap printer I was trying to use and got it in the mail today, plugged it in, and it detects properly! So I guess it was an issue with this particular off brand Chinese printer. Glad that this Epson is plug and play.

Code:
falcon ~ # dmesg
[3649912.188677] usb 3-10.4.5.2: USB disconnect, device number 37
[3649912.188864] usblp3: removed
[3649925.697070] usb 3-10.4.5.2: new full-speed USB device number 38 using xhci_hcd
[3649925.786521] usb 3-10.4.5.2: New USB device found, idVendor=04b8, idProduct=0e15
[3649925.786526] usb 3-10.4.5.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[3649925.786528] usb 3-10.4.5.2: Product: TM-T20II
[3649925.786531] usb 3-10.4.5.2: Manufacturer: EPSON
[3649925.786533] usb 3-10.4.5.2: SerialNumber: 544336594967940000
[3649925.788164] usblp 3-10.4.5.2:1.0: usblp3: USB Bidirectional printer dev 38 if 0 alt 0 proto 2 vid 0x04B8 pid 0x0E15
[3649930.863877] usblp3: removed
[3649930.865728] usblp 3-10.4.5.2:1.0: usblp3: USB Bidirectional printer dev 38 if 0 alt 0 proto 2 vid 0x04B8 pid 0x0E15
falcon ~ # 
falcon ~ # 
falcon ~ # 
falcon ~ # echo "test 1234567890 abcdefghijklmnopqrstuv" > /dev/usb/lp3


I have not played with actual ESC/POS commands yet but the fact that I can send clear text is a good sign. It also has an auto cutter which is kind of neat, once I read up more on the commands I think I'll have a bit of fun with this before I actually put it in production. :p It's neat that it's that easy to talk to and that you don't need to mess around with complicated libraries or anything like that.

Here's hoping it will work on the RPI as well though... but I'll consider this solved for now. I'll have to play with it further when I'm off work.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,100
126
$250 is about the right price for a name brand thermal printer like that size.

Good luck.
 

tommag

Junior Member
Oct 9, 2019
2
1
36
Just posting here to say that I've had the exact same error with a similar thermal printer (brand GOOJPRT, model MTP-3).

For me the solution was to execute the following command as root :
echo 4b43:3830:c > /sys/module/usbcore/parameters/quirks

The USB VID / PID of my printer is 4B43:3830 so you will have to replace those with 0416:5011.

I will try to submit a patch to the usbcore driver, it seems that these simple USB controllers have a special behavior of not responding to usb_set_interface() command.
 
  • Like
Reactions: Quantamm

Quantamm

Junior Member
Oct 11, 2019
1
0
6
For me the solution was to execute the following command as root :
echo 4b43:3830:c > /sys/module/usbcore/parameters/quirks

Without the quirks, 0416:5011 isn't found by the usblp module, but after putting in the quirk you recommended, I do see /dev/usb/lp0. However, writing to it doesn't cause the printer to print and dmesg shows "usblp0: nonzero read bulk status received: -71".

I found the list of quirks flags: https://github.com/torvalds/linux/blob/master/drivers/usb/core/quirks.c#L88

I'm guessing that I might need another flag in order to make this printer work.

My question to you is how did you determine that 'c' was the right flag for your printer?
 

tommag

Junior Member
Oct 9, 2019
2
1
36
Hello and sorry for my late reply, I missed your message.

I don't have this error with my printer, so I can't investigate more.

The error you see seems to come from here : https://elixir.bootlin.com/linux/v5.3.6/source/drivers/usb/class/usblp.c#L300

This indicates that you're having the EPROTO error from the USB stack : https://elixir.bootlin.com/linux/v5.3.6/source/include/uapi/asm-generic/errno.h#L54

Unfortunately, from this doc : https://www.kernel.org/doc/html/latest/driver-api/usb/error-codes.html#f1 this looks like a very generic error...

While trying to debug my printer, I had some success by booting with the `debug` kernel parameter activated and the log level set to 7. Maybe you can identify what happens before this error message ?

Also you can find a better description of all the USB quirks here: https://elixir.bootlin.com/linux/v5.3.6/source/include/linux/usb/quirks.h

To answer your question, I found that i needed the `c` flag by parsing the usblp and usbcore source code, guessing and trying stuff, I'm not an USB nor kernel expert but it was a fun journey for sure !

Good luck :)
 

paul-91920116

Junior Member
Apr 2, 2020
1
0
6
I know this is a year late, but for anyone else who bashed their head against a wall, here's a blog post I found that worked for me:


The solution was to add a "Generic" / "Raw Queue" CUPS printer then use the `lp` command to print to it.

From Ask Ubuntu (https://askubuntu.com/questions/110892/print-via-terminal-without-usblp/110940#110940):

You can install it in CUPS as a raw device and then just lp -d Epson [textfile] (or possibly cat text | lp -d Epson) That's how I talk to my Eltron printers in EPL2. In CUPS web interface it's under "Make: Raw", but in gnome-print it's "Choose Driver: Generic" then "Raw Queue".

For what it's worth I've also blacklisted the `usblp` kernel driver (see post above) though I'm not sure if that was necessary in the end.

Another top tip is to make sure your thermal paper is the correct way up - for a while my printer was feeding but not printing - turns out it was printing, but on the wrong side of the paper :)


This is the device as reported by dmesg:


Code:
[112490.986040] usb 2-2: New USB device found, idVendor=0416, idProduct=5011
[112490.986046] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[112490.986049] usb 2-2: Product: POS58 USB Printer
[112490.986052] usb 2-2: Manufacturer: GD32 Microelectronics
[112490.986055] usb 2-2: SerialNumber: Printer
[112496.103434] usblp: can't set desired altsetting 0 on interface 0
 

Red Squirrel

No Lifer
May 24, 2003
67,194
12,025
126
www.anyf.ca
For me the issue is that the printer was not being picked up at all. It was not registering as a device. By buying a different printer it solved the issue for me. The cheap one I had got off Amazon probably required some kind of driver and was not plug and play so it didn't work in Linux.

Never ended up doing this project as the client decided to stick with Chownow so now I need to find a use for it lol. It's neat to be able to print stuff with simple scripting.