Protocol updates
This commit is contained in:
parent
1211cdf7fc
commit
25ec73a584
|
@ -36,6 +36,8 @@ Type
|
||||||
Queue : TProtocolQueue;
|
Queue : TProtocolQueue;
|
||||||
EndTransfer : Boolean;
|
EndTransfer : Boolean;
|
||||||
Connected : Boolean;
|
Connected : Boolean;
|
||||||
|
StatusCheck : Word;
|
||||||
|
StatusTimer : LongInt;
|
||||||
ReceivePath : String;
|
ReceivePath : String;
|
||||||
|
|
||||||
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Virtual;
|
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Virtual;
|
||||||
|
@ -44,6 +46,9 @@ Type
|
||||||
Function AbortTransfer : Boolean;
|
Function AbortTransfer : Boolean;
|
||||||
Procedure StatusUpdate (Starting, Ending: Boolean);
|
Procedure StatusUpdate (Starting, Ending: Boolean);
|
||||||
Function ReadByteTimeOut (hSec: LongInt) : SmallInt;
|
Function ReadByteTimeOut (hSec: LongInt) : SmallInt;
|
||||||
|
|
||||||
|
Procedure QueueReceive; Virtual;
|
||||||
|
Procedure QueueSend; Virtual;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
@ -62,6 +67,8 @@ Begin
|
||||||
ReceivePath := '';
|
ReceivePath := '';
|
||||||
StatusProc := NIL;
|
StatusProc := NIL;
|
||||||
AbortProc := @NoAbortProc;
|
AbortProc := @NoAbortProc;
|
||||||
|
StatusCheck := 100;
|
||||||
|
StatusTimer := 0;
|
||||||
|
|
||||||
FillChar(Status, SizeOf(Status), 0);
|
FillChar(Status, SizeOf(Status), 0);
|
||||||
End;
|
End;
|
||||||
|
@ -84,10 +91,10 @@ Begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
|
|
||||||
If Client.DataWaiting Then Begin
|
If Client.DataWaiting Then Begin
|
||||||
Connected := Client.ReadBuf(Res, 1) <> -1;
|
Connected := Client.ReadBuf(Res, 1) >= 0;
|
||||||
Result := Res;
|
Result := Res;
|
||||||
End Else
|
End Else
|
||||||
Case Client.WaitForData(HSec * 10) of
|
Case Client.WaitForData(hSec * 10) of
|
||||||
-1 : Connected := False;
|
-1 : Connected := False;
|
||||||
0 : ;
|
0 : ;
|
||||||
Else
|
Else
|
||||||
|
@ -104,4 +111,12 @@ Begin
|
||||||
AbortTransfer := EndTransfer;
|
AbortTransfer := EndTransfer;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
Procedure TProtocolBase.QueueReceive;
|
||||||
|
Begin
|
||||||
|
End;
|
||||||
|
|
||||||
|
Procedure TProtocolBase.QueueSend;
|
||||||
|
Begin
|
||||||
|
End;
|
||||||
|
|
||||||
End.
|
End.
|
||||||
|
|
|
@ -72,6 +72,7 @@ Begin
|
||||||
Assign (F, fPath + fName);
|
Assign (F, fPath + fName);
|
||||||
|
|
||||||
{$I-} Reset(F, 1); {$I+}
|
{$I-} Reset(F, 1); {$I+}
|
||||||
|
|
||||||
If IoResult = 0 Then Begin
|
If IoResult = 0 Then Begin
|
||||||
QData[QSize]^.FileSize := FileSize(F);
|
QData[QSize]^.FileSize := FileSize(F);
|
||||||
QData[QSize]^.Status := QueuePending;
|
QData[QSize]^.Status := QueuePending;
|
||||||
|
|
|
@ -5,12 +5,32 @@ Unit m_Protocol_XModem;
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
m_Protocol_Base;
|
m_Socket_Class,
|
||||||
|
m_Protocol_Base,
|
||||||
|
m_Protocol_Queue;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TProtocolXmodem = Class(TProtocolBase)
|
TProtocolXmodem = Class(TProtocolBase)
|
||||||
|
DoCRC : Boolean;
|
||||||
|
Do1K : Boolean;
|
||||||
|
|
||||||
|
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
|
||||||
|
Destructor Destroy; Override;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
End.
|
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.
|
||||||
|
|
|
@ -5,12 +5,30 @@ Unit m_Protocol_YModem;
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
Uses
|
Uses
|
||||||
|
m_Socket_Class,
|
||||||
|
m_Protocol_Queue,
|
||||||
m_Protocol_Xmodem;
|
m_Protocol_Xmodem;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TProtocolYmodem = Class(TProtocolXmodem)
|
TProtocolYmodem = Class(TProtocolXmodem)
|
||||||
|
UseG : Boolean;
|
||||||
|
|
||||||
|
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
|
||||||
|
Destructor Destroy; Override;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Implementation
|
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.
|
End.
|
|
@ -2,7 +2,7 @@ Unit m_Protocol_Zmodem;
|
||||||
|
|
||||||
{$I M_OPS.PAS}
|
{$I M_OPS.PAS}
|
||||||
|
|
||||||
{.$DEFINE ZDEBUG}
|
{$DEFINE ZDEBUG}
|
||||||
|
|
||||||
Interface
|
Interface
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@ Const
|
||||||
ZBufSize = 1024; // 1024 only maybe 8k ZEDZAP someday
|
ZBufSize = 1024; // 1024 only maybe 8k ZEDZAP someday
|
||||||
ZAttnLen = 32;
|
ZAttnLen = 32;
|
||||||
RxTimeOut : Word = 500;
|
RxTimeOut : Word = 500;
|
||||||
StatusCheck : Word = 50;
|
|
||||||
StatusTimer : LongInt = 0;
|
|
||||||
|
|
||||||
Type
|
Type
|
||||||
ZHdrType = Array[0..3] of Byte;
|
ZHdrType = Array[0..3] of Byte;
|
||||||
|
@ -49,8 +47,9 @@ Type
|
||||||
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
|
Constructor Create (Var C: TSocketClass; Var Q: TProtocolQueue); Override;
|
||||||
Destructor Destroy; Override;
|
Destructor Destroy; Override;
|
||||||
|
|
||||||
Procedure QueueReceive; Virtual;
|
Procedure QueueReceive; Override;
|
||||||
Procedure QueueSend; Virtual;
|
Procedure QueueSend; Override;
|
||||||
|
|
||||||
Function ZInitReceiver : SmallInt;
|
Function ZInitReceiver : SmallInt;
|
||||||
Function ZGetByte : SmallInt;
|
Function ZGetByte : SmallInt;
|
||||||
Function ZDLRead : SmallInt;
|
Function ZDLRead : SmallInt;
|
||||||
|
@ -80,6 +79,7 @@ Implementation
|
||||||
Const
|
Const
|
||||||
CANBRK = 4;
|
CANBRK = 4;
|
||||||
EscAll = $0040;
|
EscAll = $0040;
|
||||||
|
ZCRC = 13;
|
||||||
ZABORT = 7;
|
ZABORT = 7;
|
||||||
ZRQINIT = 0;
|
ZRQINIT = 0;
|
||||||
ZPAD = 42;
|
ZPAD = 42;
|
||||||
|
@ -843,7 +843,7 @@ Var
|
||||||
Begin
|
Begin
|
||||||
{$IFDEF ZDEBUG} ZLog(''); {$ENDIF}
|
{$IFDEF ZDEBUG} ZLog(''); {$ENDIF}
|
||||||
{$IFDEF ZDEBUG} ZLog('ZSendFile -> begin'); {$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;
|
Result := ZERROR;
|
||||||
|
|
||||||
|
@ -897,14 +897,22 @@ Begin
|
||||||
ZFIN,
|
ZFIN,
|
||||||
ZTIMEOUT : Begin
|
ZTIMEOUT : Begin
|
||||||
Close (WrkFile);
|
Close (WrkFile);
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
ZSKIP : Begin
|
ZSKIP : Begin
|
||||||
Close (WrkFile);
|
Close (WrkFile);
|
||||||
ZSendFile := ZSKIP;
|
ZSendFile := ZSKIP;
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
End;
|
End;
|
||||||
ZRPOS : Goto start;
|
ZCRC : Begin
|
||||||
|
ZPutLong(FileCRC32(Status.FilePath + Status.FileName));
|
||||||
|
ZSendHexHeader(ZCRC);
|
||||||
|
|
||||||
|
Continue;
|
||||||
|
End;
|
||||||
|
ZRPOS : Goto Start;
|
||||||
End;
|
End;
|
||||||
Until (C <> ZRINIT);
|
Until (C <> ZRINIT);
|
||||||
Until False;
|
Until False;
|
||||||
|
@ -1118,7 +1126,7 @@ Begin
|
||||||
|
|
||||||
FillChar (TxHdr, SizeOf(TxHdr), 0); // zero out all flags
|
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
|
If EscapeAll Then
|
||||||
TxHdr[ZF0] := TxHdr[ZF0] or ESCALL;
|
TxHdr[ZF0] := TxHdr[ZF0] or ESCALL;
|
||||||
|
@ -1673,4 +1681,4 @@ Begin
|
||||||
StatusUpdate(False, True);
|
StatusUpdate(False, True);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
End.
|
End.
|
Loading…
Reference in New Issue