Author Topic: sending Host Get_/Set_Report requests  (Read 8719 times)

bonitusb

  • Member
  • ***
  • Posts: 3
sending Host Get_/Set_Report requests
« on: July 04, 2014, 07:35:29 am »
Hello Respected People,

i am using your example code "generic_hid_vb_50" with a very little modification for communicating with my NXP LPC1343 development board and its working very fine.
I basically placed check boxes on VB to light LEDs on my board when selected and buttons that will change to green in VB when input is received for the microcontroller(button pressed).

Now, i've migrated to NXP LPC1347 using the same VB program. Connection is established between the host and 1347 board but they are not communicating with each other(i.e no LED lights as was the case in 1343).
I used this your test program "SimpleHIDWrite" and my 1347 board responded. So, i guess the problem might be from the VB program.

Please what can i do to solve this problem?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: sending Host Get_/Set_Report requests
« Reply #1 on: July 04, 2014, 09:17:03 am »
Use whatever debugging tools you have to isolate the problem.

A hardware protocol analyzer will show what is happening on the bus. If you don't have an analyzer, in the host application, use breakpoints, etc. to view the parameters and return values of functions that communicate with the device. In device firmware, use a monitor program or similar to debug.

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: sending Host Get_/Set_Report requests
« Reply #2 on: July 05, 2014, 02:51:29 pm »
Hi bonitusb, again ;-)

You've moved to here from this thread on LPCWare USB forum.
http://www.lpcware.com/content/forum/lpc1347-hidsetreport-and-hidgetreport-functions-not-called

Quote
i am using your example code "generic_hid_vb_50" with a very little modification for communicating with my NXP LPC1343 development board and its working very fine. ... Now, i've migrated to NXP LPC1347 using the same VB program. Connection is established between the host and 1347 board but they are not communicating with each other(i.e no LED lights as was the case in 1343).

Your description suggests that the report descriptor on LPC1347 code should be different from LPC1343's. Also, you've modified Jan's VB code, so that the original avility to fit to the different report descriptor would be lost.

You have two options.

a) Report descriptor on the firmware
Copy the report descriptor from LPC1343 code to LPC1347, so that both have the same report definitions.

On the LPC1347 code, the report descriptor is given as HID_ReportDescriptor[] initialization in hid_desc.c

OR

b) PC code
What is your "a very little modification"?

If you would replace inputReportBuffer and outputReportBuffer into fixed size ones, the code ability to fit to target report descriptor should be lost. The size of these buffers are "Resize"d into Capabilities.InputReportByteLength / OutputReportByteLength in FindTheHid() (FrmMain.vb). The rest of the VB code assumes that these buffers hold given size.

Tsuneo
« Last Edit: July 05, 2014, 02:56:43 pm by Tsuneo »

bonitusb

  • Member
  • ***
  • Posts: 3
Re: sending Host Get_/Set_Report requests
« Reply #3 on: July 05, 2014, 08:05:42 pm »
Thank you so much Tsuneo, i really appreciate your support.

a)
I can only find the declaration of
Code: [Select]
extern const uint8_t HID_ReportDescriptor[]; in 1343 and not the initialization.
In 1347, the initialization remains the same as in "lpcopen_2_05_keil_iar_nxp_lpcxpresso_1347.zip(hid_desc.c)".
In Both:  pipe information, Device, configuration, interface, HID, Endpoint descriptor are similar.
monitored with "Advanced USB Port Monitor"

b)
I only redesigned the front panel to what i wanted and did not temper with these parts of Jan's VB code, they still remain the same.
Code: [Select]
Array.Resize(inputReportBuffer, MyHid.Capabilities.InputReportByteLength)
Array.Resize(outputReportBuffer, MyHid.Capabilities.OutputReportByteLength)

I just added these part and all other things remain same:
Code: [Select]
' '' <summary>
    ' '' Retrieves Input report data and status information.
    ' '' This routine is called automatically when myInputReport.Read
    ' '' returns. Calls several marshaling routines to access the main form.
    ' '' </summary>
    ' ''
    ' '' <param name="ar"> an object containing status information about
    ' '' the asynchronous operation. </param>

    ''' input from microcontroller
    Private Sub GetInputReportData(ByVal ar As IAsyncResult)

        Dim AdcValueHigh As Int16
        Dim AdcValueLow As Int16
        Dim AdcResult As Int16
        Dim Adc_str As String

        Dim switch_value As Int16

        Dim inputReportBuffer As Byte() = Nothing

        Try
            inputReportBuffer = CType(ar.AsyncState, Byte())

            fileStreamdevicedata.EndRead(ar)

            tmrReadTimeout.Stop()

            ' Display the received report data in the form's list box.

            If (ar.IsCompleted) Then

                'MyMarshalToForm("AddItemToListBox", "An Input report has been read.")
                'MyMarshalToForm("AddItemToListBox", " Input Report ID: " & String.Format("{0:X2} ", inputReportBuffer(0)))
                'MyMarshalToForm("AddItemToListBox", " Input Report Data:")

                switch_value = inputReportBuffer(1)

                AdcValueLow = inputReportBuffer(2)
                AdcValueHigh = inputReportBuffer(3)
                AdcResult = (AdcValueHigh << 8) Or AdcValueLow
                AdcResult = CShort(AdcResult * 3300 / 1023)
                Adc_str = String.Format("{0:D} ", AdcResult)

                MyMarshalToForm("ShowInCounterBox", Adc_str)


                If (switch_value And 1) = 1 Then
                    Button1.BackColor = Color.DarkGreen
                Else
                    Button1.BackColor = Color.Silver
                End If

                If (switch_value And 2) = 2 Then
                    Button2.BackColor = Color.DarkGreen
                Else
                    Button2.BackColor = Color.Silver
                End If

                If (switch_value And 4) = 4 Then
                    Button3.BackColor = Color.DarkGreen
                Else
                    Button3.BackColor = Color.Silver
                End If

            Else
                Debug.Write("The attempt to read an Input report has failed")
            End If
            MyMarshalToForm("'ScrollToBottomOfListBox", "")
            transferInProgress = False

        Catch ex As Exception
            DisplayException(Me.Name, ex)
            Throw
        End Try

    End Sub

and this part for lighting LEDs on the board:
Code: [Select]
    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        LedStatusUpdate()
    End Sub
Code: [Select]
Private Sub LedStatusUpdate()

        If CheckBox1.Checked = True Then         
            Output_Status = CByte(Output_Status Or (1 <<0))
            CheckBox1.BackColor = Color.DarkGreen
        Else
           Output_Status = CByte(Output_Status And Not (1 << 0))
            CheckBox1.BackColor = Color.Transparent
        End If
End Sub

This happens in VB
I placed checkboxes in VB to light LEDs on my board when selected, and buttons that should be changed to green in VB when  selected from the board.
If i select the check-boxes in VB, they end up setting the buttons on the same VB interface panel to green instead of lighting the LEDs on the board and pressing buttons on the board does nothing

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: sending Host Get_/Set_Report requests
« Reply #4 on: July 07, 2014, 10:19:40 am »
If you have changed a report descriptor (or any descriptor) and kept the same Vendor ID/Product ID, you should either:

1. With the device attached, in Device Manager > Driver, uninstall. Then detach and reattach.

or

2. Change the Product ID.

Windows caches information with the assumption that descriptors won't change.

bonitusb

  • Member
  • ***
  • Posts: 3
Re: sending Host Get_/Set_Report requests
« Reply #5 on: July 07, 2014, 11:24:41 am »
The Product IDs are different