Protocol updates

This commit is contained in:
mysticbbs 2012-08-11 12:50:14 -04:00
parent 1211cdf7fc
commit 25ec73a584
5 changed files with 75 additions and 13 deletions

View File

@ -36,6 +36,8 @@ Type
Queue : TProtocolQueue;
EndTransfer : Boolean;
Connected : Boolean;
StatusCheck : Word;
StatusTimer : LongInt;
ReceivePath : String;
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Virtual;
@ -44,6 +46,9 @@ Type
Function AbortTransfer : Boolean;
Procedure StatusUpdate (Starting, Ending: Boolean);
Function ReadByteTimeOut (hSec: LongInt) : SmallInt;
Procedure QueueReceive; Virtual;
Procedure QueueSend; Virtual;
End;
Implementation
@ -62,6 +67,8 @@ Begin
ReceivePath := '';
StatusProc := NIL;
AbortProc := @NoAbortProc;
StatusCheck := 100;
StatusTimer := 0;
FillChar(Status, SizeOf(Status), 0);
End;
@ -84,10 +91,10 @@ Begin
Result := -1;
If Client.DataWaiting Then Begin
Connected := Client.ReadBuf(Res, 1) <> -1;
Connected := Client.ReadBuf(Res, 1) >= 0;
Result := Res;
End Else
Case Client.WaitForData(HSec * 10) of
Case Client.WaitForData(hSec * 10) of
-1 : Connected := False;
0 : ;
Else
@ -104,4 +111,12 @@ Begin
AbortTransfer := EndTransfer;
End;
Procedure TProtocolBase.QueueReceive;
Begin
End;
Procedure TProtocolBase.QueueSend;
Begin
End;
End.

View File

@ -72,6 +72,7 @@ Begin
Assign (F, fPath + fName);
{$I-} Reset(F, 1); {$I+}
If IoResult = 0 Then Begin
QData[QSize]^.FileSize := FileSize(F);
QData[QSize]^.Status := QueuePending;

View File

@ -5,12 +5,32 @@ Unit m_Protocol_XModem;
Interface
Uses
m_Protocol_Base;
m_Socket_Class,
m_Protocol_Base,
m_Protocol_Queue;
Type
TProtocolXmodem = Class(TProtocolBase)
DoCRC : Boolean;
Do1K : Boolean;
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
Destructor Destroy; Override;
End;
Implementation
Constructor TProtocolXmodem.Create (Var C: TSocketClass; Var Q: TProtocolQueue);
Begin
Inherited Create(C, Q);
DoCRC := True;
Do1K := True;
End;
Destructor TProtocolXmodem.Destroy;
Begin
Inherited Destroy;
End;
End.

View File

@ -5,12 +5,30 @@ Unit m_Protocol_YModem;
Interface
Uses
m_Socket_Class,
m_Protocol_Queue,
m_Protocol_Xmodem;
Type
TProtocolYmodem = Class(TProtocolXmodem)
UseG : Boolean;
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
Destructor Destroy; Override;
End;
Implementation
Constructor TProtocolYModem.Create (Var C: TSocketClass; Var Q: TProtocolQueue);
Begin
Inherited Create(C, Q);
UseG := False;
End;
Destructor TProtocolYModem.Destroy;
Begin
Inherited Destroy;
End;
End.

View File

@ -2,7 +2,7 @@ Unit m_Protocol_Zmodem;
{$I M_OPS.PAS}
{.$DEFINE ZDEBUG}
{$DEFINE ZDEBUG}
Interface
@ -21,8 +21,6 @@ Const
ZBufSize = 1024; // 1024 only maybe 8k ZEDZAP someday
ZAttnLen = 32;
RxTimeOut : Word = 500;
StatusCheck : Word = 50;
StatusTimer : LongInt = 0;
Type
ZHdrType = Array[0..3] of Byte;
@ -49,8 +47,9 @@ Type
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
Destructor Destroy; Override;
Procedure QueueReceive; Virtual;
Procedure QueueSend; Virtual;
Procedure QueueReceive; Override;
Procedure QueueSend; Override;
Function ZInitReceiver : SmallInt;
Function ZGetByte : SmallInt;
Function ZDLRead : SmallInt;
@ -80,6 +79,7 @@ Implementation
Const
CANBRK = 4;
EscAll = $0040;
ZCRC = 13;
ZABORT = 7;
ZRQINIT = 0;
ZPAD = 42;
@ -843,7 +843,7 @@ Var
Begin
{$IFDEF ZDEBUG} ZLog(''); {$ENDIF}
{$IFDEF ZDEBUG} ZLog('ZSendFile -> begin'); {$ENDIF}
{$IFDEF ZDEBUG} ZLog('ZSendFile -> file:' + Queue^.QData[Queue^.QPos]^.FName); {$ENDIF}
{$IFDEF ZDEBUG} ZLog('ZSendFile -> file:' + Queue.QData[Queue.QPos].FileName); {$ENDIF}
Result := ZERROR;
@ -897,14 +897,22 @@ Begin
ZFIN,
ZTIMEOUT : Begin
Close (WrkFile);
Exit;
End;
ZSKIP : Begin
Close (WrkFile);
ZSendFile := ZSKIP;
Exit;
End;
ZRPOS : Goto start;
ZCRC : Begin
ZPutLong(FileCRC32(Status.FilePath + Status.FileName));
ZSendHexHeader(ZCRC);
Continue;
End;
ZRPOS : Goto Start;
End;
Until (C <> ZRINIT);
Until False;
@ -1118,7 +1126,7 @@ Begin
FillChar (TxHdr, SizeOf(TxHdr), 0); // zero out all flags
TxHdr[ZF0] := CANFDX OR CANOVIO OR CANFC32 {OR CANBRK};
TxHdr[ZF0] := CANFDX OR CANOVIO OR CANFC32 OR CANBRK;
If EscapeAll Then
TxHdr[ZF0] := TxHdr[ZF0] or ESCALL;