' this event is activated when we receive something
' we will do something only after receiving a ">"
' that means the answer is complete
Sub OBDStream_NewData(Buffer() As Byte)
Try
Dim rsp As String
rsp = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
response.Append(rsp)
Dim PromptReceived As Boolean
PromptReceived = rsp.Contains(">")
If (PromptReceived) Then
'prompt is not terminater with CR, so we add it
response.Append(Chr(13))
'this doesn't count as a received response
RequestsPerSecond = RequestsPerSecond - 1
End If
'log received bytes
Dim tmp As String
Dim x As Int
x = 0
Do Until x = -1
tmp = response.ToString
x = tmp.IndexOf(Chr(13))
response = response.remove(0, x + 1)
If (x >= 0) Then
Dim frame As String
'remove CR
frame = tmp.SubString2(0, x)
WriteOBDLogReceived(frame)
RequestsPerSecond = RequestsPerSecond + 1
End If
Loop
'we received a prompt
If PromptReceived Then
SendNextCommand
response.Initialize 'clear string buffer
End If
Catch
util.HandleException("sequencer.OBDStream_NewData", util.EXCEPTION_CRITICAL)
End Try
End Sub