Hi all,
I am trying my hand at writing USB-aware apps and started with an
atempt to work with my USB webcam. I have failed to write to the
OV511+ bridge's regisers - I just can't find out what I am missing or
doing wrong. This is the code I have so far:
#include <usb.h>
#include <usbi.h>
#include <linux.h>
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#define OMNIVN 0x05a9
#define OV511P 0xa511
int main()
{
struct usb_bus
*bus,
*busses;
struct usb_device *dev;
struct usb_dev_handle *dev_handle;
int
interface,
done = FALSE;
unsigned char data[4];
/* Initialize */
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
/* Find an OV511+ based camera */
for (bus = busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if( (dev->descriptor.idVendor == OMNIVN) &&
(dev->descriptor.idProduct == OV511P) )
{
printf( "xcam: Found OV511+ camera at /proc/bus/usb/%s/%s\n",
bus->dirname, dev->filename );
done = TRUE;
break;
}
} /* for (dev = bus->devices; dev; dev = dev->next) */
if( done ) break;
} /* for (bus = busses; bus; bus = bus->next) */
if( !done )
{
puts( "xcam: No OV511+ camera found" );
exit(-1);
}
/* Open camera device */
dev_handle = usb_open( dev );
if( dev_handle == NULL )
{
perror( "xcam: Open camera device" );
printf( "xcam: USB Error: %s\n", usb_strerror() );
exit(-1);
}
/* Claim an interface */
interface = 0;
if( usb_claim_interface(dev_handle, interface) < 0 )
{
perror( "xcam: Claim interface" );
printf( "xcam: USB Error: %s\n", usb_strerror() );
exit(-1);
}
/* Set active config */
if( usb_set_configuration(dev_handle, 1) < 0 )
{
perror( "xcam: Set Configuration" );
printf( "xcam: USB Error: %s\n", usb_strerror() );
exit(-1);
}
/* Send control message (LED on) */
puts( "\nxcam: Sending control message" );
data[0] = 0x01; /* LED on */
if( usb_control_msg(dev_handle,
0x40, /* Vendor command to device */
2, /* Register I/O */
0,
0x55, /* LED control reg */
data, 1, 100) < 0 )
{
perror( "xcam: Send Control Message" );
printf( "xcam: USB Error: %s\n", usb_strerror() );
exit(-1);
}
printf( "xcam: USB Error: %s\n", usb_strerror() );
return( 0 );
} /* main.c */
Basically I am trying to switch the camera's LED on-off, as the most
visible sign of a successful write to a register, but no joy. Also
tried usb-robot-slave to send the command, but still failed.
My thanks in advance for any help on this!
--
Regards
Neoklis Ham Radio callsign: 5B4AZ QTH Loc: KM64MR
-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel