no, just the ten bytes following the start char in buffer
Well, making guesses in the absence of the other information, and with me banging up demo code in B4J because I don't have B4R...
then this packet handler:
[CODE lang="b4x" highlight="18-21"]Sub HandlePacket(Buffer() As Byte)
Dim bc As ByteConverter
Dim BufferString As String = bc.StringFromBytes(Buffer, "ISO-8859-1")
Log("BufferString = " & BufferString)
'chop off first and last characters (StartOfPacket and EndOfPacket)
Dim HexString = BufferString.SubString2(1, BufferString.Length - 1)
Log("HexString = " & HexString)
'convert each 2 hex digits to 1 byte
Dim HexBytes() As Byte = bc.HexToBytes(HexString)
For I = 0 To HexBytes.Length - 1
Log(I & TAB & ByteToUnsigned(HexBytes(I)) & TAB & ByteToHex(HexBytes(I)))
Next
Dim CheckValue As Byte = 0
For I = 0 To HexBytes.Length - 2 'not including last byte (received checkvalue?)
CheckValue = Bit.Xor(CheckValue, HexBytes(I))
Next
Dim ReceivedCheckValue As Byte = HexBytes(HexBytes.Length - 1)
Log("Calculated checkvalue = " & ByteToHex(CheckValue))
Log("Received checkvalue = " & ByteToHex(ReceivedCheckValue))
End Sub
[/CODE]
supported by these helper routines:
[CODE lang="b4x" title="1,8"]Sub ByteToHex(B As Byte) As String
Dim bc As ByteConverter
Dim OneByte(1) As Byte
OneByte(0) = B
Return bc.HexFromBytes(OneByte)
End Sub
Sub ByteToUnsigned(B As Byte) As Int
Return Bit.And(B, 0xFF)
End Sub[/CODE]
and tested using:
[CODE lang="b4x" highlight="5,13"]Dim bc As ByteConverter
Dim StartOfPacket As String = ":"
Dim EndOfPacket As String = "$"
Dim SamplePacket As String = StartOfPacket & "000029CE688F" & EndOfPacket
Dim Buffer() As Byte = bc.StringToBytes(SamplePacket, "ISO-8859-1")
For I = 0 To Buffer.Length - 1
Log(I & TAB & Buffer(I) & TAB & Chr(Buffer(I)))
Next
HandlePacket(Buffer)[/CODE]
produces the promising-looking:
[CODE lang="html" title="Log output" highlight="15,23"]0 58 :
1 48 0
2 48 0
3 48 0
4 48 0
5 50 2
6 57 9
7 67 C
8 69 E
9 54 6
10 56 8
11 56 8
12 70 F
13 36 $
BufferString = :000029CE688F$
HexString = 000029CE688F
0 0 00
1 0 00
2 41 29
3 206 CE
4 104 68
5 143 8F
Calculated checkvalue = 8F
Received checkvalue = 8F[/CODE]