Calculate checksum by adding 2 data bytes togetherSo the CheckSum = (%10101011 * 2 BYTES) if SW1 ( GPIO.3) was pressed.Code:CheckSum = DAT_IN1 + DAT_IN2
or (%10101101 * 2 BYTES) if SW2 (GPIO.4) was pressed.
Plus we should have the already have a calculated CHK_SUM that was sent.
So:
And:Code:CHK_SUM VAR BYTE ' Holds checksum received
Therefore:Code:CheckSum VAR BYTE ' Computed checksum of all bytes received
If Checksum (!) is not = CHK_SUM then go back to MAIN the checksum has failed.Code:IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return
The same with:
The DAT_IN BYTES must also be equal, if not then back to MAIN:IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return
If however everything matches then continue to MATCH..........
How does this look?
Dave




Bookmarks