(Read 10 times, has 0 replies, 1972 bytes) Date : Thu Nov 20 00:06:28 1997 From : Richard Murray of fidonet#2:254/86.1 To : Jonathan Harston Subject: Re: XModem-CRC Calculation Quoting Jonathan Harston (in ACORN_COMMS_UK)... JH> The first assumption - is the C function the correct one? I assume it is JH> as it is directly from the refernce documents. It's been a while since I looked at the X/Ymodem code in MTermRX. One thing I do remember, however, is that the CRC is a 16bit value. It was defined as an "int", but remember our "int"s are 32bit but only 16 on the PC. It expects to be able to roll over. While I'm on about it - Thanks again to Keith for helping me out there. JH> By the way, what's that extra data at the end of the file data block? If it is what I think it is, then try the following: --8<-------- if (ftp_buffer[120] == 'F' && cffiletype) { filetype = ftp_buffer[122] << 8 | ftp_buffer[121]; } --8<-------- I've improvised it for myself. Might not be 100% correct, but basically a hidden method of sending the filetype (and something else) in the header block. For my CRCing, I've built up a CRC table (should be in your sources?) and defined the routine: #define updcrc(cp, crc) ( crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ cp) And then: if ((sum = timed_get(1, 1)) == -1) return TIMED_OUT; if ((c = timed_get(1, 1)) == -1) return TIMED_OUT; c |= sum << 8; for (i = sum = 0; i < l; i++) sum = updcrc(ftp_buffer[i], sum); sum = updcrc(0, sum); sum = updcrc(0, sum); "sum" should be the same as "c". ___ /__/ rmurray@argonet.co.uk / \ichard. http://www.argonet.co.uk/users/rmurray/ --- Life has many mysteries, and I am one of them. * Origin: Worrying Heights [Encina] (2:254/86.1)