Sub AStream_NewData (Buffer() As Byte)
[INDENT]Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "ASCII")
s = BytesToString(Buffer, 0, Buffer.Length, "ASCII")
HalfBuffer = HalfBuffer & s
Do While HalfBuffer.Length >= 5
[INDENT]NrLoop = NrLoop + 1
HalfBufferTmp = HalfBuffer.SubString2(0, 5)
B1S = HalfBufferTmp.SubString2(0, 1)
B2S = HalfBufferTmp.SubString2(1, 2)
B3S = HalfBufferTmp.SubString2(2, 3)
B4S = HalfBufferTmp.SubString2(3, 4)
B5S = HalfBufferTmp.SubString2(4, 5)
Log(Asc(B1S) & "." & Asc(B2S) & "." & Asc(B3S) & "." & Asc(B4S) & "." & Asc(B5S)) ' ---->>> LOG is: 65533.1.3.20.2 (byte from UART was 203.1.3.20.2)
Log(B1S & "." & B2S & "." & B3S & "." & B4S & "." & B5S) ' ---->>> LOG is: �.... (byte from UART was 203.1.3.20.2)
B3S = Asc(B3S)
Select B3S
[INDENT]Case 3
[INDENT]Log ("is 3")
If Asc(B1S) = 202 Then ' <<<<<----- trouble is here, if the value of B1S in more then 127 the value from Asc become 65533
[INDENT]If Asc(B2S) = 1 Then
[INDENT]TAint = Asc(B4S)
TAdec = Asc(B5S)
Log ("TA : " & B4S & "." & B5S)[/INDENT]
End If[/INDENT]
End If[/INDENT]
Case Else
[INDENT]Log (B3S)[/INDENT][/INDENT]
End Select
astream.Write(HalfBuffer.GetBytes("ASCII")) 'ECHO
HalfBuffer = HalfBuffer.SubString (5)[/INDENT]
Loop
NrLoop = 0[/INDENT]
End Sub