From 2d5a6a45a379ce7d30919ac9f86015eaa4b9f3c9 Mon Sep 17 00:00:00 2001 From: Bernard Blackham Date: Wed, 23 Jun 2004 15:21:14 +0000 Subject: [PATCH] More versatile CRC function ... planned for auth --- ROM2/xmodem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ROM2/xmodem.c b/ROM2/xmodem.c index 3aa776a..b164243 100644 --- a/ROM2/xmodem.c +++ b/ROM2/xmodem.c @@ -53,17 +53,17 @@ readchar (int timeout) } /* Calculate a CRC-16 for the LEN byte message pointed at by P. */ -/* Pads with ^Z if necessary */ +/* Pads with ^Z up to 128 bytes if told to */ static unsigned short -docrc (unsigned char *p, int len) +docrc (unsigned char *p, int len, bool pad) { int len2 = len; unsigned short crc = 0; while (len-- > 0) crc = (crc << 8) ^ crctab[(crc >> 8) ^ *p++]; - if (len2 < 128) { + if (pad && len2 < 128) { len = 128-len; while (len-- > 0) crc = (crc << 8) ^ crctab[(crc >> 8) ^ 0x1a]; @@ -162,7 +162,7 @@ xmodem_send_packet (const unsigned char *packet, int len) if (crcflag) { u16 crc; - crc = docrc ((unsigned char*)packet, len); + crc = docrc ((unsigned char*)packet, len, 1); s[0] = crc >> 8; s[1] = crc & 0xff; -- 2.20.1