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

Peter Chen peterchenn@hotmail.com
Sun, 27 Apr 2003 10:38:02 -0500


Hi,

I tried to set fi-4120c to tl_x=50, tl_y=0, br_x=150, br_y=100 with the
following codes:

        status = sane_init(version_code, NULL);

        // Get all the deivces and list them in Select Scanner Form//
        status = sane_get_devices(&device_list, true);
        status = sane_open("fujitsu:/dev/usb/scanner0", &device );

sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0);
  for (i = 0; i < num_dev_options; ++i)
    {
      opt = sane_get_option_descriptor (device, i);

      // 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);
      }
      if ( strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION) == 0)
      {
          value = 300;
          status = sane_control_option(device, i, SANE_ACTION_SET_VALUE,
&value, &info);
      }
      // Set the scan mode to GrayScale
      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);
      }
      // Set the source to ADF
      if ( strcmp(opt->name, SANE_NAME_SCAN_SOURCE) == 0)
      {
          str = "ADF";
          valuep = (void *)str;
          status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
valuep, &info);
      }

///////////////////////////Codes added to set tl_x, tl_y, br_x and br_y
///////////////////////////////////////////
      // Set tl_x to 50
      if ( strcmp(opt->name, SANE_NAME_SCAN_TL_X) == 0)
      {
          value = 100;
          valuep = (void *)&value;
          status = sane_control_option(device, i, SANE_ACTION_SET_VALUE,
valuep, &info);
      }
      // Set tl_y to 0
      if ( strcmp(opt->name, SANE_NAME_SCAN_TL_Y) == 0)
      {
          value = 0;
          valuep = (void *)&value;
          status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
valuep, &info);
      }
      // Set br_x to 150
      if ( strcmp(opt->name, SANE_NAME_SCAN_BR_X) == 0)
      {
          value = 150;
          valuep = (void *)&value;
          status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
valuep, &info);
      }
      // Set br_y to 100
      if ( strcmp(opt->name, SANE_NAME_SCAN_BR_Y) == 0)
      {
          value = 100;
          valuep = (void *)&value;
          status = sane_control_option (device, i, SANE_ACTION_SET_VALUE,
valuep, &info);
      }
////////////////////////////////////////////////////////////
    }

  do
    {
      status = sane_start (device);

-------------------
Before I added these codes, everything worked just fine, 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?

Thanks,

Peter