[sane-devel] Problem with setting Fujitsu fi-4120c to Grayscale

Peter Chen peterchenn at hotmail.com
Thu Apr 24 21:43:38 BST 2003


Hi all,

I tried to set fi-4120c to Grayscale. I used the following code flow:

        status = sane_init(version_code, NULL);
        status = sane_get_devices(&device_list, true);
        ...
        sane_exit();

        status = sane_init(version_code, NULL);
        status = sane_open("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;
          sane_control_option (device, i, SANE_ACTION_SET_VALUE, &value,
&info);
      }
      if ( strcmp(opt->name, SANE_NAME_SCAN_Y_RESOLUTION) == 0)
      {
          value = 300;
          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)
      {
          value = 3;
          sane_control_option (device, i, SANE_ACTION_SET_VALUE, &value,
&info);
      }
    }

The first time I ran it, it successfully set fi-4120c to GrayScale (when I
debug, I could see that), but then later when I did that, it always returned
SANE_STATUS_INVAL, even after I rebooted my linux box and fi-4120c. I could
set the resolutions successfully. What did I do wrong?

Thanks,

Peter



More information about the sane-devel mailing list