Logo Search packages:      
Sourcecode: scanbuttond version File versions  Download package

int scanbtnd_open ( scanner_t *  scanner  ) 

Opens the given scanner device. This function must be called before using scanbtnd_get_button(). After calling this function, it is usually not possible for another process to access the scanner until scanbtnd_close() is called.

scanner the scanner device to be opened
0 if successful, <0 otherwise
Return values:
-ENODEV if the device is no longer present (or the device list has to be refreshed). In this case, call scanbtnd_rescan() and try again.
-EBUSY if the device is currently used by another process.
-EINVAL if the device is already open
-ENOSYS if there is no connection method to communicate with the device

Definition at line 187 of file epson.c.

      int result = -ENOSYS;
      if (scanner->is_open)
            return -EINVAL;
      switch (scanner->connection) {
            case CONNECTION_LIBUSB:
                  // if devices have been added/removed, return -ENODEV to
                  // make scanbuttond update its device list
                  if (libusb_get_changed_device_count() != 0)
                        return -ENODEV;
                  result = libusb_open((libusb_device_t*)scanner->internal_dev_ptr);
      if (result == 0)
            scanner->is_open = 1;
      return result;

Generated by  Doxygen 1.6.0   Back to index