R
RG
I am having trouble parsing the data I need from a Serial Port Buffer.
I am sending info to a microcontroller that is being echoed back that
I need to remove before I start the actual important data reading.
For instance this is my buffer string:
012301234FFFFFFxFFFFFFxFFFFFFx
Where the FFFFFF is my Hex data I need to read. I am using the "x" as
a separater as I was having problems using the VbCrLf. But I think
that was because the actual stream of data I need has to be filtered
on the front end.
The 012301234 intergers are values being sent to the microcontroller
and echoed back to VB serialport buffer. The 4 is the number I use to
start the HEX data stream I need. I am using a Select Case with "4"
being the case to start the stream. This is probably not a good idea
becuase it could also be found in the Hex Data Stream using the Instr
command.
This is what I have so far but it is not working correctly
Dim TerminatorPos As Integer
TerminatorPos = InStr(Buffer1, "x")
If vboutput = 4 Then
Buffer1 = Buffer1.Remove(0, TerminatorPos) ' Trying to
remove everything before the "x"
End If
If TerminatorPos > 0 Then
hexbuffer1 = Mid(Buffer1, 1, TerminatorPos - 1)
buffer1_Dec = Convert.ToInt32(hexbuffer1, 16)' This is
where the errors occur because I amnot getting a true hex value to
convert based on the data being parsed when the program starts.
Buffer1 = Mid(Buffer1, TerminatorPos + 1)
End If
I am sending info to a microcontroller that is being echoed back that
I need to remove before I start the actual important data reading.
For instance this is my buffer string:
012301234FFFFFFxFFFFFFxFFFFFFx
Where the FFFFFF is my Hex data I need to read. I am using the "x" as
a separater as I was having problems using the VbCrLf. But I think
that was because the actual stream of data I need has to be filtered
on the front end.
The 012301234 intergers are values being sent to the microcontroller
and echoed back to VB serialport buffer. The 4 is the number I use to
start the HEX data stream I need. I am using a Select Case with "4"
being the case to start the stream. This is probably not a good idea
becuase it could also be found in the Hex Data Stream using the Instr
command.
This is what I have so far but it is not working correctly
Dim TerminatorPos As Integer
TerminatorPos = InStr(Buffer1, "x")
If vboutput = 4 Then
Buffer1 = Buffer1.Remove(0, TerminatorPos) ' Trying to
remove everything before the "x"
End If
If TerminatorPos > 0 Then
hexbuffer1 = Mid(Buffer1, 1, TerminatorPos - 1)
buffer1_Dec = Convert.ToInt32(hexbuffer1, 16)' This is
where the errors occur because I amnot getting a true hex value to
convert based on the data being parsed when the program starts.
Buffer1 = Mid(Buffer1, TerminatorPos + 1)
End If