Serial stream string help
Posted on 2006-03-25
I am needing help with putting a partial string back together when the serial stream buffer only sends part of it.
Here's the deal.
Let's say that a chunk of data comes from the buffer and looks like this:
Then you have the rest that looks like
" 9 M3 8:22:39.147192"
I need those to get combined.
Now, thanks to previous help, I have this, but it isn't quite working correctly..
Here is my code:
Dim LeftOvers As String = ""
Dim Buffer1 As String = "S 8 M3 12.241000" & vbCrLf _
& "Tx 3 M4 8:22:35.417706" & vbCrLf _
& "V 1 20.129 [km/h]" & vbCrLf _
& "Tx "
Dim Buffer2 As String = " 9 M3 8:22:39.147192"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String
s = LeftOvers & Buffer1.ToString() '& "$"
LeftOvers = ""
s = s.Replace(ControlChars.CrLf, "$") ' remove all the CR and LF to become one line
'Dim StringBuffer() As String = Split(s, ControlChars.CrLf) ' split each by CR/LF
Dim StringBuffer() As String = Split(s, "$")
Dim TagHeuerPhotoCellValidString As String
For i As Int64 = 0 To StringBuffer.GetUpperBound(0)
If StringBuffer(i) <> Nothing Then
If ValidLine(StringBuffer(i)) Then
TagHeuerPhotoCellValidString = StringBuffer(i)
LeftOvers = StringBuffer(i) <----This is never getting hit...Why?
Catch ex As Exception
Function ValidLine(ByVal TestData As String) As Boolean
Dim SplitUpString() As String
Dim AlphaNum As String
Dim character As Char
If TestData.StartsWith("Tx") And (TestData.Length = 30) Then