1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Dim bytes(6) As Byte
bytes(0) = 1
bytes(1) = 22
bytes(2) = 0
bytes(3) = 0
bytes(4) = 0
bytes(5) = 0
bytes(6) = 0 '23
Dim result As Int32 = 0
For i = 0 To bytes.Length - 1
result = result Xor bytes(i)
Next
bytes(6) = result
'01 22 00 00 00 00 23
'SerialPort1.Write(bytes, 0, bytes.Length)
'ou
bytes(0) = &H1
bytes(1) = &H22
bytes(2) = &H0
bytes(3) = &H0
bytes(4) = &H0
bytes(5) = &H0
bytes(6) = &H0 '23
result = 0
For i = 0 To bytes.Length - 1
result = result Xor bytes(i)
Next
bytes(6) = result
''SerialPort1.Write(bytes, 0, bytes.Length) |