Problem with /dev/usb/lp0

Hi, I’m relative new to nixos, and I have a problem…

I need /dev/usb/lp0 exposed, because a thermal printer.

I found a solution: deactivating cups, but also I’ve a Laser printer that works with cups…

So I can’t find the way to expose /dev/usb/lp0 without deactivating cups, anyone know a way to do it?

I’ve usblp en my kernelModules

boot.kernelModules = [ “kvm-amd” “usblp” ];

Thank you !

1 Like

What do you mean by expose, please?

I need /dev/usb/lp0 in my filesystem to echo to a thermal printer.

But when cups is active, I understand the usblp module is blacklisted, and /dev/usb/lp0 doen’t get created

So, there is a way to mantain cups and load usblp at the same time?

Thank you

PD Sorry about my english is not my first language.

Can’t you use your thermal printer through CUPS? You may need to add a driver package for it via services.printing.drivers, but I don’t know if most folks should be using the usblp module for anything these days.

Yes I can see it, but that’s not the point, I need to send commands directly to the printer.

Almost all thermal printer works that way, you send it ESC/POS commands directly to the printer, no driver required.

But also I have a “normal” laser printer what requires cups, so my problem is i can’t use in the same NixOS installation both printers.

Yes, but couldn’t you send those commands via the lp program (with -o raw) instead of writing them to /dev/usb/lp0?

Hi again, thank you for your time, but that not a posible solution, the driver don’t “speak” the same language of the printer.

I use the printer to print barcodes (hundreds of them). Thermals printers have a set of native commands in the printer (ESC/POS)

If I print “\x1b\x21\x3012345678” with the lp command prints exactly that

But echoing the same string to the printer directly prints a bardoce in code128 format, that represents the last 8 character of the string. Those escape character are the ESC/POS commands, for cups is a normal string.

I need to use usblp kernel module and cups at the same time… or a way to cups understand the ESC/POS commands, but i think is way easier the first, because is the default dehaviour in Arch what is I using right now in that PC for this reason (I like to use NixOS in all my computers)

That kernel module is indeed being blacklisted by the CUPS (NixOS) module:

# Cups uses libusb to talk to printers, and does not use the
# linux kernel driver. If the driver is not in a black list, it
# gets loaded, and then cups cannot access the printers. 
boot.blacklistedKernelModules = [ "usblp" ];

If this comment it still valid, it does really look like it’s not possible to use both at the same time.

EDIT: if you say you can just do so in Arch, then it may be that this is no longer true. Maybe try to override the blacklist with lib.mkForce.

1 Like

OK… now I see exactly what is the problem, I gonna try your solution, maybe that is there for some legacy problem (I hope).

THANK YOU !

1 Like

Indeed that was the solution, thank you again, the printer works fine echoing directly to /dev/usb/lp0 and through CUPS too