OpenPrinting / cups-filters

filters, backends, driverless utility, ... - Everything which CUPS 2.x needs to be used on non-Mac systems
Apache License 2.0
160 stars 126 forks source link

cups picks manual tray on HP Color LaserJet M252dw #478

Closed steinarb closed 1 year ago

steinarb commented 2 years ago

Platform: debian 11.4 "bullseye" on amd64 cups 2.3.3op2-3+11u2 HP Color LaserJet Pro M252dw, driverless, cups-filters 1.28.7

My HP Color LaserJet consistently prints from the manual tray, which it calls "Tray 1".

I opened "System->Adminstration->Print Settings" from the debian menu.

I double clicked on the printer HP_Color_LaserJet_Pro_M252dw501595

In "Printer Properties"->"Print Options" there is the setting "Media source".

"Media source" is a dropdown with the values Automatic Manual Tray 1 Tray 2

I have tried the settings "Automatic" (the default) and "Tray 1" and "Tray 2" and all of them uses the manual tray, which the printer display calls "Tray 1".

I saw no point in trying the "Manual" setting.

I have reported this as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1018265 There it was suggested I should report it here.

The debian issue has more information on the configuration and of what I have tried so far.

Other, possibly releated issues, are:

MathuserNik commented 2 years ago

I am just another user, not part of the cups or filters project. As a quick verification:

HP printers will consistently redirect to Tray 1 if a page size is sent to printer for which there isn't a size available, even if one has explicitly selected a different tray. It's possible that the tray guides have been incorrectly set, or that the tray/paper setting switches are broken.

One could try checking the above to ensure it's not something other than cups. Does the printer report the correct paper size in the tray? Try printing from a different OS if possible, and see if the same occurs. If the same problem shows, it is more likely that one of the above is the problem.

steinarb commented 2 years ago

MathuserNik @.***>:

HP printers will consistently redirect to Tray 1 if a page size is sent to printer for which there isn't a size available, even if one has explicitly selected a different tray. It's possible that the tray guides have been incorrectly set, or that the tray/paper setting switches are broken.

One could try checking the above to ensure it's not something other than cups. Does the printer report the correct paper size in the tray?

Yes, as far as I can tell: it reports A4 and that's what's loaded in the regular tray.

@.:~$ lpstat -t HP_Color_LaserJet_Pro_M252dw501595 scheduler is running no system default destination device for HP_Color_LaserJet_Pro_M252dw501595: implicitclass://HP_Color_LaserJet_Pro_M252dw501595/ HP_Color_LaserJet_Pro_M252dw501595 accepting requests since Wed 31 Aug 2022 05:08:55 PM CEST printer HP_Color_LaserJet_Pro_M252dw501595 is idle. enabled since Wed 31 Aug 2022 05:08:55 PM CEST @.:~$ lpoptions @.:~$ lpoptions -p HP_Color_LaserJet_Pro_M252dw501595 device-uri=ipps://HP%20Color%20LaserJet%20Pro%20M252dw%20(501595)._ipps._tcp.local/ printer-info='HP Color LaserJet Pro M252dw (501595)' printer-location printer-make-and-model='Hewlett-Packard HP Color LaserJet Pro M252dw' printer-type=16781340 @.:~$ lpoptions -p HP_Color_LaserJet_Pro_M252dw501595 -l PageSize/Media Size: 100x150mm 184x260mm 195x270mm 4x6 5x8 A4 A5 A6 B5 B6 DoublePostcardRotated Env10 EnvC5 EnvDL EnvMonarch Executive FanFoldGermanLegal ISOB5 Legal Letter Oficio Postcard roc16k Custom.WIDTHxHEIGHT InputSlot/Media Source: Auto Manual Tray1 Tray2 ColorModel/Print Color Mode: Gray AdobeRGB DeviceRGB DeviceGray RGB Duplex/2-Sided Printing: None DuplexNoTumble DuplexTumble OutputBin/Output Tray: FaceDown cupsPrintQuality/Print Quality: Draft Normal print-content-optimize/Print Optimization: auto photo graphics text text-and-graphics print-scaling/Print Scaling: auto auto-fit fill fit none @.***:~$

Try printing from a different OS and see if the same occurs. If the same problem shows, it is more likely that one of the above is the problem.

Printing from an iPhone and from a windows machine works fine, and picks the regular tray.

tillkamppeter commented 1 year ago

Could you give us your /var/log/cups/error_log file after a job with the problem? Set CUPS to debug logging before sending the job (cupsctl --debug-logging) and when attaching your error_log after the job, rename the file to have a .txt extension so that GitHub accepts it.

steinarb commented 1 year ago

Till Kamppeter @.***>:

Could you give us your /var/log/cups/error_log file after a job with the problem? Set CUPS to debug logging before sending the job (cupsctl --debug-logging) and when attaching your error_log after the job, rename the file to have a .txt extension so that GitHub accepts it.

Here's an error_log from printing a test file after setting 'cupsctl --debug-logging': https://gist.github.com/steinarb/7ab8d472b82f1c42b3864a759ede827a

tillkamppeter commented 1 year ago

The only thing looking wrong to me in the error_log is that no setting for media-source or InputSlot got sent along with the Job or set by CUPS:

D [13/Dec/2022:23:52:44 +0100] [Job 13] argv[5]="job-uuid=urn:uuid:4bfea665-605a-3850-4e9b-b6b357e725b9 cups-browsed job-originating-host-name=localhost date-time-at-creation= date-time-at-processing= time-at-creation=1670971964 time-at-processing=1670971964"

This probably leads to the printer-internal default being selected and this could mean Manual. Could you check in the web admin interface, whether there is defined which paper is loaded into which tray and also whether one can also configure what happens when "Auto" is set as media source? Could you enter the loaded page size(s) in the web admin interface of the printer?

steinarb commented 1 year ago

Till Kamppeter @.***>:

[snip!] Could you check in the web admin interface, whether there is defined which paper is loaded into which tray and also whether one can also configure what happens when "Auto" is set as media source? Could you enter the loaded page size(s) in the web interface?

Set Printer Options: General Media Size: A4 Media Source: Automatic Print Color Mode: Color 2-Sided Printing: On (Portrait) Print Quality: Normal Print Optimization: Automatic Print Scaling: Automatic

tillkamppeter commented 1 year ago

@steinarb Are these your settings in the printer's web interface?

steinarb commented 1 year ago

Till Kamppeter @.***>:

@steinarb Are these your settings in the printer's web interface?

These are the setting for the printer from cups web interface.

Do you mean the printer has a web interface...?

Wow! http://10.10.10.37

Lots of stuff here!

This one is probably closest to what you're asking about: http://10.10.10.37/set_config_ph.html?tab=System&menu=PaperHandling

Unfortunately, the pages are in Norwegian and there is no menu entry to set the language.

Standard papirstørrelse: A4 (dropdown) Standard papirtype: Vanlig Manuell mating: Av Tosidig: Av Bind: Langside (not active) Skuffstr. 1: Alle str. Skufftype 1: Alle typer Skuffstr. 2: A4 Skufftype 2: Alle typer

"Standard papirstørrelse" translates to "Standard paper size" "Standard papirtype" translates to "Standard paper type" "Vanlig" translates to "Regular" "Manuell mating" translates to "Manual feeding" "Av" translates to "Off" "Tosidig" translates to "Two sided" "Bind" translate to "Binding" (as in book) "Skuffstr. 1" translates to "Tray size 1" "Skufftype 1" translages to "Tray type 1" "Skuffstr. 2" translates to "Tray size 2" "Skufftype 2" translages to "Tray type 2"

tillkamppeter commented 1 year ago

@steinarb Could you run the command

ipptool -tv ipps://NPI501595.local:443/ipp/print get-printer-attributes.test > attrs.txt

and attach attrs.txt to this bug report?

steinarb commented 1 year ago

Here is attrs.txt from NPI501595.

The file does mention trays, I see: auto,manual,tray-1,tray-2

tillkamppeter commented 1 year ago

The description of the Apple Raster (URF) support of the printer looks strange for me. The properties are as usual described in a single string supplied both in the printer's DNS-SD record and as urf-supported printer IPP attribute. In attrs.txt from above it read:

urf-supported (1setOf keyword) = V1.4,CP99,W8,OB10,PQ3-4-5,ADOBERGB24,DEVRGB24,DEVW8,SRGB24,DM1,IS1,MT1-2-3-5-12,RS600

The media trays are encoded by the IS ("InputSlot") field, and here the only entry is 1. Assuming that these integer numbers are the same as the ones from the MediaPosition mentioned above, there is only the "Manual" tray advertised, not even the standard tray (21).

This could be a firmware bug which botches the printer's Apple Raster support. You should try copying the printer's PPD file, editing the cost values (the integer numbers) in the copy, putting a high number in the image/urf line and 0 in the image/pwg-raster line. Then create a queue using this PPD:

lpadmin -p testqueue -E -v ipps://NPI501595.local:443/ipp/print -P YOURPPD

replacing YOURPPD by the name of your edited copy of the PPD file. Can you print with that queue and is the main tray be selected if no other tray explicitly specified?

tillkamppeter commented 1 year ago

If there is no cupsFilter(2): line for image/pwg-raster try with other cupsFilter(2): lines, like for PDF, PostScript, or PCLm. Also raise the number in the image/urf line to get the desired alternative for sure.

steinarb commented 1 year ago

No "image/pwg-raster" in /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw501595.ppd (uploaded as HP_Color_LaserJet_Pro_M252dw_501595.zip because github would't let me attach a .ppd file)

The file contains the following lines with "image/" in them:

     "image/urf image/urf 1 -"
     "image/jpeg image/jpeg 0 -"
tillkamppeter commented 1 year ago

So please try with the PDF, PCLm, PostScript, ... instead, test with one of these languages at a time.

steinarb commented 1 year ago

Here is what I did:

  1. Copied the /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw501595.ppd file to /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw_501595_edited.ppd
  2. Set the "image/urf" entry to cost 1 and set all other cupsFilter2 values to 0
    *cupsFilter2: "application/vnd.cups-pdf application/pdf 0 -"
    *cupsFilter2: "image/urf image/urf 1 -"
    *cupsFilter2: "application/PCLm application/PCLm 0 -"
    *cupsFilter2: "application/vnd.cups-pdf application/vnd.hp-pclxl 0 gstopxl"
    *cupsFilter2: "application/vnd.cups-postscript application/postscript 0 -"
    *cupsFilter2: "application/vnd.cups-raster application/vnd.hp-pcl 0 rastertopclx"
    *cupsFilter2: "image/jpeg image/jpeg 0 -"
  3. Created the testqueue with the following command
    root@marquez:~# /usr/sbin/lpadmin -p testqueue -E -v ipps://NPI501595.local:443/ipp/print -P  /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw_501595_edited.ppd 
    lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS.
    root@marquez:~# 
  4. Opened a PDF file in the Atril document viewer and printed it to testqueue
  5. The PDF file came out from the regular tray (i.e. it didn't use the manual feed), with color and printed dual sided
tillkamppeter commented 1 year ago

Thank you very much for this test.

This made it work for you but does not tell us why, as you have made all formats having practically the same cost. 0 and 1 is no significant difference, as CUPS runs a filter chain (1-4 filters typically) to obtain the desired output format. Each filter got assigned a cost value by CUPS. The *cupsFilter2 lines in the PPD describe the last filter of this chain and this filter's cost value. CUPS looks for the filter chain where the sum of the cost values is the lowest one. Typical cost values of the filters are between 0 and 100. So having the cost value of the last filter only differing by 1 usually makes CUPS basing its decision on the other filters in the chain. So If you want to assure that a certain of these cupsFilter2 lines is used, you either assign 1000 to all the other lines and 0 to the desired line or you comment out the unwished lines, putting a % after the * in the beginning of the line (*%cupsFilter2: ...), leaving only one active line.

As you changes worked for you I assume that somehoe anther format than URF got sent to the printer, but I want to know which one, and even better I would like to know which of the 7 available formats works and which not. So I would like to ask you to do 7 tests. In each test you test one format. Either set this format´s cost to 0 and set the costs of the other formats to 1000 or comment out the lines of the other formats. Do it one-by-one, remove your queue, edit, the PPD, create the queue again, try to print. Could you tell us then which formats work and which not, and also if a format does not work, if it simply wants to use the manual tray or if it is even a more severe problem (printing garbage or nothing).

steinarb commented 1 year ago

Ok I have no idea what I'm doing here so having clear instructions, is good. :-)

Here is what I've been doing

  1. Set one of the cupsFilter2 settings to 0 and the others to 1000
  2. Re-run lpadmin to create the testqueue
    /usr/sbin/lpadmin -p testqueue -E -v ipps://NPI501595.local:443/ipp/print -P  /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw_501595_edited.ppd 
  3. Print a PDF file loaded in the Atril document viewer

Should I have deleted the testqueue somehow before recreating it? Should I have printed something other than the PDF? Do the Atril document viewer have to be restarted between each print?

Anyway: all attempts printed out OK: Format with 0 cost tray dual sided colour
application/vnd.cups-pdf regular yes yes
image/urf regular yes yes
application/PCLm regular yes yes
application/vnd.cups-pdf regular yes yes
application/vnd.cups-postscript regular yes yes
application/vnd.cups-raster regular yes yes
image/jpeg regular yes yes
tillkamppeter commented 1 year ago

The safest way would be to actually remove the queue with lpadmin -x testqueue after each test, and also to restart the viewer after each test.

Newer versions of cups-filters (at least version 2.0b1 and later) have only a single *cupsFilter2: ... line in the auto-generated PPD files. Perhaps those work better, but I do not have enough test reports yet.

steinarb commented 1 year ago

No more luck with that, unfortunately.

Here's what I did for each attempt:

  1. Set one of the cupsFilter2 settings to 0 and the others to 1000
  2. Delete the testqueue:
    /usr/sbin/lpadmin -x testqueue
  3. Re-run lpadmin to create the testqueue
    /usr/sbin/lpadmin -p testqueue -E -v ipps://NPI501595.local:443/ipp/print -P  /etc/cups/ppd/HP_Color_LaserJet_Pro_M252dw_501595_edited.ppd 
  4. Start Atril document viewer, load a PDF file and print the PDF file to the printer testqueue
This time, as well, all attempts printed out OK: Format with 0 cost tray dual sided colour
application/vnd.cups-pdf regular yes yes
image/urf regular yes yes
application/PCLm regular yes yes
application/vnd.cups-pdf regular yes yes
application/vnd.cups-postscript regular yes yes
application/vnd.cups-raster regular yes yes
image/jpeg regular yes yes
tillkamppeter commented 1 year ago

Thank you very much for the thorough testing.

So it seems on all your test efforts the bug does not show. As you have done them on a separate queue for testing ("testqueue") you probably still have your original queue for day-to-day printing. Is that original queue also correctly working now? If not, we need to somehow compare it, both error_log and PPD files. If it is also working. I have no idea what to do any further and we will close this issue.

steinarb commented 1 year ago

Yes, the original printer started using the correct tray a while back, while trying out stuff people asked me to try out, on the CUPS mailing list (I reported back to the person that made me try stuff). https://lists.cups.org/pipermail/cups/2022-December/thread.html#75172

However I have no idea why things changed or if it will stop working just as mysteriously at some point in time.

I have also installed a hplip printer queue for the printer, with some degree of success (works, except for on webkit based web browsers, where it doesn't print colours).

But thanks for trying to nail this down.

tillkamppeter commented 1 year ago

OK, thanks a lot for your cooperation, @steinarb So now is all working, we do not know why the bug went away, but it went away. So let us close this issue here...