Author Topic: USB VB Issue  (Read 10580 times)

eoin

  • Member
  • ***
  • Posts: 5
USB VB Issue
« on: November 05, 2010, 11:57:42 am »
First of all your code has been a great help in getting my project up and running, I am using your Visual Basic example and my own USB code running on a PIC24FJ (Bulk Mode).
 
When I increase my ENDPOINT 1 packet length to 255 bytes my computer blue screens occassionally but when I switch back to a max of 64 bytes it does not blue screen.
 
I have a simple system setup whereby I send a command to my PIC24F, on receipt of a command I send back 64 bytes to the PC, this works great for single shots, Now if I put in a for loop behind the sendreceive bulk transfer button it will only receive data 3 times and not more.
 
After the third time it says Attempt to read bulk data failed. an then a text box pops up stating system access violation error.
 
Do you have any insight with regards to these issues?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB VB Issue
« Reply #1 on: November 05, 2010, 01:03:27 pm »
If you increase an endpoint's wMaxPacketSize, be sure any firmware buffers for the endpoint data are big enough.

In your For loop, wait for cmdOnce.Enabled to be true before starting a new set of send/receive transfers. In my app, see:

Private Sub cmdContinuous_Click

I'm glad to hear you've found my code helpful!

Jan

eoin

  • Member
  • ***
  • Posts: 5
Re: USB VB Issue
« Reply #2 on: November 06, 2010, 08:30:28 am »
Firmware buffers? I'm not really sure what packet size winusb.dll can handle?
 Could you tell me what the limitations there are ?
In your example I only saw one place where I could change the size of the received data buffer, or is there some other place I should change the max packet size ?

cmdOnce.Enabled and cmdContinous_Click I can't see these in winusb_vb_181, is there a newer version of the application which I couldnt find on your website?


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB VB Issue
« Reply #3 on: November 06, 2010, 10:34:41 am »
The firmware buffers are in the code in your device, not on the PC.

cmdOnce.Enabled and cmdContinous_Click are in my HID application here:

www.Lvr.com/hidpage.htm

Jan


eoin

  • Member
  • ***
  • Posts: 5
Re: USB VB Issue
« Reply #4 on: November 07, 2010, 12:52:46 pm »
The size of my Firmware buffer on the PIC24FJ32GB002 is 64 bytes now.
Let me explain first how my application will work.
The VB application will send a single one or two byte command to the PIC and the PIC will then begin fetching the contents of a 128Mbit memory IC and send the data back to the PC.

At the moment like i said it works great for single transfers I can receive up to around 128bytes( Still blue screens sometimes when I try to transmit 255 bytes on EP1 from PIC to PC) It also works fine if I make your code behind the send( Bulk transfer) button run twice or 3 times.

  For x As Integer = 1 To 2


                        success = myWinUsbDevice.SendViaBulkTransfer(databuffer, bytesToSend)


                        ReadDataViaBulkTransfer(64)


   Next x

I changed your  ReadDataViaBulkTransfer() function to accept a Uint32 value for how many bytes to read.
I also tried putting in a delay below ReadDataViaBulkTransfer(64) with a simple for loop and this didnt make a difference.(To make sure the USB activity was finished)

So the questions are why does this fail when I try to do this more than 3 times?
Why am I getting Blue Screens when I try sending large packets from PIC-PC?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB VB Issue
« Reply #5 on: November 07, 2010, 05:24:54 pm »
A protocol analyzer will show any problems on the bus. If you don't have access to one, use whatever debugging tools you have to monitor what the device is sending and how the host is responding.

This might also help:

http://www.networkworld.com/news/2005/041105-windows-crash.html

Jan