PORTS Forum
Ports and Interfaces => USB => Topic started by: Frank Neumann on November 21, 2019, 10:58:12 am
-
Hi,
I have built a USB board with the AT90USB162, can also send and receive data. Have 8 LEDs connected and they shine when switching.
For the PC sided control software the software from the Internet of
the page http://janaxelson.com/files/generic_hid_vb_50.zip
downloaded.
I send the date from 0 - 255 for the 8 LEDs.
So far everything is fine.
Well, my HW also constantly sends back data, so I can see synonymous s.PC, what is switched or not.
But the software does not read continuously, It read only than if I send data.
Can someone tell me what this is due to the VB.NET software?
I did not change anything about the software, so I have it one on one
accepted. Only that I work with Byte instead of Hex.
BR
Frank
-
Yes, that application is written to send, then read, data. You can edit the source code to read reports continuously.
For the code to read a report, see the ExchangeInputAndOutputReports routine.
-
Hi Jan,
thanks for your reply.
Can you help me, how can I edit the source code to read reports continuously.
Can you show me a this with a small code?
thnaks for advanced
Frank
-
In the ExchangeInputAndOutputReports routine, delete the code that writes a report. Leave the code that reads a report.
-
Hi Jan,
sorry but I don't know what you mean.
Shall I delete this part?
fileStreamdevicedata.Write(outputReportBuffer, 0, outputReportBuffer.Length)
I yes, than I can not sent data to device.
BR
Frank
-
Remove this entire If...End If construction
If (MyHid.Capabilities.OutputReportByteLength > 0) Then
-
Hi Jan,
I have edit like below in the code, but doesn't works.
Try
success = False
If (Not (hidHandle.IsInvalid)) Then
'If (MyHid.Capabilities.OutputReportByteLength > 0) Then
Array.Resize(outputReportBuffer, MyHid.Capabilities.OutputReportByteLength)
outputReportBuffer(0) = 0
outputReportBuffer(1) = CByte(1)
If UBound(outputReportBuffer) > 1 Then
outputReportBuffer(2) = CByte(1)
End If
outputReportBuffer(3) = CByte(255)
outputReportBuffer(4) = CByte(255)
outputReportBuffer(5) = CByte(255)
outputReportBuffer(6) = CByte(255)
outputReportBuffer(7) = CByte(255)
outputReportBuffer(8) = CByte(255)
outputReportBuffer(9) = CByte(255)
outputReportBuffer(10) = CByte(255)
outputReportBuffer(11) = CByte(1)
outputReportBuffer(12) = CByte(2)
outputReportBuffer(13) = CByte(0)
outputReportBuffer(14) = CByte(0)
If (fileStreamdevicedata.CanWrite) Then
fileStreamdevicedata.Write(outputReportBuffer, 0, outputReportBuffer.Length)
success = True
Else
CloseCommunications()
' lstResults.Items.Add("The attempt to read an Input report has failed.")
End If
'If success Then
' ' lstResults.Items.Add("An Output report has been written.")
' ' lstResults.Items.Add(" Output Report ID: " & String.Format("{0:X2} ", outputReportBuffer(0)))
' ' lstResults.Items.Add(" Output Report Data:")
' 'txtBytesReceived.Text = ""
' 'For count = 1 To UBound(outputReportBuffer)
' ' 'byteValue = String.Format("{0:X2} ", outputReportBuffer(count))
' ' ' lstResults.Items.Add(" " & byteValue)
' 'Next count
'Else
' CloseCommunications()
' ' lstResults.Items.Add("The attempt to write an Output report failed.")
'End If
'Else
' lstResults.Items.Add("The HID doesn't have an Output report.")
'End If
success = False
If (MyHid.Capabilities.InputReportByteLength > 0) Then
Array.Resize(inputReportBuffer, MyHid.Capabilities.InputReportByteLength)
Dim ar As IAsyncResult = Nothing
transferInProgress = True
tmrReadTimeout.Start()
If (fileStreamdevicedata.CanRead) Then
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
Else
CloseCommunications()
' lstResults.Items.Add("The attempt to read an Input report has failed.")
End If
End If
End If
Catch ex As Exception
DisplayException(Me.Name, ex)
Throw
End Try
-
Use single-stepping or other debugging tools to isolate where the code is failing.
-
Hi,
shall I put this part in a Timer for to read reports continuously?
see below
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim inputReportBuffer() As Byte = Nothing
Dim i As Integer
Array.Resize(inputReportBuffer, MyHid.Capabilities.InputReportByteLength)
Dim ar As IAsyncResult = Nothing
fileStreamdevicedata.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, New AsyncCallback(AddressOf GetInputReportData), inputReportBuffer)
End Sub
I have Remove this entire If...End If construction
If (MyHid.Capabilities.OutputReportByteLength > 0) Then
as you said but the staus was the same.
First write
second read
BR
Frank
-
Yes, you can use a timer.