Path: utzoo!mnetor!uunet!husc6!uwvax!dogie!uwmcsd1!lakesys!mikep From: mikep@lakesys.UUCP (Mike Pluta) Newsgroups: comp.protocols.misc Subject: XModem CRC16 help Message-ID: <607@lakesys.UUCP> Date: 25 Apr 88 01:44:33 GMT Reply-To: mikep@lakesys.UUCP (Mike Pluta) Organization: Lake Systems - Milwaukee, WI Lines: 62 I am attempting to implement the X-Modem file transfer protocol under the PICK operating system. I has gotten so far as to complete and refine the sending and receiveing of files using the checksum error detection, but am having a bit of difficulty with the CRC portion of this particular project. I am using as a reference various articles by Ward Christionson, Chuck Forsberg and John Byrnes- the particular piece of data I have questions with is one composed by John Byrnes; i.e. he who first implemented the CRC16 extention to Ward's XModem protocol. As defined by Forsberg, the CRC calculation is as follows: int calcrc(ptr,count) char *ptr; int count; { int crc, i; crc = 0; while (--count >= 0 ){ crc = crc ^ (int)*ptr++ << 8; for (i = 0; i < 8; ++i) if (crc & 0x8000) crc = crc << 1 ^ 0x1021; else crc = crc << 1; } return (crc & 0xFFFF); } Now, I'm no C guru, but my feble attempt to decode this mess is as follows (please bear with the personal method of pseudo-coding): Given: Block of data, length of said block crchi/lo = 0 FOR i = 1 TO length_of_block crchi/lo = ( crchi/lo XOR block[i,1] ) SHIFTL 8 FOR j = 1 TO 8 IF ( crchi/lo AND HEX(8000) ) THEN crchi/lo = ( crchi/lo SHIFTL 1 ) XOR HEX(1021) ELSE crchi/lo = crchi/lo SHIFTL 1 END NEXT j NEXT i where SHIFTL is a bitwise left shift, no carry and block[i,1] references a single character starting at position i. My simple question is am I off in my interpretation, and if not, why doesn't the blasted thing work?! Is there some other CRC method that has superceeded the above stated? I am truely at a loss.... -- Michael J Pluta (mikep@lakesys.UUCP) c/o | Tri-Sys Computer Corp., Inc. | 207 East Buffalo Street, Suite 600 | Milwaukee, WI 53202 |