Author Topic: input report too short  (Read 9797 times)

fotosettore

  • Member
  • ***
  • Posts: 4
input report too short
« on: April 17, 2017, 05:23:29 am »
hi
first thanks for developing genericHid. it helps too much for my usb software
i already used the your project under VB6. it works fine
i'm having some trouble using under VB2015. looking in the forum, it seems that there are no answers.

the problem is : the displayed answer of device is too short and is always truncated to byte n. 8

depending on the request, the device should answer up to 140 bytes
i tried to give more space at array (like i did in vb6 : works fine) but it did not work. i tried to set 512 in input report buffer size.
please note i'm not really expert of .net. i'm beginner in vs2015 devoloping software.

so, after my scenario, i have two questions :
1. which it is the way in order to increase the bytes answer (until 140 every times) ?
2. is it possible to put a delay time between output data and input data ? this why usb id needs little time to create the info pack to send.

many thanks for your help


p.s. please note the command sent : the answer must be of about 20 bytes but it stops to 9

  Usage: 1
  Usage Page: FF00
  Input Report Byte Length: 9      <--------- Always 9
  Output Report Byte Length: 9   
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 1
  Number of Input Button Caps: 0
  Number of Input Value Caps: 1
  Number of Input Data Indices: 1
  Number of Output Button Caps: 0
  Number of Output Value Caps: 1
  Number of Output Data Indices: 1
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0



 

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #1 on: April 17, 2017, 08:47:19 am »
If the endpoint is sending the correct report, but the data is truncated:

The passed buffer must be as large as the largest supported report + 1 byte (for report ID).

If the report is larger than the endpoint's maximum packet size, the device firmware must send the report in multiple transactions in response to received IN token packets.

Use breakpoints, etc. to be sure the received data is actually truncated (and it's not just that the display isn't showing all received data).

If the endpoint is sending the wrong report:

Configure the endpoint to return NAK until the device has received an Output report with the request. Then the firmware can fill the IN endpoint's buffer and configure the endpoint to return data on receiving an IN token packet. The specifics of how to do this will vary with the chip architecture.
« Last Edit: April 17, 2017, 10:04:41 am by Jan Axelson »

fotosettore

  • Member
  • ***
  • Posts: 4
Re: input report too short
« Reply #2 on: April 17, 2017, 01:09:15 pm »
hi
thanks for you fast reply
the report is correct because a not correct report says "nak"
sorry i'm not able to understand the practical solution to enlarge the buffer. may you help me better showing me where I must act ?
from what I can understand, i must operate changing outputReportBuffer but after some test it reports lenght 9 everytime. i'm wrong somewere
also i put 512 Friend Function GetNumberOfInputBuffers without success.
two days of tests - no way out :(

at last i want remember that in vb6 demo, the right string was get in this easy way
1. Public OutputReportData(7) As Byte - Public OutputReportData(200) As Byte
2. put a delay of 700ms at the beginning of Private Sub ReadReport()

very strange :please note that in vb2015 demo i must send THREE TIMES the command "once" to get the complete right string (see image)
the device is a solar inverter : if i send the command QID + CRC + CR, the inverter answer a length string of 18 ----> BEGIN + SERIAL NUMBER + CRC + CR

many thank for you help




« Last Edit: April 17, 2017, 01:14:25 pm by fotosettore »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #3 on: April 18, 2017, 09:00:27 am »
In FrmMain.vb, this line:

Array.Resize(outputReportBuffer, MyHid.Capabilities.OutputReportByteLength)

sizes outputReportBuffer to match the maximum OutputReportByteLength reported by the device during enumeration. That value should be large enough to hold the largest report.

It looks like your device is returning a value of 9. If that is less than the longest report, the problem is in the device firmware. Check the report descriptor.

towlerg

  • Member
  • ***
  • Posts: 24
Re: input report too short
« Reply #4 on: April 18, 2017, 04:38:15 pm »
Where does the Generic HID tester come from?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #5 on: April 19, 2017, 11:02:08 am »
If you are asking who wrote the Generic HID application at janaxelson.com, I did.

towlerg

  • Member
  • ***
  • Posts: 24
Re: input report too short
« Reply #6 on: April 20, 2017, 08:16:35 am »
Quote
If you are asking who wrote the Generic HID application at janaxelson.com, I did.

I'm curious about the program that was screen dumped in reply #2

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #7 on: April 20, 2017, 12:57:01 pm »
That looks like my application. fotosettore is using VB so it's not the most recent version. The applications are here:

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

towlerg

  • Member
  • ***
  • Posts: 24
Re: input report too short
« Reply #8 on: April 22, 2017, 01:03:17 pm »
Sorry if I'm being dull but I can't find the utility, could you be more specific (like what heading is it under).

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #9 on: April 22, 2017, 09:07:49 pm »
From here:

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

Under the heading:

My example code

The C# code is here:

Visual C# (C Sharp)

generic_hid_cs_62

and the VB code is here:

Visual Basic .NET

generic_hid_vb_50

fotosettore

  • Member
  • ***
  • Posts: 4
Re: input report too short
« Reply #10 on: April 23, 2017, 08:30:47 pm »
hi jan

i solved enlarging the dimension of INPUT BUFFER (the answer of inverter) using the instruction                 

Capabilities.InputReportByteLength = 200

in Hid.vb file
now i can read all bytes of answer string !

now there is another problem  :( about data to send to inverter (OUTPUT BUFFER)
sending a command to inverter that is more than 9 bytes gives error
all commands that are shorter of 9 are ok and all works fine. Over gives error.
i tried to set
Capabilities.OutputReportByteLength = 15
in Hid.vb
and change
Dim outputReportBuffer() As Byte = Nothing
to
Dim outputReportBuffer(15) As Byte
but i did not solved : it does not work and gives error

please note that i'm using generic_hid_vb_50 and it seems does not permit to enlarge output buffer
please note that Usbhidio2 works fine without errors of in or out
 
so ... any idea ?



Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #11 on: April 24, 2017, 09:44:38 am »
In the routine ExchangeInputAndOutputReports, this line:

Array.Resize(outputReportBuffer, MyHid.Capabilities.OutputReportByteLength)

sets outputReportBuffer to match the output report length returned by the device during enumeration.

I would start by examining this value.

fotosettore

  • Member
  • ***
  • Posts: 4
Re: input report too short
« Reply #12 on: May 07, 2017, 04:49:52 am »
after a lot of tests i discovered this
1. streaming routines goes in random error with my device. so i used the read write routine (4.6)
2. after write block it needs to put thread.sleep
3. to send more than 8 bytes it needs to send packs of 8+8+etc

« Last Edit: May 07, 2017, 04:57:17 am by fotosettore »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: input report too short
« Reply #13 on: May 07, 2017, 07:50:40 pm »
For OUT transfers that require multiple transactions (packets), the device firmware must support receiving data in multiple transactions. A short or zero-length packet indicates end of data.

For IN transfers that require multiple transactions (packets), the device firmware must support sending data in multiple transactions.

sjt

  • Member
  • ***
  • Posts: 6
Re: input report too short
« Reply #14 on: June 07, 2017, 06:22:44 pm »
From here:

and the VB code is here:

Visual Basic .NET

generic_hid_vb_50

I downloaded and compiled that yesterday. It now looks a lot less comprehensive than the image above, which perhaps is why people are asking.. Is there a version mismatch?