USB_BULK_READ() (amin mosayyebzadeh)
Krakora, Robert V <robert.v.krakora <at> delphi.com>
2007-09-03 13:57:41 GMT
Amin:
It looks like there is possibly a bug in your code. The variable i contains the size of reading blocks and that
is passed in to usb_bulk_read(). However, if the size of reading blocks is greater than the size of the
allocated buffer then there can be a buffer overrun in the driver causing a blue screen or PC reboot (based
on how you have Windows configured to handle the exception blue screen vs. automatic reboot). To fix this,
malloc() the buffer after calculating the size of reading blocks (do not forget to free it). You can
configure Windows to show a blue screen instead of automatically rebooting. The blue screen will
indicate in which driver the exception occurred and show a dump of registers and memory.
Best Regards,
Rob Krakora
Software Engineer
Delphi Electronics & Safety
e-mail: robert.v.krakora <at> delphi.com
phone: 765-451-8574
________________________________
From: libusb-win32-devel-bounces <at> lists.sourceforge.net on behalf of libusb-win32-devel-request <at> lists.sourceforge.net
Sent: Sat 9/1/2007 3:04 PM
To: libusb-win32-devel <at> lists.sourceforge.net
Subject: Libusb-win32-devel Digest, Vol 16, Issue 1
Send Libusb-win32-devel mailing list submissions to
libusb-win32-devel <at> lists.sourceforge.net
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
or, via email, send a message with subject or body 'help' to
libusb-win32-devel-request <at> lists.sourceforge.net
You can reach the person managing the list at
libusb-win32-devel-owner <at> lists.sourceforge.net
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Libusb-win32-devel digest..."
Today's Topics:
1. Re: libUsb Windows XP 64-bit (Xiaofan Chen)
2. USB_BULK_READ() (amin mosayyebzadeh)
----------------------------------------------------------------------
Message: 1
Date: Sat, 1 Sep 2007 11:01:21 +0800
From: "Xiaofan Chen" <xiaofanc <at> gmail.com>
Subject: Re: [Libusb-win32-devel] libUsb Windows XP 64-bit
To: libusb-win32-devel <at> lists.sourceforge.net
Message-ID:
<a276da400708312001k718611baif8836bab36b64beb <at> mail.gmail.com>
Content-Type: text/plain; charset=WINDOWS-1252
On 8/31/07, Spiro Trikaliotis <an-libusb-win32 <at> spiro.trikaliotis.net> wrote:
> * On Thu, Aug 30, 2007 at 07:54:14PM +0800 Xiaofan Chen wrote:
> > On 8/30/07, Bachelier, Georges <georges.bachelier <at> atmel.com> wrote:
> > > We provide the libUsb-Win32 driver and DLL to our customers within our
> > > software package (Atmel ? In-System Programming application). One of our
> > > customers is asking for an XP 64-bit version of libUsb. Is there anything
> > > available or planned?
> >
> > According to the forum archive, XP 64bit is supported but not Vista 64bit.
>
> Unless someone is willing to contribute his Verisign (or similar) key to
> sign a 64 bit driver, it is unlikely that this will change soon. That
> is, this holds true as long as there is no new implementation that
> utilizes the built-in driver winusb.sys.
I am not an USB expert but even with winusb.sys one still needs to
provide an INF file. Does that mean the situation will be any better
unless the INF is WHQLed? I do not have Vista now.
For example, people still need to provide an inf file for CDC-ACM
device even though they use the default usbser.sys in Windows.
The safe bet is HID which does not need an inf file in most cases.
> Citing Stephan in Message-Id: <2065512040 <at> web.de>:
>
> * On Mon, Jun 25, 2007 at 09:03:58PM +0200 Stephan Meyer wrote:
> >
> > The current version (0.1.12.1) works without any problems
> > on vista-32bit but NOT on vista-64bit.
> > Furture versions of the DLL will use vista's built-in winusb.sys
> > driver and will therefore work on both platforms. If you're
> > interrested in a pre-pre-alpha version then grab the latest sources
> > from the SVN and try it out.
> > http://libusb-win32.svn.sourceforge.net/viewvc/libusb-win32/trunk/libusb1/
>
> So, you might want to help Stephan in getting the new version done in
> order to get the Vista 64-bit version.
>
I would like to help but I do not know much about programming. I
can certainly help for testing. I've tested the HID backend and
it is only partially working. Not so sure anout the WinUSB
backend since I am still learning how to use WinUSB. There
are very few WinUSB examples on the web. For example, I am
having problems with WinUSB here.
http://forum.microchip.com/tm.aspx?m=264046
Now I have an WinUSB host example in Visual C++ 2005
Express so I am learning how to use it.
Hopefully some other person will help Stephan to get the HID
and WinUSB backend to work. That would be really nice.
Regards,
Xiaofan
------------------------------
Message: 2
Date: Sat, 1 Sep 2007 15:50:05 +0330
From: "amin mosayyebzadeh" <siramin056 <at> gmail.com>
Subject: [Libusb-win32-devel] USB_BULK_READ()
To: libusb-win32-devel <at> lists.sourceforge.net
Message-ID:
<e71cbb750709010520u72a93cfcm756d9eff15e52a4 <at> mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
hi all,
I use usb_bulk_read() for reading usb device sending data, but if I try to
read once again, PC will be reseted.(in below code, when I change prime
value of k to 2).
if I plug device out then plug in to pc, I can read again. Do you know why?
thanks.
int usb_test(usb_dev_handle *udev, int cnt) {
time_t start, end;
double dif=0;
ofstream ofile;
ofile.open("result.txt");
time (&start);
time (&end);
//PROBLEM IS HERE
for(int k = 1; k>0; k--){
char* rb;
char* wb;
int i=0, result;
rb = new char[4096];
wb = new char[2048];
int count = cnt;
//getting size of reading blocks;
ifstream ifile;
ifile.open("test.txt");
while(!ifile.eof()){
ifile.get();
i++;
}
ifile.close();
//reading received data
result = usb_bulk_read (udev, 2, rb, i, 1000);
if (result < 0) {
printf("\nCould not read: %s", usb_strerror());
return result;
} else {
count -= result;
printf("\nread %d bytes ", result);
}
//print read buffer
for (int j=0; j<result; j++) {
ofile << rb[j];
}
time(&end);
dif = difftime(end , start);
delete rb;
delete wb;
}
ofile.close();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
------------------------------
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
End of Libusb-win32-devel Digest, Vol 16, Issue 1
*************************************************
****************************************************************************************
Note: If the reader of this message is not the intended recipient, or an employee or agent responsible for
delivering this message to the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to the message and deleting it from your
computer. Thank you.
****************************************************************************************
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/