Author Topic: HID problem half duplex  (Read 16131 times)

webluca

  • Member
  • ***
  • Posts: 8
HID problem half duplex
« on: April 12, 2012, 10:14:04 am »
Hi,
everybody. This is my first topic on forum!  ;)

I have problem with comunicationn between pc and a pic microcontroller.
I have tried the library (generic_hid_vb_50) but I can not send and read data simultaneously.

Is it possible to realize ?

I have to make an application that reads data from USB and sends the data that the programmer wants.

I always receive data from the PIC, then I have to sniff all data sent from the pic.
Is there someone that can help me?

Looking forward getting your reply soon
« Last Edit: April 12, 2012, 12:13:43 pm by webluca »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #1 on: April 12, 2012, 03:35:09 pm »
All of a device's data shares the bus, so send and receive technically can't be simultaneous.

My generic HID application sends data to the device, then reads a response.

But an application can attempt to read and write in any sequence.

Jan

webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #2 on: April 12, 2012, 04:04:30 pm »
The application works fine but I need a change.
I have divided the section to read the writing section.
I tried the version 5.0. The read operation waits for the reception of data.
I try to send data to the device and the application stops.
Can You send me a modified example.
I need help! ;-)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #3 on: April 12, 2012, 10:21:32 pm »
My application is a starting point that you can modify as needed.

If you want to write to the device without reading from it, comment out the code that reads from the device.

Jan

webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #4 on: April 13, 2012, 03:05:00 am »
Hi

I modified the library.
Steps to follow to start form
1) Start the form
2) Click on find
3) Click on Continuos
4) click on send data

The form stops to point four, and not getting any response.

You can download modified solution:
http://dl.dropbox.com/u/47674327/generichid_vb_mod.rar

I need help! ;-)

webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #5 on: April 16, 2012, 03:12:35 am »
up

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #6 on: April 16, 2012, 10:46:26 am »
A hardware protocol analyzer will show what is happening on the bus. If you don't have an analyzer, use a monitor program, watch variables, etc., or whatever debugging tools you have to find out if the device's endpoint is receiving and ACKing the data.

Jan

webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #7 on: April 16, 2012, 11:34:11 am »
hi,
I checked your answer and the problem is not that.
I can send and receive data if i do the task in sequence.
I need to send data and read data asynchronously

I can receive 100, 2000, no packets asynchronously without sending anything!

I have to receive data without send something. The device has to "listen" always.
If you see above I pointed out the link from where you can download the modification to your library!
Please help me!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #8 on: April 16, 2012, 11:48:40 am »
If you want the device to listen always, write your firmware to detect and retrieve received data using interrupts or polling. After retrieving data from the endpoint's buffer, the endpoint should be configured to ACK new data.   

Jan

webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #9 on: April 16, 2012, 12:31:11 pm »
hi,
I must receive the data that the device sends me and not the other way!
The problem remains on application software!
 ;)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #10 on: April 16, 2012, 12:36:30 pm »
Modify the application so that after receiving data, it immediately attempts to read data again.

Jan

webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #11 on: April 16, 2012, 03:16:32 pm »
hi,
I have tried to modify the application but then I no longer send data forever!
You may check the files I changed?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #12 on: April 16, 2012, 03:35:24 pm »
In ExchangeInputAndOutputReports, comment out the code that sends a report. Exactly which line this is depends on the transfer type and whether you're using filestreams or writefile.

When GetInputReportData returns (transferInProgress = false), call ExchangeInputAndOutputReports again to begin another read operation.

Jan




webluca

  • Member
  • ***
  • Posts: 8
Re: HID problem half duplex
« Reply #13 on: April 17, 2012, 03:21:33 am »
I comment out the code that sends a report and then how do I send a report?
I have to use this function MyHid.SendOutputReportViaControlTransfer (hidHandle, outputReportBuffer)
or the other Me.fileWrite.Write (outputReportBuffer, 0, outputReportBuffer.Length) to send data?

I tried using the first or second and my application stops!!
IT STOPPS AND DOES NOT SEND DATA!!!!!

I stopped the application and it stops ON the Thread class?
You can send me a solution via email: webluca@aruba.it

Please help me because I can not complete my application because of this problem  :o :o :o :o :o :o :o
I attach a photo:

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID problem half duplex
« Reply #14 on: April 17, 2012, 12:23:00 pm »
Get the read operation working first. Then you can add a button or other code to initiate writes to the device.

Jan