Author Topic: Output Report sending problem  (Read 7105 times)

ojg

  • Member
  • ***
  • Posts: 4
Output Report sending problem
« on: May 07, 2015, 03:30:58 pm »
Hi,
I have downloaded generic_hid_cs_62 demo from this site. I can read and sent data from device but there is a problem. When I click on Send Output Report button the program answers Output report has been written but there is no received data in device at this moment. Data arrive to device immidiatly when I click on Get Input Report,
specificly this line
Code: [Select]
Task<Int32> t = deviceData.ReadAsync(inputReportBuffer, 0, inputReportBuffer.Length, cts.Token); or when I close the program. I have noticed that when I stepping through code (Break point on Send Output Report) data are send at the same moment as I get back from code to program window.

Can anyone give me some advice.

Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Output Report sending problem
« Reply #1 on: May 07, 2015, 05:44:47 pm »
A hardware-based protocol analyzer can show if the data is going out on the bus.

If you don't have an analyzer, use whatever debugging tools you have to isolate the problem.

How do you determine that there is "no received data in device"? Possibly the host sent the data but the device firmware isn't retrieving the data from the endpoint.

ojg

  • Member
  • ***
  • Posts: 4
Re: Output Report sending problem
« Reply #2 on: May 07, 2015, 06:36:34 pm »
I have a function in firmare what switch-on LED on receive any data.
When I click send as I have described LED stays off. I can wait for a minute to buffer some data from device and then I can read some data from buffer and LED goes on. Here is what I dont understand how can I start out transfer by reading buffer when there is no in nor out USB communication during reading buffer.
 
I have only software USBlyzer. It shows out communication at  the same time as LED go on.

When I click 3 times (4 times at first) on the Send button, LED connected to device switch on and I can see out transfer in USBlyzer.

Could be this problem descriptor related?

I am sorry if my questions are not professional, I am new in this area.

Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Output Report sending problem
« Reply #3 on: May 07, 2015, 08:13:33 pm »
How does the firmware detect received data to find out when to turn on the LED?

Maybe the data has been received, but the routine that is detecting the data doesn't see it.

ojg

  • Member
  • ***
  • Posts: 4
Re: Output Report sending problem
« Reply #4 on: May 08, 2015, 05:17:44 am »
I am using modified HID keyboard Demo from MicroChip Harmony (PIC32). As far as I can see there is some function called by USB device hid layer when some data arrive.

Code: [Select]
/* Function:
    void _USB_DEVICE_HID_ReportReceiveCallBack(void * handle)

  Summary:
    Callback function that gets called after the report is received
    from host.

  Description:
    This callback forwards the event to application callback function.

  Remarks:
    This is a local function and should not be called directly by the application.
*/

I have tested it by setting back keyboard descriptor and connect it to PC. Windows assumes that I have connect keayboard and sends output report on Num Lock changes. This output reports turn on the LED immediaetly, even if there is no input reports.

ojg

  • Member
  • ***
  • Posts: 4
Re: Output Report sending problem
« Reply #5 on: May 08, 2015, 03:37:07 pm »
I have found some solution. Its not pretty but it seems working.

call:
Code: [Select]
_deviceData.Flush(); after that write operation is complete
Code: [Select]
//
        // Summary:
        //     Clears buffers for this stream and causes any buffered data to be written
        //     to the file.
        //
        // Exceptions:
        //   System.IO.IOException:
        //     An I/O error occurred.
        //
        //   System.ObjectDisposedException:
        //     The stream is closed.
        public override void Flush();

do the job and sends data to device. I guess the important part is: causes any buffered data to be written to the file.
« Last Edit: May 08, 2015, 03:39:02 pm by ojg »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Output Report sending problem
« Reply #6 on: May 09, 2015, 11:03:06 am »
Thanks for reporting your solution.