SANE standard / get_select_fd / sane_read

From: Christian Nassau (nassau@math.uni-frankfurt.de)
Date: Wed Jan 10 2001 - 02:18:16 PST

  • Next message: Christian Nassau: "sanei_scsi_cmd / snapscan / Prisa640S"

    Currently the SANE standard (1.0.2, Nov 14 2000) makes the
    following specification concerning sane_get_select_fd():

      This function is used to obtain a [...] file descriptor [...]
      that is readable if and only if image data is available

    and adds
      
      (i.e., when a call to sane_read() will return at least
      one byte of data).

    I wonder if we can relax this a little bit, and allow the next
    call to sane_read() to return 0 bytes, as long as it performs
    some useful/necessary operations (internal to the backend).

    To be more concrete: I wonder if we could make the following
    setup legal:

      - the file descriptor handed over by the backend signals
        readable if raw data from the scanner is available to
             the backend, but

      - the backend does some postprocessing and would rather
        keep some of the data until more data is available

        (take chroma correction, for example, where the backend
        doesn't want to send some lines at the beginning
        which have incomplete color components. The initial
             call to sane_read() might just put some lines into an
        internal buffer, which will be (partially) transferred
             when sane_read() is called the next time)

    Basically, this is a question about the specification of
    sane_read(). There seem to be two competing ideas of what a
    successful call to sane_read() is:

      - The last line on page 29, allows sane_read() to transfer
        0 bytes but still return SANE_STATUS_GOOD

      - On page 30 (blocking I/O mode) sane_read() has to transfer
        at least one byte if it wants to return SANE_STATUS_GOOD

    Wouldn't it be better to allow a backend to transfer 0 bytes,
    as long as it considers this a success for some internal reasons?

    Actually, I've got another question about sane_read():
     
    It might be convenient for a backend to internally store only
    complete lines of image data (not fractions of a line). So:

     - Does it have to be legal (for the frontend) to request
       less than bytes_per_line bytes?

    This could easily lead to a deadlock if the backend transfers
    0 bytes successfully in such a case. (Which it may do in
    non-blocking mode.)

    (Well, requesting 0 bytes explicitly could still be legal.)

    ---------
    Christian Nassau

    e-mail: nassau@math.uni-frankfurt.de
    home-page: http://www.math.uni-frankfurt.de/~nassau

    Fachbereich Mathematik (12)
    AG 8.1, Zi.814
    Johann Wolfgang Goethe-Universit"at
    Robert-Mayer-Str. 6-10
    D-60054 Frankfurt/M
    --- Germany ---

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Wed Jan 10 2001 - 01:55:27 PST