Calculate checksum by adding 2 data bytes together
Code:
CheckSum = DAT_IN1 + DAT_IN2
So the CheckSum = (%10101011 * 2 BYTES) if SW1 ( GPIO.3) was pressed.
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:
Code:
CHK_SUM VAR BYTE ' Holds checksum received
And:
Code:
CheckSum VAR BYTE ' Computed checksum of all bytes received
Therefore:
Code:
IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return
If Checksum (!) is not = CHK_SUM then go back to MAIN the checksum has failed.
The same with:
IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return
The DAT_IN BYTES must also be equal, if not then back to MAIN:
If however everything matches then continue to MATCH..........
How does this look?
Dave
Bookmarks