Author Topic: question about inputbuffers  (Read 8812 times)

Zep

  • Member
  • ***
  • Posts: 10
question about inputbuffers
« on: February 16, 2013, 01:12:06 pm »
Hello. I am an oldtimer in development but I have not been working with USB before lately after I got a USB product with a very bad software for reading. So I decided to give it a try and make something myself.

I started working with VB and a DLL I found and things worked fine but for reasons I am not sure about I always run into issues when I start using the tableadpters in VB..never in C#, so I want now to stick to c# (VC 2010 Express).

For that I have been playing with the generic_hid_cs_50 and trying to get it communicate with my device.
And that goes fine it seems. Except ...I always sends 8 bytes (outputreport) to the devide to receive 4 x 8 bytes back (inputreport). The problem is that I only get the first 8 byte of the 4.

Is that as intended with the generic_hid_cs_50 frmMain example or am I doing something wrong? I have been trying to find information here in the forum and browsing the code to see if I can find something, but without luck. When I use the "Find my device" button I do get confirmed that the inputbuffer should be 32 bytes.

I noticed that when I tried just to tap the "Once" button 4 times after each other I would get all 4 reports.

I hope I made this post clear enough.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: question about inputbuffers
« Reply #1 on: February 16, 2013, 04:49:12 pm »
My generic HID application sends one report and requests one report.

If you want to receive 32 bytes, the device's report descriptor should define a 32-byte report, and this will be reflected in Capabilities.InputReportByteLength.

I have a new version of the application here:

http://lvr.com/hidpage.htm#MyExampleCode

 

Zep

  • Member
  • ***
  • Posts: 10
Re: question about inputbuffers
« Reply #2 on: February 16, 2013, 05:54:10 pm »
Quote
My generic HID application sends one report and requests one report.

If you want to receive 32 bytes, the device's report descriptor should define a 32-byte report, and this will be reflected in Capabilities.InputReportByteLength.

Yes I realize that. Does that mean that it is not really possible to read all 4 inputreports that is delivered per outputreport?
I dont have the option to change how the device is working.


Quote
I have a new version of the application here:

http://lvr.com/hidpage.htm#MyExampleCode

Thank you but isnt that the same version as the one I donwloaded a couple of days ago?

/Zep

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: question about inputbuffers
« Reply #3 on: February 16, 2013, 09:39:48 pm »
The Once button sends a report and then waits for a report. You can edit the code to do four reads (instead of one) after each write.

Side note - this is true for ReadFile (used in my code before v50) and is probably also true for Filestreams though I don't think I've tested it: when calling a read function, if multiple reports are available in the HID driver's buffer, the read operation will return as many reports as will fit in the read function's buffer. So if you use a larger buffer, you might get multiple reports returned and will need to check for this in the code. 

You said you were using generic_hid_cs_50. The new version is generic_hid_cs_60. The v60 version has an option to just send or just receive; you don't have to do both at once.

Zep

  • Member
  • ***
  • Posts: 10
Re: question about inputbuffers
« Reply #4 on: February 17, 2013, 02:23:52 am »
Thank you very much. I will play a little with sending more reads...

The generic_hid_cs_60 wont run with my VS 2010 and win 7 config. I tried that before writing here. It says that the version of VS is not compatible.

Zep

  • Member
  • ***
  • Posts: 10
Re: question about inputbuffers
« Reply #5 on: February 17, 2013, 06:52:19 am »
Ok, I read up on VS 2012 once more. First I thought that it was only for Win 8, but noticed that it had a desktop version. I instatlled that one and tried out generic_hid_cs_60.

In generic_hid_cs_60 it works perfectly just repeating the RequestToGetInputReport() without any delays. So I found something to work from.

Thank you very much for your fast replies.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: question about inputbuffers
« Reply #6 on: February 17, 2013, 01:52:34 pm »
Yes, I used Visual Studio 2012, and there is a free version. Biggest limitation of the application is no XP  because .NET 4.5 doesn't support it.

Zep

  • Member
  • ***
  • Posts: 10
Re: question about inputbuffers
« Reply #7 on: February 17, 2013, 02:34:20 pm »
Well I am first of all making this application for myself and I am pretty sure that xp will not be on my computers again.If I should ever decide to let others use this software (it it becomes worth releasing) then they just have to use win 7 og 8