|
From: Dave H. <DAV...@ni...> - 2007-06-06 14:20:26
|
Wow, what a rapid reply! Thanks. I tried your fix, and it has got me
one step further.
(I note that usb_set_configuration (udev, 0) gives the same error -22 as
not calling it. The only configuration I have is numbered 0; is this
OK?)
Setting configuration to 1 makes the call return 0, so it looks like
it's working, but it fails at the next step. In the main loop, I do:
printf ("Starting...\n");
while (1)
{
if (usb_interrupt_read (contact_closure_usb_dev,
contact_closure_usb_input_endpoint,
cBuf,
4,
0) > 0)
{
printf ("Got some\n");
}
}
but the printf statement is never executed, although I am doing things
that should cause the interface to send messages - which are 4 bytes
each.
Any more ideas?
Dave
> -----Original Message-----
> From: lib...@li...=20
> [mailto:lib...@li...] On=20
> Behalf Of Stephan Meyer
> Sent: 2007 June 06 14:05
> To: lib...@li...
> Subject: Re: [Libusb-win32-devel] Help, please
>=20
> Try to replace:
>=20
> uci =3D usb_claim_interface (udev, 0);
>=20
> with
>=20
> usb_set_configuation(udev, 1);
> uci =3D usb_claim_interface (udev, 0);
>=20
> It should work then.
>=20
>=20
> Stephan
>=20
>=20
>=20
>=20
> > Help, please. I've started writing a programme to use=20
> libusb-win32, but
> > I'm getting an error right at the start.
> >=20
> > First, some background. I've used libusb under Linux=20
> (Fedora Core 5)
> > successfully, to write driver functions for the first USB=20
> device that I
> > wrote firmware for. That device works entirely happily=20
> under FC5 and
> > under RISC O (yes, the Acorn/Pace/Castle one). I have now written
> > firmware for a second device. Perhaps unsurprisingly, this device's
> > firmware is very heavily based on the previous one. This=20
> device also
> > works entirely happily under RISC OS. I thought I'd try=20
> this Windows
> > thing, but I'm having no success.
> >=20
> > The entire programme is here:
> >=20
> > // Can I get this system to do what I want?
> > #include <usb.h>
> > #include <stdio.h>
> >=20
> > #define VENDOR_ID_NICE 0x16A8
> > #define PRODUCT_ID_CONTACT_CLOSURE 0x0004
> >=20
> > int init (void)
> > {
> > //int usb_busses;
> > struct usb_bus* bus;
> > struct usb_device* dev;
> > usb_dev_handle *udev;
> > int retval =3D -1;
> > int uci;
> > int done =3D 0;
> >=20
> > printf ("Hello\n");
> >=20
> > usb_init ();
> > usb_find_busses ();
> > usb_find_devices ();
> > for (bus =3D usb_get_busses (); bus; bus =3D bus->next)
> > {
> > for (dev =3D bus->devices; dev && (done =3D=3D 0); dev =3D
> > dev->next)
> > {
> > udev =3D usb_open (dev);
> > printf ("udev =3D %p\n", udev);
> > if ((dev->descriptor.idVendor =3D=3D VENDOR_ID_NICE)
> > && (dev->descriptor.idProduct =3D=3D
> > PRODUCT_ID_CONTACT_CLOSURE))
> > {
> > printf ("Found it!\n");
> > uci =3D usb_claim_interface (udev, 0);
> > printf ("Return value from
> > usb_claim_interface: %d\n", uci);
> > retval =3D uci;
> > done =3D 1;
> > }
> > else
> > {
> > printf ("Not ours, VID =3D %04X, PID =3D
> > %04X\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
> > usb_close (udev);
> > printf ("Closed: %p\n", udev);
> > }
> > }
> > }
> > return retval;
> > }
> >=20
> > int main (void)
> > {
> > int init_result;
> >=20
> > init_result =3D init ();
> > if (init_result =3D=3D 0)
> > {
> > printf ("Starting...\n");
> > }
> > else
> > {
> > printf ("Failed\n");
> > }
> > }
> >=20
> > When I run it, I get a couple of "Not ours, VID =3D " etc.=20
> messages for
> > other USB items I have, followed by "Found it!" But then=20
> "Return value
> > from usb_claim_interface: -22" which I don't understand. I think it
> > indicates an illegal parameter. udev must be OK, I assume.=20
> My device
> > only has interface 0. It's a very simple device, with a=20
> vendor-specific
> > protocol, specified at interface level.
> >=20
> > Can anyone see what I'm doing wrong, please?
> >=20
> > libusb-win32 downloaded from the main libusb-win32 site=20
> this week. No
> > previous copy on this computer. Windows XP.
> >=20
> > Dave
> >=20
> >=20
> >=20
> **************************************************************
> **************************************************************
> **************************************************************
> *******************************************************
> >=20
> > NICE CTI Systems UK Limited ("NICE") is registered in England under=20
> > company number, 3403044. The registered office of NICE is at=20
> > Tollbar Way, Hedge End, Southampton, Hampshire SO30 2ZP.
> >=20
> > Confidentiality: This communication and any attachments are intended
> > for the above-named persons only and may be confidential and/or=20
> > legally privileged. Any opinions expressed in this communication are
> > not necessarily those of NICE. If this communication has come to you
> > in error you must take no action based on it, nor must you copy or=20
> > show it to anyone; please delete/destroy and inform the sender by e-
> > mail immediately.
> >=20
> > Monitoring: NICE may monitor incoming and outgoing e-mails.
> >=20
> > Viruses: Although we have taken steps toward ensuring that this e-
> > mail and attachments are free from any virus, we advise that in=20
> > keeping with good computing practice the recipient should ensure=20
> > they are actually virus free.
> >=20
> >=20
> **************************************************************
> **************************************************************
> **************************************************************
> **********************************************************
> >=20
> >=20
> >=20
> >=20
> >=20
> --------------------------------------------------------------
> -----------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Libusb-win32-devel mailing list
> > Lib...@li...
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>=20
>=20
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>=20
|