updated zmodem

This commit is contained in:
Michiel Broek 2004-11-20 18:31:13 +00:00
parent 992dac98bc
commit 164b54d91e
4 changed files with 28 additions and 28 deletions

View File

@ -133,6 +133,6 @@ userlist.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h userlist.h
timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h timestats.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h timestats.h funcs.h language.h input.h exitinfo.h term.h
logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h logentry.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h logentry.h
zmmisc.o: ../config.h ../lib/mbselib.h ttyio.h zmmisc.h zmmisc.o: ../config.h ../lib/mbselib.h ttyio.h zmmisc.h
zmsend.o: ../config.h ../lib/mbselib.h ttyio.h zmmisc.h transfer.h openport.h zmsend.o: ../config.h ../lib/mbselib.h ttyio.h zmmisc.h transfer.h openport.h timeout.h
zmrecv.o: ../config.h ../lib/mbselib.h ../lib/users.h ttyio.h transfer.h zmmisc.h zmrecv.h openport.h zmrecv.o: ../config.h ../lib/mbselib.h ../lib/users.h ttyio.h transfer.h zmmisc.h zmrecv.h openport.h timeout.h input.h
# End of generated dependencies # End of generated dependencies

View File

@ -69,12 +69,11 @@ static void garbitch(void);
#include "zmmisc.h" #include "zmmisc.h"
/* Original zm.c timing was in tenths of seconds, but our current ttyio driver /*
does timing in whole seconds. * Original zm.c timing was in tenths of seconds, but our current ttyio driver
*/ * does timing in whole seconds.
*/
static int Rxtimeout = 10; /* Seconds to wait for something */ static int Rxtimeout = 10; /* Seconds to wait for something */
// int Rxhlen; /* Length of header received */
char *txbuf=NULL; char *txbuf=NULL;
static int lastsent; /* Last char we sent */ static int lastsent; /* Last char we sent */
static int Not8bit; /* Seven bits seen on header */ static int Not8bit; /* Seven bits seen on header */
@ -347,7 +346,7 @@ int zrdata(register char *buf, int length)
register char *end; register char *end;
register int d; register int d;
Syslog('z', "zrdata: len=%d, Crc32r=%s", length, Crc32r ? "true":"false"); Syslog('Z', "zrdata: len=%d, Crc32r=%s", length, Crc32r ? "true":"false");
if (Crc32r) if (Crc32r)
return zrdat32(buf, length); return zrdat32(buf, length);

View File

@ -36,6 +36,8 @@
#include "zmmisc.h" #include "zmmisc.h"
#include "zmrecv.h" #include "zmrecv.h"
#include "openport.h" #include "openport.h"
#include "timeout.h"
#include "input.h"
static FILE *fout = NULL; static FILE *fout = NULL;
@ -76,7 +78,8 @@ extern unsigned long rcvdbytes;
int zmrcvfiles(void) int zmrcvfiles(void)
{ {
int rc; int rc, c, count = 0;
unsigned char ch = 0;
Syslog('+', "Zmodem: start Zmodem receive"); Syslog('+', "Zmodem: start Zmodem receive");
@ -106,7 +109,17 @@ int zmrcvfiles(void)
secbuf = NULL; secbuf = NULL;
free_frame_buffer(); free_frame_buffer();
io_mode(0, 1); io_mode(0, 1); /* Normal raw mode */
/*
* Some programs (Dynacom) send some garbage after the transfer
*/
Syslog('z', "zmrcvfiles: garbage check");
do {
c = Waitchar(&ch, 100);
count++;
} while (c == 1);
Syslog('z', "zmrcvfiles: purged %d garbage characters", count);
Syslog('z', "Zmodem: receive rc=%d",rc); Syslog('z', "Zmodem: receive rc=%d",rc);
return abs(rc); return abs(rc);
} }
@ -131,19 +144,14 @@ int tryz(void)
Syslog('z', "tryz attempt %d", n); Syslog('z', "tryz attempt %d", n);
stohdr(0L); stohdr(0L);
Txhdr[ZF0] = CANFC32|CANFDX|CANOVIO; Txhdr[ZF0] = CANFC32|CANFDX|CANOVIO;
// Txhdr[ZF0] = CANFC32;
if (Zctlesc) if (Zctlesc)
Txhdr[ZF0] |= TESCCTL; Txhdr[ZF0] |= TESCCTL;
// Txhdr[ZF0] |= CANRLE;
// Txhdr[ZF1] = CANVHDR;
zshhdr(tryzhdrtype, Txhdr); zshhdr(tryzhdrtype, Txhdr);
if (tryzhdrtype == ZSKIP) /* Don't skip too far */ if (tryzhdrtype == ZSKIP) /* Don't skip too far */
tryzhdrtype = ZRINIT; /* CAF 8-21-87 */ tryzhdrtype = ZRINIT; /* CAF 8-21-87 */
again: again:
switch (zgethdr(Rxhdr)) { switch (zgethdr(Rxhdr)) {
case ZRQINIT: // if (Rxhdr[ZF3] & 0x80) case ZRQINIT: continue;
// Usevhdrs = TRUE; /* we can var header */
continue;
case ZEOF: continue; case ZEOF: continue;
case TIMEOUT: Syslog('+', "Zmodem: tryz() timeout attempt %d", n); case TIMEOUT: Syslog('+', "Zmodem: tryz() timeout attempt %d", n);
continue; continue;
@ -154,8 +162,6 @@ again:
} }
zmanag = Rxhdr[ZF1]; zmanag = Rxhdr[ZF1];
ztrans = Rxhdr[ZF2]; ztrans = Rxhdr[ZF2];
// if (Rxhdr[ZF3] & ZCANVHDR)
// Usevhdrs = TRUE;
tryzhdrtype = ZRINIT; tryzhdrtype = ZRINIT;
c = zrdata(secbuf, MAXBLOCK); c = zrdata(secbuf, MAXBLOCK);
io_mode(0, 3); io_mode(0, 3);
@ -211,7 +217,6 @@ again:
default: continue; default: continue;
} }
} }
Syslog('z', "tryz return 0");
return 0; return 0;
} }
@ -224,8 +229,6 @@ int rzfiles(void)
{ {
int c; int c;
Syslog('z', "rzfiles");
for (;;) { for (;;) {
switch (c = rzfile()) { switch (c = rzfile()) {
case ZEOF: case ZEOF:
@ -253,8 +256,6 @@ int rzfile(void)
{ {
int c, n; int c, n;
Syslog('z', "rzfile");
Eofseen=FALSE; Eofseen=FALSE;
rxbytes = 0l; rxbytes = 0l;
if ((c = procheader(secbuf))) { if ((c = procheader(secbuf))) {
@ -328,8 +329,9 @@ nxthdr:
continue; continue;
} }
moredata: moredata:
Syslog('z', "%7ld ZMODEM%s ", rxbytes, Crc32r?" CRC-32":""); Syslog('Z', "%7ld ZMODEM%s ", rxbytes, Crc32r?" CRC-32":"");
Nopper(); Nopper();
alarm_on();
switch (c = zrdata(secbuf, MAXBLOCK)) { switch (c = zrdata(secbuf, MAXBLOCK)) {
case ZCAN: Syslog('+', "Zmodem: sender CANcelled"); case ZCAN: Syslog('+', "Zmodem: sender CANcelled");
return TERROR; return TERROR;
@ -350,7 +352,6 @@ moredata:
case GOTCRCW: n = 20; case GOTCRCW: n = 20;
putsec(secbuf, Rxcount); putsec(secbuf, Rxcount);
rxbytes += Rxcount; rxbytes += Rxcount;
Syslog('z', "rxbytes %ld, will ACK", rxbytes);
stohdr(rxbytes); stohdr(rxbytes);
PUTCHAR(XON); PUTCHAR(XON);
zshhdr(ZACK, Txhdr); zshhdr(ZACK, Txhdr);
@ -556,8 +557,6 @@ int putsec(char *buf, int n)
if (Thisbinary) { if (Thisbinary) {
if (fwrite(buf, n, 1, fout) != 1) if (fwrite(buf, n, 1, fout) != 1)
return ERROR; return ERROR;
// for (p = buf; --n>=0; )
// putc( *p++, fout);
} else { } else {
if (Eofseen) if (Eofseen)
return OK; return OK;

View File

@ -34,6 +34,7 @@
#include "zmmisc.h" #include "zmmisc.h"
#include "transfer.h" #include "transfer.h"
#include "openport.h" #include "openport.h"
#include "timeout.h"
static int initsend(void); static int initsend(void);
@ -514,6 +515,7 @@ to:
e = ZCRCG; e = ZCRCG;
Syslog('Z', "%7ld ZMODEM%s ", Txpos, Crc32t?" CRC-32":""); Syslog('Z', "%7ld ZMODEM%s ", Txpos, Crc32t?" CRC-32":"");
Nopper(); Nopper();
alarm_on();
zsdata(txbuf, n, e); zsdata(txbuf, n, e);
bytcnt = Txpos += n; bytcnt = Txpos += n;