PORTS Forum
Ports and Interfaces => USB => Topic started by: bonitusb 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?
-
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.
-
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
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
-
Thank you so much Tsuneo, i really appreciate your support.
a)
I can only find the declaration of 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.
Array.Resize(inputReportBuffer, MyHid.Capabilities.InputReportByteLength)
Array.Resize(outputReportBuffer, MyHid.Capabilities.OutputReportByteLength)
I just added these part and all other things remain same:
' '' <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:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
LedStatusUpdate()
End Sub
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
-
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.
-
The Product IDs are different