git.ucc.asn.au
/
uccvend-snackrom.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A little sanity checker.
[uccvend-snackrom.git]
/
ROM2
/
xmodem.c
diff --git
a/ROM2/xmodem.c
b/ROM2/xmodem.c
index
3aa776a
..
b164243
100644
(file)
--- 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. */
}
/* 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
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++];
{
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];
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;
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;
s[0] = crc >> 8;
s[1] = crc & 0xff;
UCC
git Repository :: git.ucc.asn.au