BBS: Inland Empire Archive Date: 03-25-93 (15:36) Number: 291 From: DIRK THEURER Refer#: NONE To: ALL Recvd: NO Subj: CND-DET routines 6/8 Conf: (2) Quik_Bas
'
' CND-DET routines (part 6)
'
IF NoOfGottenChars < DataLength THEN
GetCNDNumber% = 7
FOR i = 1 TO 500: NEXT i
FOSSILFlush
EXIT FUNCTION
'
' fatal error - number of characters received did not match
' indicated number of characters
'
ELSE
Timeout = 0 ' might not need to set this one
DO
i$ = GetChar$
IF i$ <> "" THEN
Timeout = 0
EXIT DO
END IF
Timeout = Timeout + 1
LOOP WHILE Timeout < 500
IF Timeout THEN
'
' fatal error - timed out getting CRC value
'
GetCNDNumber% = 8
FOR i = 1 TO 500: NEXT i
FOSSILFlush
EXIT FUNCTION
END IF
'
' received all CND data for current call
'
' format into CND data type
'
CND.CNDCRC = ASC(i$)
'
' - The following 'snippet' is from Quinn Tyler Jackson. It is a POSSIBLE
' method of calculating the CRC for the CND data packet. (It makes sense
' to me too, Quinn. :-) )
' - I've modified Quinn's original snippet to use my own variable
' names ("CNDData" which is DIMmed as variable length string and
' I DIMmed TempCRCSum as LONG for the temporary sum).
' - This snippet has NOT BEEN TESTED! (I _hope_ it works. %-} )
'
' Verbal description given to me:
' "The CRC is the twos compliment of the modulo 256 sum of the other
' words in the data message."
'
' Quinn's interpretation (most likely accurate or VERY close):
' "Add up the ASCII values of the bytes of the data, MOD 256 the
' result, and NOT that."
'
' TempCRCSum = 0
' FOR i% = LEN(CNDData)
' TempCRCSum = TempCRCSum + ASC(MID$(CNDData, i%, 1))
' NEXT i%
' TempCRCSum = NOT(TempCRCSum MOD 256)
'
' TempCRCSum can be converted to an integer and compared directly to
' CND.CNDCRC. If they match, then all the credit goes to Quinn! :-)
'
'
' Continues...
'
---
* Origin: RAVE * Burnaby, BC (1:153/810)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET