[sane-devel] General question on C programming

abel deuring adeuring at gmx.net
Wed Oct 17 17:01:20 UTC 2007


On 17.10.2007 18:18, jazz_johnson at verizon.net wrote:

> THANKS. I somehow missed this point. I now see ibm.c includes ibm-scsi.c
> which explains how ibm.c sees the static funcctions in ibm-scsi.c
> 
> I hope to soon have a driver supporting essential IS450 scanning functions.
> I've written structs and functions for most IS450 commands/data, but have not 
> yet added non-essential options to the SANE_OPTION_DESCRIPTORS array.
> 
> Does the SANE API have a means of getting user input. My IS450DE has an 
> Endorser which can print a (19 char max) string on each sheet fed through the 
> ADF. So to implement this feature I need a way to let the User type in their 
> stamp, although I could read the stamp string from the configuration file.

You can use the string option.

> 
> Also, I noticed that the API has a BUTTON type, but haven't seen any examples.
> The IS450 has a self-diagnostics, optical-adjustment and scanner maintenance 
> data features which I supposed I could use the BUTTON to implement, e.g. when 
> button is pressed run_self_diagnostics or run_optical_adjustment.

Yes, a button option is intended for such purposes. You can use a
read-only string option to display the test results.

> 
> The IS450 also comes with an option IPU (Image Processing Unit) which mine 
> doesn't have. Basically, this is some firmware for image processing. I've 
> written structs for the IPU command/data, but haven't added it yet to 
> OPTIONS. Is there any advantage in having the scanner do image processing 
> instead of just returning raw scan data to the front end for further 
> processing? CPUs are a lot faster now than 10 years ago.
> In the same vein, the IS450 allows user definable dither patterns and gamma 
> tables to be uploaded to the scanner for use with the IPU firmware. So to add 
> such an OPTION would require some means of letting the user browse for their 
> custom dither patterns and gamma tables (which I've also deferred 
> implementing).

A "string constraint string list" (usually displayed as a drop-down list
by GUIs) allows the selection of such options.

> 
> Also the IS450 allow setting its padding type (default: trucate to byte 
> boundary), bitorder, as well as byte order (1st to last  or last -> 1st) for 
> its image data and also  packing of 4bits gray data. I suppose there is no 
> reason for the backend to play with these things.

Well, just use the settings which make the transformation into the
output format most convenient :) I am not sure, if it makes sense to
select the byte order for the scanner depending on the byte order of the
 the machine.

> 
> 
> The IS450 also supports up to 2 window identifiers in its window_data 
> structure, but the IS420 only supports 1:
> /* HS2P_WINDOW_DATA_FORMAT       */
> struct hs2p_window_data {           
>    SANE_Byte window_id;           
>    SANE_Byte auto_bit; 
>    /* {(ulx,uly), (brx,bry)} main scan region */     
>    SANE_Byte xres[2];              
>    SANE_Byte yres[2];            
>    SANE_Byte ulx[4];                
>    SANE_Byte uly[4];                
>    SANE_Byte width[4];
>    .
>    .
>    .
>    /* sub scan regions {(ulx,uly),(brx,bry)}[i] */
>    struct window_section sec[8];
> }


Is the IS450 a duplex scanner? In this case the first window would
probably describe the front side scan area, and the second window the
backside scan area. If my guess is right, use the same settings for both
windows.

> I don't understand what this is for. The other backends just  use one w_id.
> Also when the IPU is installed this scanner allows scanning sub sections of a 
> document (up to 4 for the IS450 and 6 for the IS420). So if you had a 
> document with mixed text, photos, etc., you could scan the photo in halftone 
> and the text in lineart, etc. I've not yet implented an OPTION to allow 
> defining more than one { (ulx,uly), (brx,bry) } scanning region. Would xsane 
> work with such a feature? Again, since my IS450 lacks an IPU this feature 
> isn't available and I haven't yet implemented it.

I'm afraid that most frontends will have problems to deal with multiple
windows :)

Abel



More information about the sane-devel mailing list