Zmodem fixes

This commit is contained in:
mysticbbs 2013-02-17 17:36:57 -05:00
parent 95b48236cd
commit b4d47f0fca
1 changed files with 21 additions and 8 deletions

View File

@ -199,7 +199,7 @@ Begin
Status.Protocol := 'Zmodem'; Status.Protocol := 'Zmodem';
LastSent := 0; LastSent := 0;
EscapeAll := False; EscapeAll := True;
Attn := ''; Attn := '';
End; End;
@ -517,7 +517,7 @@ Begin
LastSent := B XOR $40; LastSent := B XOR $40;
End; End;
13, 13,
13 OR $80 : If {EscapeAll And} (LastSent AND $7F = Ord('@')) Then Begin 13 OR $80 : If EscapeAll And (LastSent AND $7F = Ord('@')) Then Begin
Client.BufWriteChar(Char(ZDLE)); Client.BufWriteChar(Char(ZDLE));
LastSent := B XOR $40; LastSent := B XOR $40;
End Else End Else
@ -528,7 +528,7 @@ Begin
End; End;
Else Else
If {(EscapeAll) and} ((B AND $60) = 0) Then Begin If (EscapeAll) and ((B AND $60) = 0) Then Begin
Client.BufWriteChar(Char(ZDLE)); Client.BufWriteChar(Char(ZDLE));
LastSent := B XOR $40; LastSent := B XOR $40;
End Else End Else
@ -764,6 +764,10 @@ Splat:
C := ZGetByte; C := ZGetByte;
{$IFDEF ZDEBUG}
ZLog ('ZGetHeader -> Checking Frame Index: ' + HeaderType(C));
{$ENDIF}
Case C of Case C of
RCDO, RCDO,
ZTIMEOUT: Goto Finished; ZTIMEOUT: Goto Finished;
@ -1354,7 +1358,7 @@ Var
Begin Begin
RxCount := 0; RxCount := 0;
{$IFDEF ZDEBUG} ZLog('ZReceiveData -> begin'); {$ENDIF} {$IFDEF ZDEBUG} ZLog('ZReceiveData -> begin (frameindex=' + HeaderType(RxFrameIdx) + ')'); {$ENDIF}
If RxFrameIdx = ZBIN32 Then Begin If RxFrameIdx = ZBIN32 Then Begin
ulCRC := LongInt($FFFFFFFF); ulCRC := LongInt($FFFFFFFF);
@ -1467,7 +1471,9 @@ ErrorCRC16:
End; End;
End; End;
{$IFDEF ZDEBUG} ZLog('ZReceiveData -> Long packet (frameidx=' + HeaderType(RxFrameIdx) + '; rxcount=' + strI2S(RxCount) + ')'); {$ENDIF} {$IFDEF ZDEBUG}
ZLog('ZReceiveData -> Long packet (frameidx=' + HeaderType(RxFrameIdx) + '; rxcount=' + strI2S(RxCount));
{$ENDIF}
ZReceiveData := ZERROR; ZReceiveData := ZERROR;
End; End;
@ -1478,6 +1484,7 @@ Label
MoreData; MoreData;
Var Var
Tmp : SmallInt; Tmp : SmallInt;
Str : String;
FName : String; FName : String;
FSize : LongInt; FSize : LongInt;
RetryCount : SmallInt; RetryCount : SmallInt;
@ -1487,7 +1494,7 @@ Begin
{$IFDEF ZDEBUG} ZLog('ZRecvFile -> begin'); {$ENDIF} {$IFDEF ZDEBUG} ZLog('ZRecvFile -> begin'); {$ENDIF}
FName := ''; FName := '';
FSize := 0; Str := '';
RxBytes := 0; RxBytes := 0;
Tmp := 0; Tmp := 0;
@ -1500,11 +1507,15 @@ Begin
FName := JustFile(strStripB(FName, ' ')); FName := JustFile(strStripB(FName, ' '));
Inc (Tmp); Inc (Tmp);
While (RxBuf[Tmp] <> $20) and (RxBuf[Tmp] <> 0) Do Begin
FSize := (FSize * 10) + RxBuf[Tmp] - $30; While (RxBuf[Tmp] <> 32) and (RxBuf[Tmp] <> 0) Do Begin
Str := Str + Char(RxBuf[Tmp]);
// FSize := (FSize * 10) + RxBuf[Tmp] - $30;
Inc (Tmp); Inc (Tmp);
End; End;
FSize := strS2I(Str);
{$IFDEF ZDEBUG} ZLog('ZRecvFile -> File:' + FName); {$ENDIF} {$IFDEF ZDEBUG} ZLog('ZRecvFile -> File:' + FName); {$ENDIF}
{$IFDEF ZDEBUG} ZLog('ZRecvFile -> Size:' + strI2S(FSize)); {$ENDIF} {$IFDEF ZDEBUG} ZLog('ZRecvFile -> Size:' + strI2S(FSize)); {$ENDIF}
@ -1586,6 +1597,8 @@ Begin
ZPutLong (RxBytes); ZPutLong (RxBytes);
ZSendBinaryHeader (ZRPOS); ZSendBinaryHeader (ZRPOS);
// purge input here?
NextHeader: NextHeader:
C := ZGetHeader(RxHdr); C := ZGetHeader(RxHdr);