michaelrsweet / lprint

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

using lprint on debian 10 (buster) with Dyno LabelWriter 450 (USB) #68

Closed janwilmans closed 1 year ago

janwilmans commented 1 year ago

if I try to print anything, I get an error:

./lprint test.txt -v usb://DYMO/LabelWriter%20450?serial=01010112345600

lprint: statefile='/root/.lprint.conf' E [2022-07-18T13:17:37.741Z] Unable to create listener socket for '/usr/local/var/run/lprint.sock': No such file or directory E [2022-07-18T13:17:37.742Z] Unable to register 'LPrint._ipps-system._tcp': Local name collision E [2022-07-18T13:17:37.743Z] [Printer DYMO LabelWriter 450] Unable to register 'DYMO LabelWriter 450._ipp._tcp': Local name collision E [2022-07-18T13:17:37.743Z] [Printer DYMO LabelWriter 450] Unable to register 'DYMO LabelWriter 450._ipps._tcp': Local name collision E [2022-07-18T13:17:38.748Z] Unable to register 'LPrint._ipps-system._tcp': Local name collision E [2022-07-18T13:17:38.755Z] [Printer DYMO LabelWriter 450] Unable to register 'DYMO LabelWriter 450._ipp._tcp': Local name collision E [2022-07-18T13:17:38.758Z] [Printer DYMO LabelWriter 450] Unable to register 'DYMO LabelWriter 450._ipps._tcp': Local name collision lprint: Unable to connect to server: No such file or directory

I've not sure how to debug this, could you give me guidance how to continue?

janwilmans commented 1 year ago

The first clue is to create the run directory using mkdir -p /usr/local/var/run/

This gets rid of the Unable to create listener socket error but the Local Name collisions remain

janwilmans commented 1 year ago
oot@vcenter:/home/vimec# ./lprint test.txt 
DYMO LabelWriter 450-4
root@vcenter:/home/vimec# E [2022-07-18T14:14:05.252Z] [Job 4] Unable to process job with format 'application/octet-stream'.

without specifying the printer, the error message is different, still no clue where to go from here

michaelrsweet commented 1 year ago

@janwilmans Do you have CUPS installed with a local queue for the 450 as well?

janwilmans commented 1 year ago
cups is already the newest version (2.2.10-6+deb10u6).

cups is installed, but I'm not sure how to check whether there is a local queue ?

janwilmans commented 1 year ago

hm, apparently nothing is setup image

janwilmans commented 1 year ago

Ok, I have CUPS setup, and printed a test page: image

However, if I try to run lprint, jobs are always aborted.

$ lpstat -p -d
printer DYMO_LabelWriter_450 is idle.  enabled since Tue 19 Jul 2022 09:59:06 AM CEST
system default destination: DYMO_LabelWriter_450
$ lpstat -p -d
printer DYMO_LabelWriter_450 is idle.  enabled since Tue 19 Jul 2022 09:59:06 AM CEST
system default destination: DYMO_LabelWriter_450
$ ./lprint test.txt 
DYMO LabelWriter 450-9
$ ./lprint jobs
9 aborted      vimec            test.txt
8 aborted      vimec            test.txt
7 aborted      vimec            test.txt
6 aborted      vimec            test.txt
5 aborted      root             testfile.txt
4 aborted      root             test.txt
3 aborted      root             test.txt
2 aborted      root             test.txt
1 aborted      root             test.txt
$ 

How can I investigate why the jobs are aborted?

janwilmans commented 1 year ago

hm, now I double checked I was running a single lprint-server, image

but now when I try to print the server segfaults

I have a reproducable segfault when I run the lprint server as a normal user, but when I run it as 'root' then it keeps running and gives me :

E [2022-07-19T09:52:50.504Z] [Job 12] Unable to process job with format 'application/octet-stream'.

FYI: i'm running lprint 1.1.0 build against pappl 1.1.0 because that is the only combination that seems to work on debian 10 (that has cups 2.2.1)

michaelrsweet commented 1 year ago

@janwilmans You need to enable debug logging for LPrint. But keep in mind that LPrint does not support printing of plain text files to these label printers - most barely support US ASCII text. Instead, LPrint is setup to handle "raw" printing of preformatted (DYMO/EPL/ZPL) labels, direct printing of PNG/JPEG images, and PWG/Apple raster from CUPS, iOS, Android, etc. queues since it impersonates IPP Everywhere/AirPrint/Mopria printers on the network.

If you are getting a segfault I'll also need to see the backtrace to help you further...

janwilmans commented 1 year ago

I will re-compile with -g and get a backtrace, could you give me a sample file that works / is supported, so I can take that part out of the equation ?

michaelrsweet commented 1 year ago

@janwilmans Any PNG file (including the LPrint logo files in the static-resources directory) can be used for testing.

janwilmans commented 1 year ago
Core was generated by `./lprint server'.
Program terminated with signal SIGSEGV, Segmentation fault.

warning: Unexpected size of section `.reg-xstate/639' in core file.
#0  ipp_get_printer_attributes (client=0x55ca1845ce30) at printer-ipp.c:1446
1446    printer-ipp.c: No such file or directory.
[Current thread is 1 (Thread 0x7fa7663fc700 (LWP 639))]
(gdb) bt
#0  ipp_get_printer_attributes (client=0x55ca1845ce30) at printer-ipp.c:1446
#1  _papplPrinterProcessIPP (client=0x55ca1845ce30) at printer-ipp.c:790
#2  0x00007fa7686e8807 in _papplClientProcessIPP (client=client@entry=0x55ca1845ce30) at client-ipp.c:234
#3  0x00007fa7686e7648 in _papplClientProcessHTTP (client=client@entry=0x55ca1845ce30) at client.c:439
#4  0x00007fa7686e78c2 in _papplClientRun (client=0x55ca1845ce30) at client.c:671
#5  0x00007fa7682d7fa3 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#6  0x00007fa768606eff in clone () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) 

(gdb) info locals
ra = <optimized out>
printer = 0x0
ra = <optimized out>
printer = <optimized out>
(gdb) 

image

This core dump is based on pappl / lprint master branches (I modified base.h to make it compile against cups 2.2.1)

janwilmans commented 1 year ago

I'll answer my own question about how to setup a printer using CUPS lpadmin:

#!/bin/bash
#set -x

export PRINTER_NAME="labelprinter"

echo "searching for printers..."
#export PRINTER_DEV=`lpinfo -v | grep usb`
echo "Found: ${PRINTER_DEV}"

# list all drivers
# lpinfo -m   

# list all devices and their details
# lpinfo -l -v

export PRINTER_DEV="usb://DYMO/LabelWriter%20450?serial=01010112345600"

lpadmin -x $PRINTER_NAME 
lpadmin -p $PRINTER_NAME -E -v $PRINTER_DEV -P /usr/share/cups/model/lw450.ppd

#cupsaccept $PRINTER_NAME
#cupsenable $PRINTER_NAME

echo "Done."
echo ""

# set default printer
lpoptions -d $PRINTER_NAME

lpstat -d -p -v

However, I'm still figuring out how to set the "make/model" to "Dymo Label Printer"

image

michaelrsweet commented 1 year ago

OK, the backtrace doesn't make any sense because "client->printer" cannot be NULL if the "printer-uri" attribute was seen and the printer was found. Any failure sets the status code to something other than 'successful-ok', which bypasses the call to _papplPrinterProcessIPP...

What revision of PAPPL master did you build/install?