[sane-devel] Problem with setting tl_x, tl_y, br_x and br_y with Fujitsu fi-4120c

Henning Meier-Geinitz henning@meier-geinitz.de
Sun, 27 Apr 2003 18:44:20 +0200


Hi,

On Sun, Apr 27, 2003 at 10:38:02AM -0500, Peter Chen wrote:
> I tried to set fi-4120c to tl_x=50, tl_y=0, br_x=150, br_y=100 with the

tl_x=50. 50 what? I mean, which unit? It's similar to your last
problem with the string list for "ADF". Not all options are
SANE_TYPE_INT. In this case it's a SANE_Fixed option so you must use a
fixed-point type. See the SANE-Standard for details.

>       // Set the resolutions to 300 dpi
>       if ( strcmp(opt->name, SANE_NAME_SCAN_X_RESOLUTION) == 0)
>       {
>           value = 300;
>           status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
> &value, &info);
>       }

That works, because the reolution option is an int option.

From fujitsu.c:
  opt = scanner->opt + OPT_X_RES;
  opt->name = SANE_NAME_SCAN_X_RESOLUTION;
  opt->title = SANE_TITLE_SCAN_X_RESOLUTION;
  opt->desc = SANE_DESC_SCAN_X_RESOLUTION;
  opt->type = SANE_TYPE_INT;

>       if ( strcmp(opt->name, SANE_NAME_SCAN_MODE) == 0)
>       {
>           str = "gray";
>           valuep = (void *)str;
>           status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
> valuep, &info);
>       }

By the way, it's "Gray", not "gray". The backends (or specifically
sanei_constrain_value.c) are intelligent and check for wrong
capitalization but better be exact.

 
>       // Set tl_x to 50
>       if ( strcmp(opt->name, SANE_NAME_SCAN_TL_X) == 0)
>       {
>           value = 100;
>           valuep = (void *)&value;

Let's have a look at the fujitsu source code:
  opt = scanner->opt + OPT_TL_X;
  opt->name = SANE_NAME_SCAN_TL_X;
  opt->title = SANE_TITLE_SCAN_TL_X;
  opt->desc = SANE_DESC_SCAN_TL_X;
  opt->type = SANE_TYPE_FIXED;

So it's fixed, not int. So use value = SANE_FIX(100.0).

> Before I added these codes, everything worked just fine,

That's because the default settings for the geometry was used.

> but after I added
> these codes, although the status codes returned from these
> sane_control_option are all SANE_STATUS_GOOD, sane_start() could not funtion
> correctly, the scanner just pulled the document in a little bit and then
> stopped, the status code returned was SANE_STATUS_INVAL. I declared value as
> SANE_WORD and valuep as (void *),
> 
> Am I doing something wrong?

Basically, you just set the geometry to 0, 0, 0, 0. So I guess nothing
was scanned. Maybe the backend should have a test for this in
sane_start(). Well, maybe it has and that's why you got the error.

If you set tl_x to 100 that means 100/(2^16) = 0.0015 mm. Well, that's
not much to scan :-)

Bye,
  Henning