[sane-devel] On using the files
m. allan noah
anoah at pfeiffer.edu
Thu Dec 11 14:36:31 GMT 2003
On Thu, 11 Dec 2003, Jason Anderson wrote:
> I've been trying to make a simple app which opens up the proper file (/dev/usb/scanner0), and return a message saying it is opened. But I don't think I have it right.
> Since SANE uses libusb, I've been using those functions, in part the usb_open() function. I've used the "for" loop to go through the various devices in the usb_devices structure of libusb to try and open it. Can anyone help me with this little problem?
>
your question is really vague, but is sounds like you are asking for a bit
of code to open a scanner device file so you can send your own packets to
it?
i would not use the kernel usb scanner module (rmmod scanner) i would
instead use libusb and the usbdevfs instead. see the attached bit of code.
you will have to change the vendor and device ids.
allan
--
"so don't tell us it can't be done, putting down what you don't know.
money isn't our god, integrity will free our souls" - Max Cavalera
-------------- next part --------------
usb_dev_handle *locate_fu(void)
{
unsigned char located = 0;
struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *device_handle = 0;
int open_status = 0;
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if (dev->descriptor.idVendor == 0x04c5)
{
located++;
device_handle = usb_open(dev);
printf("FU Device Found @ Address %s \n", dev->filename);
printf("FU Vendor ID 0x0%x\n",dev->descriptor.idVendor);
printf("FU Product ID 0x0%x\n",dev->descriptor.idProduct);
}
else printf("** usb device %s found **\n", dev->filename);
}
}
if (device_handle==0)
return (0);
open_status = usb_set_configuration(device_handle,1);
printf("conf_stat=%d\n",open_status);
open_status = usb_claim_interface(device_handle,0);
printf("claim_stat=%d\n",open_status);
//open_status = usb_set_altinterface(device_handle,0);
//printf("alt_stat=%d\n",open_status);
return (device_handle);
}
More information about the sane-devel
mailing list