Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GSoC'22 Work Product - Scanning Support in PAPPL emulating an eSCL Scanning

GSoC'22 Work Product : Scanning Support in PAPPL emulating an eSCL scanner

Rishabh | Github | Email | LinkedIn | View Project

Relevant Project Links

Commit Details

What is PAPPL?

PAPPL is a simple C-based framework/library for developing CUPS Printer Applications, which are the recommended replacement for printer drivers. It was specifically developed to support LPrint and a future Gutenprint Printer Application but is sufficiently general purpose to support any kind of printer or driver that can be used on desktops, servers, and in embedded environments.

Why do we need to add eSCL Scanning support in PAPPL?

With multi-function printers in mind (printer, scanner, and typically fax in one device), the IPP Scan standard was developed, allowing IPP to be used for both printing and scanning. Driverless scanning, in particular, is conceivable utilizing the same ideas as driverless printing. Manufacturers actually utilize eSCL and WSD for driverless scanning instead (both of which are available in free software). With this in mind, we are adding eSCL support to the PAPPL scanning. eSCL is the most prevalent communication protocol for driverless scanning.

How does an eSCL parser work?

  • The client sends a request to the server and we extract this request and then convert this into a XML data structure using a tiny XML composing/parsing mini-library, implemented inside the scanner-xml.h (as a wrapper around libxml).

  • The scan protocol is implemented using proto_handler and a new structure is created with the name xml_rd to read the values from the xml structure and devcaps_source is also defined to store the source capabilities.

  • Subsequent functions have been defined in the scanner-xml.h which are used to declare constants and loop through the XML tree structure by iterating the nodes and matching them with the requested capability.

  • proto_handler_escl structure is defined in client-escl.c which represents the eSCL protocol handler and further functions are defined in this file which parse the various capabilities of the scanner device by calling the helper functions to iterate through the tree structure and storing the parsed value or returning NULL if the requested value is not present with the device and based on the Mopria standards.

  • Some of these parsing functions are :

    • escl_parse_color_modes : Parses the colour modes available in the scanner by searching for the ColorMode tag in XML tree.
    • escl_parse_document_formats : Parses the document formats compatible with Scanner.
    • escl_parse_discrete_resolutions : Parses discrete resolutions for the Scanner.
    • escl_parse_resolutions_range : Parses the resolution range for the Scanner.
    • escl_parse_resolutions : Parses the supported resolutions.
    • escl_parse_setting_profiles : Parses all the settings profiles (color modes, document formats etc), by calling their respective functions and validate the results by looking for errors.
    • escl_parse_justification : Parses ADF justification for the Scanner by iterating for pwg:XImagePosition and pwg:YImagePosition in the tree.
    • escl_source_parse : Parses the source capabilities and returns error strings if errors are present or the values cannot be matched in the tree.
    • escl_compression_parse : Parses compression factor parameters for the Scanner.
    • escl_device_parse : Parses all the device capabilities by calling the respective functions for the property and stores them in a devcaps structure.

Project Task

Our task here is to build an eSCL scan interface to the programme so that it can imitate an eSCL scanner. The most prevalent communication protocol for driverless scanning is eSCL, which is also used by AirPrint. eSCL is the HTTP-based protocol that Apple employs for AirScan, which is accessible on all multi-function printers that also support AirPrint and is meant to facilitate scanning from Apple's iOS-enabled mobile devices. The eSCL specifications have also been published by Mopria and the same can be viewed at Mopria eSCL Specification

Project Report

Expectations from the project’s implementation:

  • Implement the right mix of PAPPL's IPP parser code and AirSane's eSCL parser code to end up with an eSCL parser for PAPPL.
  • Read Mopria's eSCL specification to develop the parser.

Results:

The eSCL parser has been made by defining client eSCL processing functions in client-escl.c file and using libxml as a wrapper class for defining the data strcuture and XML structures in scanner-xml.h.

The functions can easily be called to perform the scan jobs for a Scanner Application.

Pending Issues:

  • Encapsulation of sane-backends into the first, retro-fitting Scanner Application with scanning support in pappl-retrofit.
  • If the parser fails due to some error, this error should be reported and fixed by debugging.

Pending Test:

  • Take a color image as sample, convert it to the right size and color space and send it to the client of the correct size on scan requests using the Scanner Application.

Words of Thanks

I would like to thank my mentor @tillkamppeter for his continuous guidance before and throughout the summer. I would also like to thank Aveek Basu for helping me to get started with cups and cups-filters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment