michaelrsweet / lprint

A Label Printer Application
https://www.msweet.org/lprint
Apache License 2.0
219 stars 29 forks source link

'devices' sub-command gives error message #24

Closed wbrells closed 1 year ago

wbrells commented 3 years ago

lprint installed fine, but the command 'lprint devices' gives the message:

lprint: Unable to initialize USB access: Other error

However, 'lprint drivers' gives the expected output. My printers are all network connected - there are no USB printers involved. My system is running the latest version of LinuxFX which is based on Ubuntu 20.04 with a modified interface that strongly resembles Windows 10. Are there some other sub-commands I should try in order to help identify this problem?

michaelrsweet commented 3 years ago

Try running "sudo lprint drivers" - I suspect the issue is that your user account does not have access to USB devices.

wbrells commented 3 years ago

The 'lprint drivers' command works with or without sudo, but 'lprint devices' gives the above error message with or without sudo...

Not quite related to the above problem:

I'm a bit confused as to whether or not 'lprint' is a substitute for CUPS when label printers are involved. I have a DYMO 330T Labelwriter connected to the network via a Raspberry Pi configured as a printer server. That setup works fine from both of my Win 10 systems and when printing from Linux/CUPS via LibreOffice and notepad++ (running via WINE). My problem comes up when trying to run the Dymo Labelwriter program under WINE. The program installs and starts running fine, but it cannot "see" the above label printer. I was hoping - probably not likely - that lprint (running as a server?) might make the printer visible to the Dymo program... Any comments/thoughts would be greatly appreciated! Wayne

michaelrsweet commented 3 years ago

@wbrells OK, did you install lprint from source, from a distro package, or from the snap?

If you installed from source, did you have the libusb developer package installed? If you are using Raspbian, the following command will make sure you have all of the necessary dependencies:

sudo apt-get install build-essential libavahi-client-dev libcups2-dev \
    libcupsimage2-dev libgnutls28-dev libjpeg-dev libpng-dev \
    libusb-1.0-0-dev zlib1g-dev

WRT the server mode, if you run lprint as a server on the network - see the DOCUMENTATION.md file or the online documentation for instructions - then it will look like an IPP Everywhere/AirPrint/Mopria printer and will show up on your client machines. Current Windows 10 does natively support IPP printers but I'm not sure whether Dymo's label program will recognize those printers, and you won't want to use the Dymo label printer driver from the Windows client anymore because the IPP raw path isn't bidirectional (i.e. the Dymo drivers want to query the printer over the socket with printer commands but IPP doesn't allow that...)

A future version of LPrint will add support for raw socket listeners to enable support for older versions of Windows...

wbrells commented 3 years ago

I installed lprint via the suggested command: sudo snap install lprint

The installation seemed to go smoothly with no mention of unsatisfied dependencies.

WRT server mode, the Dymo software for the Labelwriter is packaged as a single installation file which (I assume) includes a Windows printer driver. FYI on my system under Windows 10 the port for the Dymo printer (which works fine) is configured as:

http://192.168.2.65:631/printers/DYMO_LabelWriter_330_Turbo

Based on your comments, it seems likely that the lack of bidirectional communications is why the DYMO printer is not being "seen" by the DYMO software running under WINE. Perhaps a future version of Lprint might provide the needed support?

Thanks very much for your comments & advice, Wayne

michaelrsweet commented 3 years ago

@wbrells It sounds like there is still a permissions issue of some sort - the snap lists the "raw-usb" interface and so should be getting access to the printer, but perhaps there is a bug in the snap packaging?

WRT using WINE to talk directly to the printer via lprint, that isn't going to work. Even with the raw socket support, lprint will still not provide direct bidirectional access to the printer. I'm not sure what WINE is doing these days to expose CUPS printers to Windows applications, but that is the level that WINE is operating.

wbrells commented 3 years ago

My real problem with the Dymo printer w/Dymo software does seem to be the lack of bidirectional support. What is really needed, I'm afraid, is a package such as the commercial TurboPrint for Linux that supports the Dymo printer. Currently, TurboPrint provides bidirectional support (and a lot of other features) for Canon, Epson, Brother, and HP printers. Given the small number of Dymo printers, it seems very unlikely that they will ever be supported by TurboPrint. At least TurboPrint seems to show that such support is technically possible. -- Wayne

michaelrsweet commented 3 years ago

@wbrells LPrint is perfectly capable of doing bidirectional comm to Dymo printers - that isn't the issue.

And TurboPrint won't make any difference, since it provides CUPS printer drivers for all the printers it supports, taking care of any printer-specific communications that are needed.

The issue is that IPP explicitly does not support direct communication with the printer itself. Instead, IPP provides a higher-level interface that abstracts the printer-specific bits away so that a generic client application can print without knowing all of the details of the printer.

zdohnal commented 3 years ago

Hi @michaelrsweet

I probably hit the same issue as @wbrells - lprint devices doesn't show anything unless called with sudo. It is because libusb_open() fails with insufficient permissions. The usb device has following ACL:

# file: dev/bus/usb/002/011
# owner: root
# group: lp
user::rw-
group::rw-
other::r--

Does lprint expect a different ACL? IIRC there is an udev rule in Fedora which sets owner:group, so maybe it can be the cause, but I would like to know how the expected ACL looks like.

Or if it supposes to be used with sudo, then I can fix the docs.

michaelrsweet commented 3 years ago

Well, USB permissions vary from distribution to distribution. The snap package runs the server as root (I think) and grants raw USB access for me, but ideally any admin user should be able to use the printer without running sudo. At the very least you could add the admin user to the 'lp' group...

ccazabon commented 3 years ago

I seem to be having the same issue. Installed the snap 1.0-104 yesterday, but the devices command fails to access the printer (Dymo LabelWriter 450) over USB with what looks like a perms/access problem (when run as root). This is on Debian buster/10.

Install & attempt log:

$ sudo apt-get install snapd
[...]
Preparing to unpack .../squashfs-tools_1%3a4.3-12_amd64.deb ...
Unpacking squashfs-tools (1:4.3-12) ...
Selecting previously unselected package snapd.
Preparing to unpack .../snapd_2.37.4-1+b1_amd64.deb ...
Unpacking snapd (2.37.4-1+b1) ...
Setting up squashfs-tools (1:4.3-12) ...
Setting up snapd (2.37.4-1+b1) ...
[...]

$ snap list
No snaps are installed yet. Try 'snap install hello-world'.

$ sudo snap install lprint
lprint 1.0 from Michael Sweet (michaelrsweet) installed

$ snap list
Name    Version   Rev   Tracking  Publisher      Notes
core18  20210507  2066  stable    canonical✓     base
lprint  1.0       104   stable    michaelrsweet  -

$ sudo snap get lprint
error: snap "lprint" has no configuration

$ sudo snap info --verbose lprint
name:      lprint
summary:   A Label Printer Application
publisher: Michael Sweet (michaelrsweet)
license:   unset
description: |
  LPrint implements printing for a variety of common label and receipt
  printers
  connected via network or USB.  Features include:

  - A single executable handles spooling, status, and server functionality.
  - Multiple printer support.
  - Each printer implements an IPP Everywhere™ print service and is
  compatible
    with the driverless printing support in iOS, macOS, and Linux clients.
  - Each printer can support options such as label modes, tear-off offsets,
    media tracking, media top offset, print darkness, resolution, roll
    selection, and speed.
  - Each printer can print "raw", Apple/PWG Raster, and/or PNG files.

  For more information, see the file "DOCUMENTATION.md", the man pages in the
  "man" directory, and/or the LPrint project page at
  "https://www.msweet.org/lprint".
commands:
  - lprint
notes:               
  private:           false
  confinement:       strict
  devmode:           false
  jailmode:          false
  trymode:           false
  enabled:           true
  broken:            false
  ignore-validation: false
base:         core18
snap-id:      z83tP2AxwcXcUTH4af7M1LcXnXoe99Xz
tracking:     stable
refresh-date: today at 17:15 CST
channels:
  stable:    1.0 2020-04-28 (104) 3MB -
  candidate: 1.0 2020-04-28 (104) 3MB -
  beta:      1.0 2020-04-28 (104) 3MB -
  edge:      1.0 2020-11-15 (123) 3MB -
installed:   1.0            (104) 3MB 

$ sudo snap interface 
error: no interfaces currently connected
$ sudo snap interface --all
Name                       Summary
[...]
raw-usb                    allows raw access to all USB devices
[...]

$ sudo snap logs lprint
error: snap "lprint" has no services

$ snap run lprint --help
Usage: lprint SUB-COMMAND [OPTIONS] [FILENAME]
       lprint [OPTIONS] [FILENAME]
       lprint [OPTIONS] -

Sub-commands:
  add PRINTER      Add a printer.
  cancel           Cancel one or more jobs.
  default          Set the default printer.
  delete           Delete a printer.
  devices          List devices.
  drivers          List drivers.
  jobs             List jobs.
  modify           Modify a printer.
  options          List printer options.
  printers         List printers.
  server           Run a server.
  shutdown         Shutdown a running server.
  status           Show server/printer/job status.
  submit           Submit a file for printing.

Options:
  -a               Cancel all jobs (cancel).
  -d PRINTER       Specify printer.
  -j JOB-ID        Specify job ID (cancel).
  -m DRIVER-NAME   Specify driver (add/modify).
  -n COPIES        Specify number of copies (submit).
  -o NAME=VALUE    Specify option (add,modify,server,submit).
  -u URI           Specify ipp: or ipps: printer/server.
  -v DEVICE-URI    Specify socket: or usb: device (add/modify).

$ sudo snap run lprint devices
lprint: Unable to initialize USB access: Other error

$ sudo snap interfaces
Slot  Plug
-     lprint:avahi-observe
-     lprint:home
-     lprint:network
-     lprint:network-bind
-     lprint:raw-usb

I'm not sure if that slot column just having - in it means the interface isn't hooked up or what - experienced administrator, but new to snap.

Does the above output look right to you?

michaelrsweet commented 2 years ago

@ccazabon The output is correct. I will be promoting a new snap build to beta for you to try shortly and will provide a command to install it when I do.

michaelrsweet commented 2 years ago

@ccazabon OK, I've promoted the current snap build to beta - please try installing the update lprint 1.1 and let me know what happens.

CyrosX commented 2 years ago

@michaelrsweet // edit: // snap connect lprint:raw-usb // now it works :)

I also have the usb access error. (btw. is it correct that I had to install avahi? got an error without it)

Run as root for testing

snap connections lprint
Interface        Plug                    Slot           Notes
avahi-control    lprint:avahi-control    -              -
home             lprint:home             :home          -
network          lprint:network          :network       -
network-bind     lprint:network-bind     :network-bind  -
network-manager  lprint:network-manager  -              -
raw-usb          lprint:raw-usb          -              -

Using now a new Raspberry Pi Zero 2 W, dietpi 7.9.3 (Debian-based), snap lprint 1.1. USB-Hub with 2 dymo 450 duo.

lsusb is working and shows both printers. Cups not installed (a remote cups will be used).