We have 2 lp printers connected to Linux Ubuntu machine. After system boot there are two files created: /dev/usb/lp0
and /dev/usb/lp1
. Unfortunately these files are created randomly and we cannot distinguish which one is which. When I echo text in this way:
echo -ne "test" > "/dev/usb/lp0"
everything works fine but of course I don't know which printer will print. We have tried using alias in dev rules (using info gathered from devadm info -q all -a /dev/usb/lp*
):
SUBSYSTEM=="usb", KERNELS=="1-1.3.2", SYMLINK+="dr_lewa"
In /dev
there is indeed alias created:
lrwxrwxrwx 1 root root 15 Apr 15 14:44 dr_lewa -> bus/usb/001/012
When I try to write to this in the same way as to /dev/usb/lpX
error is given:
echo -ne "test" > /dev/dr_lewa
bash: echo: write error: Invalid argument
How can I distinguish two USB serial port lp printers and write to them in normal serial-port-way?