D
davem
I have a simple test application that displays barcode data. The barcode
scanner works via serial port communications. I am able to scan about 15 -
20 barcodes successfully then I recieve an incomplete barcode scan (partial
data), then the next scan always return no data. After that I'm able to
scan another 15 - 20 times correctly, then incomplete scan data followed a
scan with no data (and on and on . .).
I've tried clearing the buffer after every DataRecieved event, but this
seems to have no effect. Can anyone suggest what type of issue I'm running
into? This is the code I'm running
Private Sub serialPort_DataReceived(ByVal sender As Object, ByVal e As
System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived
Try
Me.Invoke(New EventHandler(AddressOf AddToList))
Catch ex As Exception
MsgBox("From DataReceived - " & ex.Message)
End Try
End Sub
Private Sub AddToList(ByVal s As Object, ByVal e As EventArgs)
Try
Dim strMsg As String = serialPort.ReadExisting.ToString.Trim
strMsg = Microsoft.VisualBasic.Right(strMsg, Len(strMsg) - 3)
ListBox1.Items.Add(strMsg)
serialPort.DiscardInBuffer()
serialPort.DiscardOutBuffer()
Catch ex As Exception
MsgBox("From DoUpdate - " & ex.Message)
End Try
End Sub
Any suggestions or ideas would be greatly appriciated.
Dave M.
scanner works via serial port communications. I am able to scan about 15 -
20 barcodes successfully then I recieve an incomplete barcode scan (partial
data), then the next scan always return no data. After that I'm able to
scan another 15 - 20 times correctly, then incomplete scan data followed a
scan with no data (and on and on . .).
I've tried clearing the buffer after every DataRecieved event, but this
seems to have no effect. Can anyone suggest what type of issue I'm running
into? This is the code I'm running
Private Sub serialPort_DataReceived(ByVal sender As Object, ByVal e As
System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived
Try
Me.Invoke(New EventHandler(AddressOf AddToList))
Catch ex As Exception
MsgBox("From DataReceived - " & ex.Message)
End Try
End Sub
Private Sub AddToList(ByVal s As Object, ByVal e As EventArgs)
Try
Dim strMsg As String = serialPort.ReadExisting.ToString.Trim
strMsg = Microsoft.VisualBasic.Right(strMsg, Len(strMsg) - 3)
ListBox1.Items.Add(strMsg)
serialPort.DiscardInBuffer()
serialPort.DiscardOutBuffer()
Catch ex As Exception
MsgBox("From DoUpdate - " & ex.Message)
End Try
End Sub
Any suggestions or ideas would be greatly appriciated.
Dave M.