Updated transfer protocols

This commit is contained in:
Michiel Broek 2004-11-25 22:43:14 +00:00
parent 19f28d4c83
commit 6b2a1f0d15
3 changed files with 18 additions and 18 deletions

View File

@ -73,21 +73,21 @@ et_tu:
Firstsec = TRUE; Firstsec = TRUE;
eof_seen = FALSE; eof_seen = FALSE;
sendline(Crcflg?WANTCRC:NAK); sendline(Crcflg?WANTCRC:NAK);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
purgeline(0); /* Do read next time ... */ purgeline(0); /* Do read next time ... */
while ((c = wcgetsec(&Blklen, rpn, 10)) != 0) { while ((c = wcgetsec(&Blklen, rpn, 10)) != 0) {
if (c == WCEOT) { if (c == WCEOT) {
Syslog('x', "Pathname fetch returned EOT"); Syslog('x', "Pathname fetch returned EOT");
sendline(ACK); sendline(ACK);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
purgeline(0); /* Do read next time ... */ purgeline(0); /* Do read next time ... */
GETCHAR(1); // GETCHAR(1);
goto et_tu; goto et_tu;
} }
return ERROR; return ERROR;
} }
sendline(ACK); sendline(ACK);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
return OK; return OK;
} }
@ -108,7 +108,7 @@ int wcrx(void)
for (;;) { for (;;) {
sendline(sendchar); /* send it now, we're ready! */ sendline(sendchar); /* send it now, we're ready! */
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
purgeline(0); /* Do read next time ... */ purgeline(0); /* Do read next time ... */
/* /*
@ -118,7 +118,7 @@ int wcrx(void)
alarm_on(); alarm_on();
sectcurr = wcgetsec(&Blklen, secbuf, (unsigned int) ((sectnum & 0177) ? 5 : 13)); sectcurr = wcgetsec(&Blklen, secbuf, (unsigned int) ((sectnum & 0177) ? 5 : 13));
Syslog('x', "%s: got sector %d", protname(), sectcurr); Syslog('x', "%s: got sector %d size %d", protname(), sectcurr, Blklen);
if (sectcurr == ((sectnum+1) &0377)) { if (sectcurr == ((sectnum+1) &0377)) {
sectnum++; sectnum++;
@ -138,7 +138,7 @@ int wcrx(void)
if (closeit(1)) if (closeit(1))
return ERROR; return ERROR;
sendline(ACK); sendline(ACK);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
purgeline(0); /* Do read next time ... */ purgeline(0); /* Do read next time ... */
return OK; return OK;
} }
@ -160,8 +160,6 @@ int wcgetsec(size_t *Blklen, char *rxbuf, unsigned int maxtime)
register char *p; register char *p;
int sectcurr; int sectcurr;
Syslog('x', "%s: wcgetsec()", protname());
for (Lastrx = errors = 0; errors < RETRYMAX; errors++) { for (Lastrx = errors = 0; errors < RETRYMAX; errors++) {
if ((firstch = GETCHAR(maxtime)) == STX) { if ((firstch = GETCHAR(maxtime)) == STX) {
@ -170,7 +168,6 @@ int wcgetsec(size_t *Blklen, char *rxbuf, unsigned int maxtime)
if (firstch == SOH) { if (firstch == SOH) {
*Blklen=128; *Blklen=128;
get2: get2:
Syslog('x', "%s: wcgetsec blklen %d", protname(), *Blklen);
sectcurr = GETCHAR(1); sectcurr = GETCHAR(1);
if ((sectcurr + (oldcrc = GETCHAR(1))) == 0377) { if ((sectcurr + (oldcrc = GETCHAR(1))) == 0377) {
oldcrc = Checksum = 0; oldcrc = Checksum = 0;
@ -228,14 +225,14 @@ humbug:
if (Firstsec) { if (Firstsec) {
sendline(Crcflg ? WANTCRC:NAK); sendline(Crcflg ? WANTCRC:NAK);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
Syslog('x', "%s: send %s", protname(), Crcflg ? "WANTCRC":"NAK"); Syslog('x', "%s: send %s", protname(), Crcflg ? "WANTCRC":"NAK");
purgeline(0); /* Do read next time ... */ purgeline(0); /* Do read next time ... */
} else { } else {
maxtime = 40; maxtime = 40;
sendline(NAK); sendline(NAK);
Syslog('x', "%s: send NAK", protname()); Syslog('x', "%s: send NAK", protname());
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
purgeline(0); /* Do read next time ... */ purgeline(0); /* Do read next time ... */
} }
} }

View File

@ -343,8 +343,7 @@ static int wctx(long bytes_total)
do { do {
purgeline(5); purgeline(5);
PUTCHAR(EOT); PUTCHAR(EOT);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
// fflush(stdout);
++attempts; ++attempts;
} while ((firstch = (GETCHAR(Rxtimeout)) != ACK) && attempts < RETRYMAX); } while ((firstch = (GETCHAR(Rxtimeout)) != ACK) && attempts < RETRYMAX);
if (attempts == RETRYMAX) { if (attempts == RETRYMAX) {
@ -366,8 +365,7 @@ static int wcputsec(char *buf, int sectnum, size_t cseclen)
firstch = 0; /* part of logic to detect CAN CAN */ firstch = 0; /* part of logic to detect CAN CAN */
Syslog('x', "wcputsec: sectnum %d, len %d", sectnum, cseclen); Syslog('x', "%s: wcputsec: sectnum %d, len %d", protname(), sectnum, cseclen);
Syslog('x', "%s sectors/kbytes sent: %3d/%2dk", protname(), Totsecs, Totsecs/8 );
for (attempts = 0; attempts <= RETRYMAX; attempts++) { for (attempts = 0; attempts <= RETRYMAX; attempts++) {
Lastrx = firstch; Lastrx = firstch;
@ -388,8 +386,7 @@ static int wcputsec(char *buf, int sectnum, size_t cseclen)
else else
sendline(Checksum); sendline(Checksum);
ioctl(1, TCFLSH, 0); // ioctl(1, TCFLSH, 0);
// fflush(stdout);
if (Optiong) { if (Optiong) {
firstsec = FALSE; firstsec = FALSE;
return OK; return OK;

View File

@ -75,6 +75,12 @@ extern unsigned long rcvdbytes;
extern int zmodem_requested; extern int zmodem_requested;
/*
* Receive files with Zmodem, Ymodem or Xmodem.
* This receiver will figure out what to do, you should
* be able to send anything.
*/
int zmrcvfiles(int want1k) int zmrcvfiles(int want1k)
{ {
int rc; int rc;