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.

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

Definition at line 172 of file artec_eplus48u.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);
                  break;
      }
      if (result == 0)
            scanner->is_open = 1;
      return result;
}

Generated by  Doxygen 1.6.0   Back to index