| 
      
      
      From: Stephan M. <ste...@we...> - 2006-06-19 16:44:39
       | 
| See http://sourceforge.net/mailarchive/message.php?msg_id=10083829 > I got the simple bulk write/read to work. However, I would like to have a > thread waiting on the read all the time and process the read data > independent of the write. How would I implement async read using the libusb? > anyone has an example? > > thanks > Andrew > > > > _______________________________________________ > Libusb-win32-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel ______________________________________________________________________ XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130 | 
| 
      
      
      From: Stephan M. <ste...@we...> - 2006-06-19 20:50:15
       | 
| usb_reap_async() returns the number of bytes read or a value of <0 if an error occured. > usb_reap_async(context0, 5000);is waiting for the OV event. How would I find > out how many bytes were actually read? OV read does not need to fill the > number that was requested. -Andrew----- Original Message ----- > From: "Stephan Meyer" <ste...@we...> > To: <lib...@li...>; "Andrew Xiang" > <xi...@gr...> > Sent: Monday, June 19, 2006 12:44 PM > Subject: Re: [Libusb-win32-devel] win-libusb async read > > > > > > See > > > > http://sourceforge.net/mailarchive/message.php?msg_id=10083829 > > > > > > > > > I got the simple bulk write/read to work. However, I would like to have > a > > > thread waiting on the read all the time and process the read data > > > independent of the write. How would I implement async read using the > libusb? > > > anyone has an example? > > > > > > thanks > > > Andrew > > > > > > > > > > > > _______________________________________________ > > > Libusb-win32-devel mailing list > > > Lib...@li... > > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > > > > > > ______________________________________________________________________ > > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130 > > > > > > > > _______________________________________________ > > Libusb-win32-devel mailing list > > Lib...@li... > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > > > > > > _______________________________________________ > Libusb-win32-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel _____________________________________________________________________ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! http://smartsurfer.web.de/?mc=100071&distributionid=000000000071 | 
| 
      
      
      From: Stephan M. <ste...@we...> - 2006-06-19 20:54:03
       | 
| You are right. This function had a small bug that I fixed some weeks ago. The new version is in already the CVS. See http://libusb-win32.cvs.sourceforge.net/libusb-win32/libusb/src/windows.c?revision=1.44&view=markup > Stephan, > > in usb_submit_async > > if(!DeviceIoControl(c->dev->impl_info, > c->control_code, > &c->req, sizeof(libusb_request), > c->bytes, > c->size, &ret, &c->ol)) > { > if(GetLastError() != ERROR_IO_PENDING) > { > usb_error("usb_submit_async: submitting request failed, " > "win error: %s", usb_win_error_to_string()); > return -usb_win_error_to_errno(); > } > } > > return ret; > > > > ret has the bytes_read. however, the value got returned before the value is > updated. I think usb_submit_async should take a parameter in as a > &bytes_read. > > -Andrew > > > ----- Original Message ----- > From: "Stephan Meyer" <ste...@we...> > To: <lib...@li...>; "Andrew Xiang" > <xi...@gr...> > Sent: Monday, June 19, 2006 12:44 PM > Subject: Re: [Libusb-win32-devel] win-libusb async read > > > > > > See > > > > http://sourceforge.net/mailarchive/message.php?msg_id=10083829 > > > > > > > > > I got the simple bulk write/read to work. However, I would like to have > a > > > thread waiting on the read all the time and process the read data > > > independent of the write. How would I implement async read using the > libusb? > > > anyone has an example? > > > > > > thanks > > > Andrew > > > > > > > > > > > > _______________________________________________ > > > Libusb-win32-devel mailing list > > > Lib...@li... > > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > > > > > > ______________________________________________________________________ > > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130 > > > > > > > > _______________________________________________ > > Libusb-win32-devel mailing list > > Lib...@li... > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > > > > > > _______________________________________________ > Libusb-win32-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel _____________________________________________________________________ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! http://smartsurfer.web.de/?mc=100071&distributionid=000000000071 | 
| 
      
      
      From: Andrew X. <xi...@gr...> - 2006-06-21 05:26:12
       | 
| Hi, Stephan,
I am doing a loopback ping-pong between the host and the device. I get 
some -5 error after only a short while.
test\Debug>test.exe
got it open
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
1291 bytes read back
-5 bytes read back
error: bulk write failed -116
error: bulk write failed -116
^C
// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <process.h>    /* _beginthread, _endthread */
#include <stddef.h>
#include <stdlib.h>
#include <conio.h>
#include "usb.h"
/* the device's vendor and product id */
#define MY_VID 0x03EB
#define MY_PID 0x6124
/* the device's endpoints */
#define EP_IN 0x82
#define EP_OUT 0x01
#define BUF_SIZE (64*20+11)
  usb_dev_handle *dev = NULL; /* the device handle */
  char tmp[BUF_SIZE];
  char tmp1[BUF_SIZE];
  void *context0 = NULL;
int bytesread;
usb_dev_handle *open_dev(void);
int end_thread=0;
void DeviceThread( void *dummy )
{
 while(end_thread==0)
 {
 usb_bulk_setup_async(dev, &context0, EP_IN);
   usb_submit_async(context0, tmp1, sizeof(tmp1));
 bytesread=usb_reap_async(context0, INFINITE);
 printf("%d bytes read back\n", bytesread);
 }
   _endthread();
}
usb_dev_handle *open_dev(void)
{
  struct usb_bus *bus;
  struct usb_device *dev;
  for(bus = usb_get_busses(); bus; bus = bus->next)
    {
      for(dev = bus->devices; dev; dev = dev->next)
        {
          if(dev->descriptor.idVendor == MY_VID
             && dev->descriptor.idProduct == MY_PID)
            {printf("got it open\n");
              return usb_open(dev);
            }
        }
    }
  return NULL;
}
int main(void)
{
  usb_init(); /* initialize the library */
  usb_find_busses(); /* find all busses */
  usb_find_devices(); /* find all connected devices */
  for(int i=0;i<BUF_SIZE;i++)
  {
   tmp[i]=i;
   tmp1[i]=0;
  }
  if(!(dev = open_dev()))
    {
      printf("error: device not found!\n");
      return 0;
    }
  if(usb_set_configuration(dev, 1) < 0)
    {
      printf("error: setting config 1 failed\n");
      usb_close(dev);
      return 0;
    }
  if(usb_claim_interface(dev, 0) < 0)
    {
      printf("error: claiming interface 0 failed\n");
      usb_close(dev);
      return 0;
    }
   _beginthread(DeviceThread, 0, NULL );
   for( i=0;i<100000;i++)
   {int wrote;
   wrote=usb_bulk_write(dev, EP_OUT, tmp, sizeof(tmp), 5000) ;
 if(wrote
     != sizeof(tmp))
    {
      printf("error: bulk write failed %d\n", wrote);
    }
  Sleep(1000);
   }
/*  if(usb_bulk_read(dev, EP_IN, tmp1, sizeof(tmp), 5000)
     != sizeof(tmp1))
    {
      printf("error: bulk read failed\n");
    }
*/
 Sleep(500);
 end_thread=1;
  usb_release_interface(dev, 0);
  usb_close(dev);
  bool test=true;
  for(i=0;i<bytesread;i++)
  {
   if(tmp[i]!=tmp1[i])
   {
    test=false;
    printf("mismatch\n");
    break;
   }
  }
  if(test)
   printf("received okay\n");
  return 0;
}
----- Original Message ----- 
From: "Stephan Meyer" <ste...@we...>
To: <lib...@li...>; "Andrew Xiang" 
<xi...@gr...>
Sent: Monday, June 19, 2006 4:53 PM
Subject: Re: [Libusb-win32-devel] win-libusb async read
>
> You are right. This function had a small bug that I fixed some
> weeks ago. The new version is in already the CVS.
>
> See
> http://libusb-win32.cvs.sourceforge.net/libusb-win32/libusb/src/windows.c?revision=1.44&view=markup
>
>
>
>> Stephan,
>>
>> in usb_submit_async
>>
>>    if(!DeviceIoControl(c->dev->impl_info,
>>                       c->control_code,
>>                       &c->req, sizeof(libusb_request),
>>                       c->bytes,
>>                       c->size, &ret, &c->ol))
>>     {
>>       if(GetLastError() != ERROR_IO_PENDING)
>>         {
>>           usb_error("usb_submit_async: submitting request failed, "
>>                     "win error: %s", usb_win_error_to_string());
>>            return -usb_win_error_to_errno();
>>         }
>>     }
>>
>>   return ret;
>>
>>
>>
>> ret has the bytes_read. however, the value got returned before the value 
>> is
>> updated. I think usb_submit_async should take a parameter in as a
>> &bytes_read.
>>
>> -Andrew
>>
>>
>> ----- Original Message ----- 
>> From: "Stephan Meyer" <ste...@we...>
>> To: <lib...@li...>; "Andrew Xiang"
>> <xi...@gr...>
>> Sent: Monday, June 19, 2006 12:44 PM
>> Subject: Re: [Libusb-win32-devel] win-libusb async read
>>
>>
>> >
>> > See
>> >
>> > http://sourceforge.net/mailarchive/message.php?msg_id=10083829
>> >
>> >
>> >
>> > > I got the simple bulk write/read to work. However, I would like to 
>> > > have
>> a
>> > > thread waiting on the read all the time and process the read data
>> > > independent of the write. How would I implement async read using the
>> libusb?
>> > > anyone has an example?
>> > >
>> > > thanks
>> > > Andrew
>> > >
>> > >
>> > >
>> > > _______________________________________________
>> > > Libusb-win32-devel mailing list
>> > > Lib...@li...
>> > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>> >
>> >
>> > ______________________________________________________________________
>> > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
>> > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130
>> >
>> >
>> >
>> > _______________________________________________
>> > Libusb-win32-devel mailing list
>> > Lib...@li...
>> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>> >
>>
>>
>>
>> _______________________________________________
>> Libusb-win32-devel mailing list
>> Lib...@li...
>> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
>
> _____________________________________________________________________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
>
>
>
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> 
 | 
| 
      
      
      From: Stephan M. <ste...@we...> - 2006-06-21 19:50:11
       | 
| 
> #define BUF_SIZE (64*20+11)
Can you always guarantee that the last packet your device
sends is 11 bytes or less? If not, then set  BUF_SIZE to a multiple
of the endpoint's buffer size. Otherwise your device might produce
'data overrun' errors (this may cause the -5 error you got).
>  while(end_thread==0)
>  {
>  usb_bulk_setup_async(dev, &context0, EP_IN);
>    usb_submit_async(context0, tmp1, sizeof(tmp1));
>  bytesread=usb_reap_async(context0, INFINITE);
>  printf("%d bytes read back\n", bytesread);
>  }
You forgot to free 'context', call usb_free_async().
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
 | 
| 
      
      
      From: Andrew X. <xi...@gr...> - 2006-06-21 20:18:01
       | 
| Where do  I find out the file that keep a list of error like -5? And how can
I enable the usberror output? I guess I have to have the DDK to recompile
it? I don't have  the DDK installed.
I cannot use multiple of 64, because there is the only way to detect end of
the packet. Each block is 64bytes, if the block is not 64 blocks, that means
it is the last block. This is the only way in the device I am using. Maybe I
am missing something.
I think I might have some hardware noise problem. Because I did not see  the
problem on another hardware.
-Andrew
----- Original Message ----- 
From: "Stephan Meyer" <ste...@we...>
To: <lib...@li...>; "Andrew Xiang"
<xi...@gr...>
Sent: Wednesday, June 21, 2006 3:49 PM
Subject: Re: [Libusb-win32-devel] win-libusb async read
>
> > #define BUF_SIZE (64*20+11)
>
> Can you always guarantee that the last packet your device
> sends is 11 bytes or less? If not, then set  BUF_SIZE to a multiple
> of the endpoint's buffer size. Otherwise your device might produce
> 'data overrun' errors (this may cause the -5 error you got).
>
> >  while(end_thread==0)
> >  {
> >  usb_bulk_setup_async(dev, &context0, EP_IN);
> >    usb_submit_async(context0, tmp1, sizeof(tmp1));
> >  bytesread=usb_reap_async(context0, INFINITE);
> >  printf("%d bytes read back\n", bytesread);
> >  }
>
> You forgot to free 'context', call usb_free_async().
> _____________________________________________________________________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
>
>
> All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> Fully trained technicians. The highest number of Red Hat certifications in
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
 | 
| 
      
      
      From: Mark B. <mb...@ze...> - 2006-06-22 01:26:26
       | 
| You can set an environment variable USB_DEBUG to 1 or 2 for debug 
messages. Also the C header file errno.h may give some clue as to what 
the error numbers mean.
Mark.
Andrew Xiang wrote:
>Where do  I find out the file that keep a list of error like -5? And how can
>I enable the usberror output? I guess I have to have the DDK to recompile
>it? I don't have  the DDK installed.
>
>I cannot use multiple of 64, because there is the only way to detect end of
>the packet. Each block is 64bytes, if the block is not 64 blocks, that means
>it is the last block. This is the only way in the device I am using. Maybe I
>am missing something.
>
>I think I might have some hardware noise problem. Because I did not see  the
>problem on another hardware.
>
>
>-Andrew
>
>
>----- Original Message ----- 
>From: "Stephan Meyer" <ste...@we...>
>To: <lib...@li...>; "Andrew Xiang"
><xi...@gr...>
>Sent: Wednesday, June 21, 2006 3:49 PM
>Subject: Re: [Libusb-win32-devel] win-libusb async read
>
>
>  
>
>>>#define BUF_SIZE (64*20+11)
>>>      
>>>
>>Can you always guarantee that the last packet your device
>>sends is 11 bytes or less? If not, then set  BUF_SIZE to a multiple
>>of the endpoint's buffer size. Otherwise your device might produce
>>'data overrun' errors (this may cause the -5 error you got).
>>
>>    
>>
>>> while(end_thread==0)
>>> {
>>> usb_bulk_setup_async(dev, &context0, EP_IN);
>>>   usb_submit_async(context0, tmp1, sizeof(tmp1));
>>> bytesread=usb_reap_async(context0, INFINITE);
>>> printf("%d bytes read back\n", bytesread);
>>> }
>>>      
>>>
>>You forgot to free 'context', call usb_free_async().
>>_____________________________________________________________________
>>Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
>>http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
>>
>>
>>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
>>Fully trained technicians. The highest number of Red Hat certifications in
>>the hosting industry. Fanatical Support. Click to learn more
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
>>_______________________________________________
>>Libusb-win32-devel mailing list
>>Lib...@li...
>>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>
>>    
>>
>
>
>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
>Fully trained technicians. The highest number of Red Hat certifications in
>the hosting industry. Fanatical Support. Click to learn more
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
>_______________________________________________
>Libusb-win32-devel mailing list
>Lib...@li...
>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>  
>
 | 
| 
      
      
      From: Andrew X. <xi...@gr...> - 2006-06-22 13:42:46
       | 
| Here is the errno.h,  I don't see -5.
-Andrew
#ifndef __ERROR_H__
#define __ERROR_H__
/* Connection timed out */
#define ETIMEDOUT 116
typedef enum {
  USB_ERROR_TYPE_NONE = 0,
  USB_ERROR_TYPE_STRING,
  USB_ERROR_TYPE_ERRNO,
} usb_error_type_t;
void usb_error(char *format, ...);
void usb_message(char *format, ...);
const char *usb_win_error_to_string(void);
int usb_win_error_to_errno(void);
#endif /* _ERROR_H_ */
----- Original Message ----- 
From: "Mark Bourne" <mb...@ze...>
To: "Andrew Xiang" <xi...@gr...>;
<lib...@li...>
Sent: Wednesday, June 21, 2006 4:22 PM
Subject: Re: [Libusb-win32-devel] win-libusb async read
> You can set an environment variable USB_DEBUG to 1 or 2 for debug
> messages. Also the C header file errno.h may give some clue as to what
> the error numbers mean.
>
> Mark.
>
>
> Andrew Xiang wrote:
>
> >Where do  I find out the file that keep a list of error like -5? And how
can
> >I enable the usberror output? I guess I have to have the DDK to recompile
> >it? I don't have  the DDK installed.
> >
> >I cannot use multiple of 64, because there is the only way to detect end
of
> >the packet. Each block is 64bytes, if the block is not 64 blocks, that
means
> >it is the last block. This is the only way in the device I am using.
Maybe I
> >am missing something.
> >
> >I think I might have some hardware noise problem. Because I did not see
the
> >problem on another hardware.
> >
> >
> >-Andrew
> >
> >
> >----- Original Message ----- 
> >From: "Stephan Meyer" <ste...@we...>
> >To: <lib...@li...>; "Andrew Xiang"
> ><xi...@gr...>
> >Sent: Wednesday, June 21, 2006 3:49 PM
> >Subject: Re: [Libusb-win32-devel] win-libusb async read
> >
> >
> >
> >
> >>>#define BUF_SIZE (64*20+11)
> >>>
> >>>
> >>Can you always guarantee that the last packet your device
> >>sends is 11 bytes or less? If not, then set  BUF_SIZE to a multiple
> >>of the endpoint's buffer size. Otherwise your device might produce
> >>'data overrun' errors (this may cause the -5 error you got).
> >>
> >>
> >>
> >>> while(end_thread==0)
> >>> {
> >>> usb_bulk_setup_async(dev, &context0, EP_IN);
> >>>   usb_submit_async(context0, tmp1, sizeof(tmp1));
> >>> bytesread=usb_reap_async(context0, INFINITE);
> >>> printf("%d bytes read back\n", bytesread);
> >>> }
> >>>
> >>>
> >>You forgot to free 'context', call usb_free_async().
> >>_____________________________________________________________________
> >>Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> >>http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
> >>
> >>
> >>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> >>Fully trained technicians. The highest number of Red Hat certifications
in
> >>the hosting industry. Fanatical Support. Click to learn more
> >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> >>_______________________________________________
> >>Libusb-win32-devel mailing list
> >>Lib...@li...
> >>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> >>
> >>
> >>
> >
> >
> >All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> >Fully trained technicians. The highest number of Red Hat certifications
in
> >the hosting industry. Fanatical Support. Click to learn more
> >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> >_______________________________________________
> >Libusb-win32-devel mailing list
> >Lib...@li...
> >https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> >
> >
>
> All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> Fully trained technicians. The highest number of Red Hat certifications in
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
 | 
| 
      
      
      From: Mark B. <mc...@ec...> - 2006-06-22 16:44:46
       | 
| That's libusb's error.h. I meant errno.h from the compiler's standard 
headers - maybe I wasn't as clear as I could have been. MinGW has a 
comment by each value here, can't comment on how helpful other compilers 
might be:
#define    EIO        5    /* Input/output error */
Mark.
Andrew Xiang wrote:
>Here is the errno.h,  I don't see -5.
>
>-Andrew
>
>#ifndef __ERROR_H__
>#define __ERROR_H__
>
>/* Connection timed out */
>#define ETIMEDOUT 116
>
>typedef enum {
>  USB_ERROR_TYPE_NONE = 0,
>  USB_ERROR_TYPE_STRING,
>  USB_ERROR_TYPE_ERRNO,
>} usb_error_type_t;
>
>
>void usb_error(char *format, ...);
>void usb_message(char *format, ...);
>const char *usb_win_error_to_string(void);
>int usb_win_error_to_errno(void);
>
>
>
>#endif /* _ERROR_H_ */
>
>
>----- Original Message ----- 
>From: "Mark Bourne" <mb...@ze...>
>To: "Andrew Xiang" <xi...@gr...>;
><lib...@li...>
>Sent: Wednesday, June 21, 2006 4:22 PM
>Subject: Re: [Libusb-win32-devel] win-libusb async read
>
>
>  
>
>>You can set an environment variable USB_DEBUG to 1 or 2 for debug
>>messages. Also the C header file errno.h may give some clue as to what
>>the error numbers mean.
>>
>>Mark.
>>
>>
>>Andrew Xiang wrote:
>>
>>    
>>
>>>Where do  I find out the file that keep a list of error like -5? And how
>>>      
>>>
>can
>  
>
>>>I enable the usberror output? I guess I have to have the DDK to recompile
>>>it? I don't have  the DDK installed.
>>>
>>>I cannot use multiple of 64, because there is the only way to detect end
>>>      
>>>
>of
>  
>
>>>the packet. Each block is 64bytes, if the block is not 64 blocks, that
>>>      
>>>
>means
>  
>
>>>it is the last block. This is the only way in the device I am using.
>>>      
>>>
>Maybe I
>  
>
>>>am missing something.
>>>
>>>I think I might have some hardware noise problem. Because I did not see
>>>      
>>>
>the
>  
>
>>>problem on another hardware.
>>>
>>>
>>>-Andrew
>>>
>>>
>>>----- Original Message ----- 
>>>From: "Stephan Meyer" <ste...@we...>
>>>To: <lib...@li...>; "Andrew Xiang"
>>><xi...@gr...>
>>>Sent: Wednesday, June 21, 2006 3:49 PM
>>>Subject: Re: [Libusb-win32-devel] win-libusb async read
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>>#define BUF_SIZE (64*20+11)
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>Can you always guarantee that the last packet your device
>>>>sends is 11 bytes or less? If not, then set  BUF_SIZE to a multiple
>>>>of the endpoint's buffer size. Otherwise your device might produce
>>>>'data overrun' errors (this may cause the -5 error you got).
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>while(end_thread==0)
>>>>>{
>>>>>usb_bulk_setup_async(dev, &context0, EP_IN);
>>>>>  usb_submit_async(context0, tmp1, sizeof(tmp1));
>>>>>bytesread=usb_reap_async(context0, INFINITE);
>>>>>printf("%d bytes read back\n", bytesread);
>>>>>}
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>You forgot to free 'context', call usb_free_async().
>>>>_____________________________________________________________________
>>>>Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
>>>>http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
>>>>
>>>>
>>>>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
>>>>Fully trained technicians. The highest number of Red Hat certifications
>>>>        
>>>>
>in
>  
>
>>>>the hosting industry. Fanatical Support. Click to learn more
>>>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
>>>>_______________________________________________
>>>>Libusb-win32-devel mailing list
>>>>Lib...@li...
>>>>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
>>>Fully trained technicians. The highest number of Red Hat certifications
>>>      
>>>
>in
>  
>
>>>the hosting industry. Fanatical Support. Click to learn more
>>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
>>>_______________________________________________
>>>Libusb-win32-devel mailing list
>>>Lib...@li...
>>>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>>
>>>
>>>      
>>>
>>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
>>Fully trained technicians. The highest number of Red Hat certifications in
>>the hosting industry. Fanatical Support. Click to learn more
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
>>_______________________________________________
>>Libusb-win32-devel mailing list
>>Lib...@li...
>>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>
>>    
>>
>
>
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>Libusb-win32-devel mailing list
>Lib...@li...
>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>  
>
 | 
| 
      
      
      From: Stephan M. <ste...@we...> - 2006-06-22 15:47:44
       | 
| > Where do I find out the file that keep a list of error like -5? And how can > I enable the usberror output? I guess I have to have the DDK to recompile > it? I don't have the DDK installed. You can use usb_set_debug(255) to enable debug output. You don't have to recompile anything. Also, get DebugView from http://www.sysinternals.com/Utilities/DebugView.html This tool allows you to monitor the kernel driver's and the DLL's debug output. > > I cannot use multiple of 64, because there is the only way to detect end of > the packet. Each block is 64bytes, if the block is not 64 blocks, that means > it is the last block. This is the only way in the device I am using. Maybe I > am missing something. If you are using a multiple of 64 you can still detect the last packet. The usb_bulk_read() function returns the number of bytes read. If you request 64*21 bytes and your device only sends 64*20+11 bytes then 64*20+11 will be returned. > > I think I might have some hardware noise problem. Because I did not see the > problem on another hardware. > > > -Andrew > > > ----- Original Message ----- > From: "Stephan Meyer" <ste...@we...> > To: <lib...@li...>; "Andrew Xiang" > <xi...@gr...> > Sent: Wednesday, June 21, 2006 3:49 PM > Subject: Re: [Libusb-win32-devel] win-libusb async read > > > > > > > #define BUF_SIZE (64*20+11) > > > > Can you always guarantee that the last packet your device > > sends is 11 bytes or less? If not, then set BUF_SIZE to a multiple > > of the endpoint's buffer size. Otherwise your device might produce > > 'data overrun' errors (this may cause the -5 error you got). > > > > > while(end_thread==0) > > > { > > > usb_bulk_setup_async(dev, &context0, EP_IN); > > > usb_submit_async(context0, tmp1, sizeof(tmp1)); > > > bytesread=usb_reap_async(context0, INFINITE); > > > printf("%d bytes read back\n", bytesread); > > > } > > > > You forgot to free 'context', call usb_free_async(). > > _____________________________________________________________________ > > Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > > http://smartsurfer.web.de/?mc=100071&distributionid=000000000071 > > > > > > All the advantages of Linux Managed Hosting--Without the Cost and Risk! > > Fully trained technicians. The highest number of Red Hat certifications in > > the hosting industry. Fanatical Support. Click to learn more > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 > > _______________________________________________ > > Libusb-win32-devel mailing list > > Lib...@li... > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > > > > > All the advantages of Linux Managed Hosting--Without the Cost and Risk! > Fully trained technicians. The highest number of Red Hat certifications in > the hosting industry. Fanatical Support. Click to learn more > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 > _______________________________________________ > Libusb-win32-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel _____________________________________________________________________ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! http://smartsurfer.web.de/?mc=100071&distributionid=000000000071 | 
| 
      
      
      From: Stephan M. <ste...@we...> - 2006-06-22 15:50:31
       | 
| 
>From mingw's errno.h:
#define	EIO		5	/* Input/output error */
> Here is the errno.h,  I don't see -5.
> 
> -Andrew
> 
> #ifndef __ERROR_H__
> #define __ERROR_H__
> 
> /* Connection timed out */
> #define ETIMEDOUT 116
> 
> typedef enum {
>   USB_ERROR_TYPE_NONE = 0,
>   USB_ERROR_TYPE_STRING,
>   USB_ERROR_TYPE_ERRNO,
> } usb_error_type_t;
> 
> 
> void usb_error(char *format, ...);
> void usb_message(char *format, ...);
> const char *usb_win_error_to_string(void);
> int usb_win_error_to_errno(void);
> 
> 
> 
> #endif /* _ERROR_H_ */
> 
> 
> ----- Original Message ----- 
> From: "Mark Bourne" <mb...@ze...>
> To: "Andrew Xiang" <xi...@gr...>;
> <lib...@li...>
> Sent: Wednesday, June 21, 2006 4:22 PM
> Subject: Re: [Libusb-win32-devel] win-libusb async read
> 
> 
> > You can set an environment variable USB_DEBUG to 1 or 2 for debug
> > messages. Also the C header file errno.h may give some clue as to what
> > the error numbers mean.
> >
> > Mark.
> >
> >
> > Andrew Xiang wrote:
> >
> > >Where do  I find out the file that keep a list of error like -5? And how
> can
> > >I enable the usberror output? I guess I have to have the DDK to recompile
> > >it? I don't have  the DDK installed.
> > >
> > >I cannot use multiple of 64, because there is the only way to detect end
> of
> > >the packet. Each block is 64bytes, if the block is not 64 blocks, that
> means
> > >it is the last block. This is the only way in the device I am using.
> Maybe I
> > >am missing something.
> > >
> > >I think I might have some hardware noise problem. Because I did not see
> the
> > >problem on another hardware.
> > >
> > >
> > >-Andrew
> > >
> > >
> > >----- Original Message ----- 
> > >From: "Stephan Meyer" <ste...@we...>
> > >To: <lib...@li...>; "Andrew Xiang"
> > ><xi...@gr...>
> > >Sent: Wednesday, June 21, 2006 3:49 PM
> > >Subject: Re: [Libusb-win32-devel] win-libusb async read
> > >
> > >
> > >
> > >
> > >>>#define BUF_SIZE (64*20+11)
> > >>>
> > >>>
> > >>Can you always guarantee that the last packet your device
> > >>sends is 11 bytes or less? If not, then set  BUF_SIZE to a multiple
> > >>of the endpoint's buffer size. Otherwise your device might produce
> > >>'data overrun' errors (this may cause the -5 error you got).
> > >>
> > >>
> > >>
> > >>> while(end_thread==0)
> > >>> {
> > >>> usb_bulk_setup_async(dev, &context0, EP_IN);
> > >>>   usb_submit_async(context0, tmp1, sizeof(tmp1));
> > >>> bytesread=usb_reap_async(context0, INFINITE);
> > >>> printf("%d bytes read back\n", bytesread);
> > >>> }
> > >>>
> > >>>
> > >>You forgot to free 'context', call usb_free_async().
> > >>_____________________________________________________________________
> > >>Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> > >>http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
> > >>
> > >>
> > >>All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> > >>Fully trained technicians. The highest number of Red Hat certifications
> in
> > >>the hosting industry. Fanatical Support. Click to learn more
> > >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> > >>_______________________________________________
> > >>Libusb-win32-devel mailing list
> > >>Lib...@li...
> > >>https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> > >>
> > >>
> > >>
> > >
> > >
> > >All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> > >Fully trained technicians. The highest number of Red Hat certifications
> in
> > >the hosting industry. Fanatical Support. Click to learn more
> > >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> > >_______________________________________________
> > >Libusb-win32-devel mailing list
> > >Lib...@li...
> > >https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> > >
> > >
> >
> > All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> > Fully trained technicians. The highest number of Red Hat certifications in
> > the hosting industry. Fanatical Support. Click to learn more
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> > _______________________________________________
> > Libusb-win32-devel mailing list
> > Lib...@li...
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
> >
> 
> 
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
 | 
| 
      
      
      From: Andrew X. <xi...@gr...> - 2006-06-19 19:47:13
       | 
| usb_reap_async(context0, 5000);is waiting for the OV event. How would I find out how many bytes were actually read? OV read does not need to fill the number that was requested. -Andrew----- Original Message ----- From: "Stephan Meyer" <ste...@we...> To: <lib...@li...>; "Andrew Xiang" <xi...@gr...> Sent: Monday, June 19, 2006 12:44 PM Subject: Re: [Libusb-win32-devel] win-libusb async read > > See > > http://sourceforge.net/mailarchive/message.php?msg_id=10083829 > > > > > I got the simple bulk write/read to work. However, I would like to have a > > thread waiting on the read all the time and process the read data > > independent of the write. How would I implement async read using the libusb? > > anyone has an example? > > > > thanks > > Andrew > > > > > > > > _______________________________________________ > > Libusb-win32-devel mailing list > > Lib...@li... > > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > > > ______________________________________________________________________ > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130 > > > > _______________________________________________ > Libusb-win32-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel > | 
| 
      
      
      From: Andrew X. <xi...@gr...> - 2006-06-19 19:58:58
       | 
| Stephan,
in usb_submit_async
   if(!DeviceIoControl(c->dev->impl_info,
                      c->control_code,
                      &c->req, sizeof(libusb_request),
                      c->bytes,
                      c->size, &ret, &c->ol))
    {
      if(GetLastError() != ERROR_IO_PENDING)
        {
          usb_error("usb_submit_async: submitting request failed, "
                    "win error: %s", usb_win_error_to_string());
           return -usb_win_error_to_errno();
        }
    }
  return ret;
ret has the bytes_read. however, the value got returned before the value is
updated. I think usb_submit_async should take a parameter in as a
&bytes_read.
-Andrew
----- Original Message ----- 
From: "Stephan Meyer" <ste...@we...>
To: <lib...@li...>; "Andrew Xiang"
<xi...@gr...>
Sent: Monday, June 19, 2006 12:44 PM
Subject: Re: [Libusb-win32-devel] win-libusb async read
>
> See
>
> http://sourceforge.net/mailarchive/message.php?msg_id=10083829
>
>
>
> > I got the simple bulk write/read to work. However, I would like to have
a
> > thread waiting on the read all the time and process the read data
> > independent of the write. How would I implement async read using the
libusb?
> > anyone has an example?
> >
> > thanks
> > Andrew
> >
> >
> >
> > _______________________________________________
> > Libusb-win32-devel mailing list
> > Lib...@li...
> > https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
>
> ______________________________________________________________________
> XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
> Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130
>
>
>
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
 |