Hello.
I tried to reqrite the code a little:
Code:
Private Sub com1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim returnStr As String = String.empty
Dim InBuff(SerialPort1.BytesToRead - 1) As Byte
Dim pRet As Integer = 0
Trace.TraceInformation("COM1 just read: " & SerialPort1.Read(InBuff, 0, InBuff.Length).ToString("N0") & " Bytes of Data")
'probably not needed...since it clears automatically what we read...just try without it
'SerialPort1.DiscardInBuffer()
'sending what we just read...
RECIP = IPAddress.Parse(txtIP.Text)
RecPortInt = txtPort.Text
udpClient.Connect(RECIP, RecPortInt)
bytCommand = InBuff 'Encoding.ASCII.GetBytes(txtInfo.Text)
pRet = udpClient.Send(bytCommand, bytCommand.Length)
CheckForIllegalCrossThreadCalls = False
txtInfo.Text &= returnStr & Enviromnent.NewLine
End Sub I'm not sure if this changes anything. But there should be now Debug-Prints which are allowing you to follow how many bytes were read each time.
Bobby
Bookmarks