Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cups-browsed, driverless: request urf-supported attribute #86

Closed
wants to merge 1 commit into from
Closed

Conversation

mark246
Copy link

@mark246 mark246 commented Jan 6, 2019

Fixes bug #22 - at least for me (I have a Canon Pixma MG4250 printer).

I have not tested other Canon models, so can't be certain that this will fix it for other Pixma variants referred to in the bug report (and also can't be sure that requesting this attribute won't be a breaking change for other printers).

@mark246
Copy link
Author

mark246 commented Jan 6, 2019

cups-filters-issue-22-notes.txt - notes on reproducing the issue, PPD generated after applying the patch, etc.

@tillkamppeter
Copy link
Member

File cups-filters-issue-22-notes.txt of the previous posting from @mark246. Please post information to be read by humans directly into a comment, for easy reading in the browser.

# Notes

Notes on https://github.com/OpenPrinting/cups-filters/issues/22

## Steps to reproduce (Mint 19.1)

Build the 1.20 release:

    sudo apt-get install build-essential automake libtool mupdf-tools
    sudo apt-get build-dep cups-filters

    git clone https://github.com/OpenPrinting/cups-filters
    cd cups-filters && git checkout release-1-20-2

    ./autogen.sh && ./configure CFLAGS='-g -O0' CXXFLAGS='-g -O0 -w'
    make driverless

Query the printer attributes (this fails):

    printer=ipp://004417000000.local:631/ipp/printer
    .libs/driverless $printer

> Printer does not support required IPP attributes or document formats

But if I `git checkout release-1-19-0` and rebuild, it works.

Wiresharking, it looks like the key difference is inclusion of "requested-attributes" in the IPP `Get-Printer-Attributes` request in 1.21.2 (this is absent in 1.19.0 so according to RFC 2911 means the printer should return all available attributes).

With 1.19.0 (and Canon Pixma MG4250):
- the IPP response has a "urf-supported" attribute
- cupsfilters/ppdgenerator.c can deduce the resolution (600 dpi) from this attribute

With 1.21.2 (and Canon Pixma MG4250):
- no "urf-supported" attribute is present in the response
- cupsfilters/ppdgenerator.c fails to determine the resolution

## Proposed Fix

Adding "urf-supported" to the `pattrs` list in  cups-filters/utils/driverless.c seems to work (at least for this printer). 

With this patch, `./libs/driverless` runs
ok and produces the output shown below.

Copying the patched executable:

    sudo cp .libs/driverless /usr/lib/cups/driver/driverless
    system-config-printer

it's possible to print again.

### Output, after applying patch

Here's the output:

    *PPD-Adobe: "4.3"
    *FormatVersion: "4.3"
    *FileVersion: "1.20.2"
    *LanguageVersion: English
    *LanguageEncoding: ISOLatin1
    *PSVersion: "(3010.000) 0"
    *LanguageLevel: "3"
    *FileSystem: False
    *PCFileName: "drvless.ppd"
    *Manufacturer: "Canon"
    *ModelName: "Canon MG4200 series"
    *Product: "(Canon MG4200 series)"
    *NickName: "Canon MG4200 series, driverless, cups-filters 1.20.2"
    *ShortNickName: "Canon MG4200 series"
    *ColorDevice: True
    *cupsVersion: 2.2
    *cupsSNMPSupplies: False
    *cupsLanguages: "en"
    *APSupplies: "http://004417000000.local."
    *cupsFilter2: "image/urf image/urf 100 -"
    *cupsFilter2: "image/jpeg image/jpeg 0 -"
    *OpenUI *PageSize/Media Size: PickOne
    *OrderDependency: 10 AnySetup *PageSize
    *DefaultPageSize: 4x6
    *PageSize 200x148mm: "<</PageSize[566.929133858268 419.527559055118]>>setpagedevice"
    *PageSize 3.5x5/3.5 x 5": "<</PageSize[252 360]>>setpagedevice"
    *PageSize 3.5x5.Borderless/3.5 x 5" (Borderless): "<</PageSize[252 360]>>setpagedevice"
    *PageSize 4x6/4 x 6": "<</PageSize[288 432]>>setpagedevice"
    *PageSize 4x6.Borderless/4 x 6" (Borderless): "<</PageSize[288 432]>>setpagedevice"
    *PageSize 5x7/5 x 7": "<</PageSize[360 504]>>setpagedevice"
    *PageSize 5x7.Borderless/5 x 7" (Borderless): "<</PageSize[360 504]>>setpagedevice"
    *PageSize 8x10/8 x 10": "<</PageSize[576 720]>>setpagedevice"
    *PageSize 8x10.Borderless/8 x 10" (Borderless): "<</PageSize[576 720]>>setpagedevice"
    *PageSize A4/A4: "<</PageSize[595.275590551181 841.889763779528]>>setpagedevice"
    *PageSize A4.Borderless/A4 (Borderless): "<</PageSize[595.275590551181 841.889763779528]>>setpagedevice"
    *PageSize A5/A5: "<</PageSize[419.527559055118 595.275590551181]>>setpagedevice"
    *PageSize B5/JIS B5: "<</PageSize[515.905511811024 728.503937007874]>>setpagedevice"
    *PageSize DoublePostcardRotated/Oufuku Reply Postcard: "<</PageSize[419.527559055118 566.929133858268]>>setpagedevice"
    *PageSize Env10/#10 Envelope: "<</PageSize[296.985826771654 684]>>setpagedevice"
    *PageSize EnvDL/DL Envelope: "<</PageSize[311.811023622047 623.622047244094]>>setpagedevice"
    *PageSize Legal/US Legal: "<</PageSize[612 1008]>>setpagedevice"
    *PageSize Letter/US Letter: "<</PageSize[612 792]>>setpagedevice"
    *PageSize Letter.Borderless/US Letter (Borderless): "<</PageSize[612 792]>>setpagedevice"
    *PageSize Postcard/Hagaki: "<</PageSize[283.464566929134 419.527559055118]>>setpagedevice"
    *PageSize Postcard.Borderless/Hagaki (Borderless): "<</PageSize[283.464566929134 419.527559055118]>>setpagedevice"
    *CloseUI: *PageSize
    *OpenUI *PageRegion/Media Size: PickOne
    *OrderDependency: 10 AnySetup *PageRegion
    *DefaultPageRegion: 4x6
    *PageRegion 200x148mm: "<</PageSize[566.929133858268 419.527559055118]>>setpagedevice"
    *PageRegion 3.5x5/3.5 x 5": "<</PageSize[252 360]>>setpagedevice"
    *PageRegion 3.5x5.Borderless/3.5 x 5" (Borderless): "<</PageSize[252 360]>>setpagedevice"
    *PageRegion 4x6/4 x 6": "<</PageSize[288 432]>>setpagedevice"
    *PageRegion 4x6.Borderless/4 x 6" (Borderless): "<</PageSize[288 432]>>setpagedevice"
    *PageRegion 5x7/5 x 7": "<</PageSize[360 504]>>setpagedevice"
    *PageRegion 5x7.Borderless/5 x 7" (Borderless): "<</PageSize[360 504]>>setpagedevice"
    *PageRegion 8x10/8 x 10": "<</PageSize[576 720]>>setpagedevice"
    *PageRegion 8x10.Borderless/8 x 10" (Borderless): "<</PageSize[576 720]>>setpagedevice"
    *PageRegion A4/A4: "<</PageSize[595.275590551181 841.889763779528]>>setpagedevice"
    *PageRegion A4.Borderless/A4 (Borderless): "<</PageSize[595.275590551181 841.889763779528]>>setpagedevice"
    *PageRegion A5/A5: "<</PageSize[419.527559055118 595.275590551181]>>setpagedevice"
    *PageRegion B5/JIS B5: "<</PageSize[515.905511811024 728.503937007874]>>setpagedevice"
    *PageRegion DoublePostcardRotated/Oufuku Reply Postcard: "<</PageSize[419.527559055118 566.929133858268]>>setpagedevice"
    *PageRegion Env10/#10 Envelope: "<</PageSize[296.985826771654 684]>>setpagedevice"
    *PageRegion EnvDL/DL Envelope: "<</PageSize[311.811023622047 623.622047244094]>>setpagedevice"
    *PageRegion Legal/US Legal: "<</PageSize[612 1008]>>setpagedevice"
    *PageRegion Letter/US Letter: "<</PageSize[612 792]>>setpagedevice"
    *PageRegion Letter.Borderless/US Letter (Borderless): "<</PageSize[612 792]>>setpagedevice"
    *PageRegion Postcard/Hagaki: "<</PageSize[283.464566929134 419.527559055118]>>setpagedevice"
    *PageRegion Postcard.Borderless/Hagaki (Borderless): "<</PageSize[283.464566929134 419.527559055118]>>setpagedevice"
    *CloseUI: *PageRegion
    *DefaultImageableArea: 4x6
    *DefaultPaperDimension: 4x6
    *ImageableArea 200x148mm: "9.637795275591 14.173228346457 557.291338582677 405.354330708661"
    *PaperDimension 200x148mm: "566.929133858268 419.527559055118"
    *ImageableArea 3.5x5: "9.637795275591 14.173228346457 242.362204724409 345.826771653543"
    *PaperDimension 3.5x5: "252 360"
    *ImageableArea 3.5x5.Borderless: "0 0 252 360"
    *PaperDimension 3.5x5.Borderless: "252 360"
    *ImageableArea 4x6: "9.637795275591 14.173228346457 278.362204724409 417.826771653543"
    *PaperDimension 4x6: "288 432"
    *ImageableArea 4x6.Borderless: "0 0 288 432"
    *PaperDimension 4x6.Borderless: "288 432"
    *ImageableArea 5x7: "9.637795275591 14.173228346457 350.362204724409 489.826771653543"
    *PaperDimension 5x7: "360 504"
    *ImageableArea 5x7.Borderless: "0 0 360 504"
    *PaperDimension 5x7.Borderless: "360 504"
    *ImageableArea 8x10: "9.637795275591 14.173228346457 566.362204724409 705.826771653543"
    *PaperDimension 8x10: "576 720"
    *ImageableArea 8x10.Borderless: "0 0 576 720"
    *PaperDimension 8x10.Borderless: "576 720"
    *ImageableArea A4: "9.637795275591 14.173228346457 585.637795275591 827.716535433071"
    *PaperDimension A4: "595.275590551181 841.889763779528"
    *ImageableArea A4.Borderless: "0 0 595.275590551181 841.889763779528"
    *PaperDimension A4.Borderless: "595.275590551181 841.889763779528"
    *ImageableArea A5: "9.637795275591 14.173228346457 409.889763779528 581.102362204724"
    *PaperDimension A5: "419.527559055118 595.275590551181"
    *ImageableArea B5: "9.637795275591 14.173228346457 506.267716535433 714.330708661417"
    *PaperDimension B5: "515.905511811024 728.503937007874"
    *ImageableArea DoublePostcardRotated: "18 36 401.527559055118 530.929133858268"
    *PaperDimension DoublePostcardRotated: "419.527559055118 566.929133858268"
    *ImageableArea Env10: "15.874015748031 106.015748031496 281.111811023622 661.322834645669"
    *PaperDimension Env10: "296.985826771654 684"
    *ImageableArea EnvDL: "15.874015748031 106.015748031496 295.937007874016 600.944881889764"
    *PaperDimension EnvDL: "311.811023622047 623.622047244094"
    *ImageableArea Legal: "18.141732283465 14.173228346457 593.858267716535 993.826771653543"
    *PaperDimension Legal: "612 1008"
    *ImageableArea Letter: "18.141732283465 14.173228346457 593.858267716535 777.826771653543"
    *PaperDimension Letter: "612 792"
    *ImageableArea Letter.Borderless: "0 0 612 792"
    *PaperDimension Letter.Borderless: "612 792"
    *ImageableArea Postcard: "9.637795275591 14.173228346457 273.826771653543 405.354330708661"
    *PaperDimension Postcard: "283.464566929134 419.527559055118"
    *ImageableArea Postcard.Borderless: "0 0 283.464566929134 419.527559055118"
    *PaperDimension Postcard.Borderless: "283.464566929134 419.527559055118"
    *HWMargins: "18 36 18 36"
    *ParamCustomPageSize Width: 1 points 252.283464566929 609.448818897638
    *ParamCustomPageSize Height: 2 points 360 1916.220472440945
    *ParamCustomPageSize WidthOffset: 3 points 0 0
    *ParamCustomPageSize HeightOffset: 4 points 0 0
    *ParamCustomPageSize Orientation: 5 int 0 3
    *CustomPageSize True: "pop pop pop <</PageSize[5 -2 roll]/ImagingBBox null>>setpagedevice"
    *OpenUI *ColorModel/Print Color Mode: PickOne
    *OrderDependency: 10 AnySetup *ColorModel
    *ColorModel RGB/Color: "<</cupsColorSpace 19/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice"
    *ColorModel Gray/Monochrome: "<</cupsColorSpace 18/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice"
    *DefaultColorModel: RGB
    *CloseUI: *ColorModel
    *OpenUI *Duplex/2-Sided Printing: PickOne
    *OrderDependency: 10 AnySetup *Duplex
    *DefaultDuplex: None
    *Duplex None/Off: "<</Duplex false>>setpagedevice"
    *Duplex DuplexNoTumble/On (Portrait): "<</Duplex true/Tumble false>>setpagedevice"
    *Duplex DuplexTumble/On (Landscape): "<</Duplex true/Tumble true>>setpagedevice"
    *CloseUI: *Duplex
    *cupsBackSide: Rotated
    *DefaultResolution: 600dpi
    *OpenUI *cupsPrintQuality/Print Quality: PickOne
    *OrderDependency: 10 AnySetup *cupsPrintQuality
    *DefaultcupsPrintQuality: 4
    *cupsPrintQuality 4/Normal: "<</HWResolution[600 600]>>setpagedevice"
    *cupsPrintQuality 5/High: "<</HWResolution[600 600]>>setpagedevice"
    *CloseUI: *cupsPrintQuality

## What about "cups-browsed"?

The same logic for requested-attributes is duplicated in `utils/cups-browsed.c`. So maybe that needs fixing too?

Running the version that comes with Mint 19.1 (cups-filters 1.20.2-0ubuntu3)

    cups-browsed -d -v

The output contains:

    Checking whether printer Canon_MG4200_series understands Apple Raster:
    --> Printer does not support Apple Raster.
    ...
    Printer Canon_MG4200_series (ipp://004417000000.local:631/ipp/printer, not PWG Raster, not Apple Raster, not PCLm, not PDF) does not support the driverless printing protocol cups-browsed is configured to accept for setting up such printers automatically, ignoring this printer.

which looks like it might be a manifestation of the same problem.

To investigate, I found it necessary to to a dpkg-buildpackage as the upstream version wouldn't bind to the CUPS Browsing socket.

    sudo service cups-browsed stop
    sudo apt-get build-dep cups-browsed
    apt-get source cups-filters
    cd cups-filters-1.20.2/
    dpkg-buildpackage # Ignore ".. failed to sign .dsc file"
    
    ./.libs/cups-browsed  -d -v

Yup, same "...ignoring this printer." error message.

Then tried adding "urf-supported" just like with the driverless.c,

    Checking whether printer Canon_MG4200_series understands Apple Raster:
    Attr: urf-supported
    Value: CP1,PQ4-5,RS600,SRGB24,W8,DM3,OB9,OFU0
    --> Printer supports Apple Raster.

and it looks like it tries to add the printer

    Loaded PPD file /tmp/048dc5c39432e from local temporary queue Canon_MG4200_series.
    ...
    Printer ipp://004417000000.local:631/ipp/printer: Local queue Canon_MG4200_series, IPP Printer, Slave of None (To be created/updated)

I manually copied the executable to the right place and restarted
the daemon:

    strip ./.libs/cups-browsed
    sudo cp ./.libs/cups-browsed /usr/sbin/cups-browsed 
    sudo service cups-browsed start

The printer is being detected automatically.

@mark246
Copy link
Author

mark246 commented Jan 7, 2019

@tillkamppeter hello and thanks for taking the time to look at my pull request (my first public one on github). If there are any alternative approaches to fixing this you'd like me to try or you need more logs etc then I'll be happy to help.

@tillkamppeter
Copy link
Member

cups-filters 1.19.0 did mot add a "requested-attributes" attribute to the get-printer-attributes request, which, unfortunately, did not lead to all attributes being returned. Especially the "media-col-database" was not returned and so not all media sizes and types got reported. Therefore I introduced this attribute in commit 4b92fff on Jan 26, 2018, copying from CUPS' lpadmin utility (see below).

I have checked CUPS. the lpadmin utility (with "-m everywhere, file systemv/lpadmin.c) does exactly the same as cups-browsed and driverless, so has the same bug, but the scheduler (CUPS daemon) does different when auto-generating print queues for IPP printers.
Instead of a line

ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
                 "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
                 NULL, pattrs);

with appropriately set pattrs array (the array where you have added "urf-supported" in your patch) it uses

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
                 "requested-attributes", NULL, "all");

and no need of a pattrs array (function create_local_bg_thread() in scheduler/ipp.c).
Could you edit both utils/cups-browsed.c and utils/driverless.c to use this method and see whether it works with your printer (reporting "urf-supported") AND reports the "media-col-database"?

By the way, the CUPS web interface ( get_printer_ppd() function in cgi-bin/admin.c) does not add "requested-attributes" and so would support your printer but not use "media-col-database".

In any case we need to report a bug to CUPS, as it is completely inconsistent, but at first we need to find the correct solution here in cups-filters.

@tillkamppeter
Copy link
Member

Please also test to still use the pattrs array, but instead of the original entries use only the two entries "all" and "media-col-database". Does this also work with your printer and provide the "media-col-database" entry in the IPP response?
This is the method which is used by ipptool with the template file /usr/share/cups/ipptool/get-printer-attributes-2.0.test.

@mark246
Copy link
Author

mark246 commented Jan 10, 2019

@tillkamppeter I've tried the two alternative solutions you suggested. In each case I captured the IPP request/response like this in each case:

sudo tshark -i enp2s0  -f "host 192.168.1.118" -Y "ipp" -T json
make driverless && ./.libs/driverless ipp://004417000000.local:631/ipp/printer 

But here's the summary of the results.

Attempt 1 (Code same as in my current pull request)

  • PPD is generated "successfully" but contains no MediaType information.
  • "urf-supported present in response
  • "media-col-database" is huge, and nonsensical (contains the same data block repeated over-and-over).

Attempt 2 (ippAddString, no pattrs, "all")

  • PPD is generated, and DOES contain MediaType information
  • "printer-attributes-tag" section is present, including "urf-supported" field
  • Response is a reasonable size (4K), but "media-col-database" is NOT present

Attempt 3 (pattrs = {"all", "media-col-database"})

  • PPD generation fails, with "Printer does not support required IPP attributes or document formats"
  • The response is huge and contains a corrupt media-col-database similar to attempt 1
  • "printer-attributes-tag" section is missing, so there's no "urf-supported" field
  • Power-cycling the printer and repeating does not "fix" the corrupt media-col-database.

In case you need them, here are the full packet captures and PPD output: bug22-logs.zip

@tillkamppeter
Copy link
Member

As in CUPS (see CUPS issue #5484) I use the attributes "all" and "media-col-database" now. This lets the "urf-supported" and also all page size and margin info get corectly reported.
Fixed in cups-filters with commit 5259bb7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants