[sane-devel] General question on C programming

jazz_johnson at verizon.net jazz_johnson at verizon.net
Wed Oct 17 16:18:37 UTC 2007


On Wednesday 17 October 2007, Julien BLACHE wrote:
> jazz_johnson at verizon.net wrote:
>
> Hi,
>
> > So, is the static keyword necessary to prevent backend drivers from
> > interfering with each other, or is the keyword unnecessary?
>
> Every function in a backend that isn't part of the SANE API described
> in the SANE standard must be declared static. Put another way, only
> the SANE API functions must be exported.
>
> This is to avoid any clash with an application that would link
> statically against a backend. (use ./configure --enable-static; make;
> make libcheck to check that your backend is OK)
>
> Also, the SANE build system doesn't really support having several
> source files for a backend. You'll see that most multi-file backends
> in fact #include the other .c files.
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.

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.

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).

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.


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];
}

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.
>
> JB.







More information about the sane-devel mailing list