[comp.protocols.misc] XModem CRC16 help

mikep@lakesys.UUCP (Mike Pluta) (04/25/88)

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                       |

tedk@ihuxv.ATT.COM (Kekatos) (04/26/88)

I tried sending you E-mail, but it was returned. sigh!

Regarding PICK and XMODEM,

I have worked with the PICK OS and REVELATION for about 3 years.
I attempted to implement XMODEM on a ULTIMATE machine.
I can tell you about the problems that I had.
I am fairly well connected with the Chicagoland PICK
community.  I can connect you with several PICK developers.

Please call me. 

Ted G. Kekatos
backbone!ihnp4!ihuxv!tedk                     (312) 979-0804
AT&T Bell Laboratories, Indian Hill South, IX-1F-460
Naperville & Wheaton Roads - Naperville, Illinois. 60566 USA