Cheers mackrackit
I don't know.....So the original code would have to receive two good with out a bad. I wonder why Bruce did it that way?
One thing though, from Bruce's code (and please bear in mind this is the thinking of a newbie here).The only way(as I see it) that MATCH can ever reach a count of two and then move onto 'DECODE' is for the program to run from 'SERIN2' all the way to 'GOTO Main' once and then a second time to 'IF MATCH = 2 THEN DECODE' for MATCH to ever equal 2. Am I missing something here?
DaveCode:' Wait for Synch byte, then get new inbound data & checksum SERIN2 D_IN,N2400,[WAIT(Synch),DAT_IN1,DAT_IN2,CHK_SUM,TEST] T1CON.0 = 0 ' Stop Timer1 once we've received data TMR1L = 0 ' Clear low byte TMR1H = 0 ' Clear high byte ' / **** Begin data validation **** / ' Calculate checksum by adding 2 data bytes together CheckSum = DAT_IN1 + DAT_IN2 ' Test new checksum against one received in CHK_SUM IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return ' Test data bytes for match IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return MATCH = MATCH + 1 ' We have a match so increment match count IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good GOTO Main ' Else do it all over





Bookmarks