Sub AStreams_NewData (Buffer() As Byte)
Dim Data As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8") 'Grab the current chunk in buffer
DataBlock = DataBlock & Data 'Append the data to the exising running buffer.
If DataBlock.Contains(Chr(22)) = True And DataBlock.Contains(Chr(23)) = True Then 'We at least have once full packet.
RxPacket = DataBlock.SubString2(DataBlock.IndexOf(Chr(22)), DataBlock.IndexOf(Chr(23))+1) 'Grab the detected packet.
DataBlock = DataBlock.SubString(DataBlock.IndexOf(Chr(23))+1) 'Remove the first detected command from the running buffer.
Dim Splits() As String = Regex.Split("[\x16\x01\x02\x04\x17]", RxPacket) 'Separate the packet into its individual components.
For Each Item In Splits
Log(Item)
Next
End If
End Sub