PORTS Forum
Ports and Interfaces => USB => Topic started by: ojg 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 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.
-
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.
-
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.
-
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.
-
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.
/* 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.
-
I have found some solution. Its not pretty but it seems working.
call:_deviceData.Flush();
after that write operation is complete
//
// 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.
-
Thanks for reporting your solution.