|
From: Stephan M. <Ste...@ia...> - 2007-06-06 14:44:03
|
Check the 'ep' parameter. This parameter must be the
full endpoint address including the direction bit (bit7).
Stephan
> I just checked the return value of the usb_interrupt_read () call - it's
> always -22.
>
> Dave
>
> > -----Original Message-----
> > From: lib...@li...
> > [mailto:lib...@li...] On
> > Behalf Of Dave Higton
> > Sent: 2007 June 06 15:20
> > To: lib...@li...
> > Subject: Re: [Libusb-win32-devel] Help, please
> >
> > 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...
> > > [mailto:lib...@li...] On
> > > Behalf Of Stephan Meyer
> > > Sent: 2007 June 06 14:05
> > > To: lib...@li...
> > > Subject: Re: [Libusb-win32-devel] Help, please
> > >
> > > Try to replace:
> > >
> > > uci = usb_claim_interface (udev, 0);
> > >
> > > with
> > >
> > > usb_set_configuation(udev, 1);
> > > uci = usb_claim_interface (udev, 0);
> > >
> > > It should work then.
> > >
> > >
> > > Stephan
> > >
> > >
> > >
> > >
> > > > Help, please. I've started writing a programme to use
> > > libusb-win32, but
> > > > I'm getting an error right at the start.
> > > >
> > > > First, some background. I've used libusb under Linux
> > > (Fedora Core 5)
> > > > successfully, to write driver functions for the first USB
> > > device that I
> > > > wrote firmware for. That device works entirely happily
> > > 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
> > > device also
> > > > works entirely happily under RISC OS. I thought I'd try
> > > this Windows
> > > > thing, but I'm having no success.
> > > >
> > > > The entire programme is here:
> > > >
> > > > // Can I get this system to do what I want?
> > > > #include <usb.h>
> > > > #include <stdio.h>
> > > >
> > > > #define VENDOR_ID_NICE 0x16A8
> > > > #define PRODUCT_ID_CONTACT_CLOSURE 0x0004
> > > >
> > > > int init (void)
> > > > {
> > > > //int usb_busses;
> > > > struct usb_bus* bus;
> > > > struct usb_device* dev;
> > > > usb_dev_handle *udev;
> > > > int retval = -1;
> > > > int uci;
> > > > int done = 0;
> > > >
> > > > printf ("Hello\n");
> > > >
> > > > usb_init ();
> > > > usb_find_busses ();
> > > > usb_find_devices ();
> > > > for (bus = usb_get_busses (); bus; bus = bus->next)
> > > > {
> > > > for (dev = bus->devices; dev && (done == 0); dev =
> > > > dev->next)
> > > > {
> > > > udev = usb_open (dev);
> > > > printf ("udev = %p\n", udev);
> > > > if ((dev->descriptor.idVendor == VENDOR_ID_NICE)
> > > > && (dev->descriptor.idProduct ==
> > > > PRODUCT_ID_CONTACT_CLOSURE))
> > > > {
> > > > printf ("Found it!\n");
> > > > uci = usb_claim_interface (udev, 0);
> > > > printf ("Return value from
> > > > usb_claim_interface: %d\n", uci);
> > > > retval = uci;
> > > > done = 1;
> > > > }
> > > > else
> > > > {
> > > > printf ("Not ours, VID = %04X, PID =
> > > > %04X\n", dev->descriptor.idVendor, dev->descriptor.idProduct);
> > > > usb_close (udev);
> > > > printf ("Closed: %p\n", udev);
> > > > }
> > > > }
> > > > }
> > > > return retval;
> > > > }
> > > >
> > > > int main (void)
> > > > {
> > > > int init_result;
> > > >
> > > > init_result = init ();
> > > > if (init_result == 0)
> > > > {
> > > > printf ("Starting...\n");
> > > > }
> > > > else
> > > > {
> > > > printf ("Failed\n");
> > > > }
> > > > }
> > > >
> > > > When I run it, I get a couple of "Not ours, VID = " etc.
> > > messages for
> > > > other USB items I have, followed by "Found it!" But then
> > > "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.
> > > My device
> > > > only has interface 0. It's a very simple device, with a
> > > vendor-specific
> > > > protocol, specified at interface level.
> > > >
> > > > Can anyone see what I'm doing wrong, please?
> > > >
> > > > libusb-win32 downloaded from the main libusb-win32 site
> > > this week. No
> > > > previous copy on this computer. Windows XP.
> > > >
> > > > Dave
> > > >
> > > >
> > > >
> > > **************************************************************
> > > **************************************************************
> > > **************************************************************
> > > *******************************************************
> > > >
> > > > NICE CTI Systems UK Limited ("NICE") is registered in
> > England under
> > > > company number, 3403044. The registered office of NICE is at
> > > > Tollbar Way, Hedge End, Southampton, Hampshire SO30 2ZP.
> > > >
> > > > Confidentiality: This communication and any attachments
> > are intended
> > > > for the above-named persons only and may be confidential and/or
> > > > 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
> > > > show it to anyone; please delete/destroy and inform the
> > sender by e-
> > > > mail immediately.
> > > >
> > > > Monitoring: NICE may monitor incoming and outgoing e-mails.
> > > >
> > > > Viruses: Although we have taken steps toward ensuring
> > that this e-
> > > > mail and attachments are free from any virus, we advise that in
> > > > keeping with good computing practice the recipient should ensure
> > > > they are actually virus free.
> > > >
> > > >
> > > **************************************************************
> > > **************************************************************
> > > **************************************************************
> > > **********************************************************
> > > >
> > > >
> > > >
> > > >
> > > >
> > > --------------------------------------------------------------
> > > -----------
> > > > 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
> > >
> > >
> > > --------------------------------------------------------------
> > > -----------
> > > 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
> > >
> >
> > --------------------------------------------------------------
> > -----------
> > 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
> >
>
>
-------------------------------------------------------------------------
> 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
|