Changeset 407 for PinConnection/UCommSerialPort.pas
- Timestamp:
- Aug 14, 2012, 10:31:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/UCommSerialPort.pas
r288 r407 6 6 7 7 uses 8 Classes, USerialPort, UCommPin, SysUtils, DateUtils, 8 Classes, USerialPort, UCommPin, SysUtils, DateUtils, SpecializedList, 9 9 SyncObjs; 10 10 … … 15 15 TCommSerialPort = class(TSerialPort) 16 16 private 17 procedure Receive(Sender: TCommPin; Stream: T Stream);17 procedure Receive(Sender: TCommPin; Stream: TListByte); 18 18 procedure SetStatus(Sender: TCommPin; AValue: Integer); 19 procedure ReceiveData(Stream: T MemoryStream);19 procedure ReceiveData(Stream: TListByte); 20 20 public 21 21 Lock: TCriticalSection; … … 31 31 { TCommSerialPort } 32 32 33 procedure TCommSerialPort.ReceiveData(Stream: T MemoryStream);33 procedure TCommSerialPort.ReceiveData(Stream: TListByte); 34 34 begin 35 35 if Active then Pin.Send(Stream); … … 64 64 end; 65 65 66 procedure TCommSerialPort.Receive(Sender: TCommPin; Stream: TStream); 66 procedure TCommSerialPort.Receive(Sender: TCommPin; Stream: TListByte); 67 var 68 S: TMemoryStream; 67 69 begin 68 if Active then begin 69 Stream.Position := 0; 70 repeat 71 try 72 Lock.Acquire; 73 if CanWrite(0) then 74 SendStreamRaw(Stream); 75 finally 76 Lock.Release; 77 end; 78 if Stream.Position <> Stream.Size then 79 Sleep(1); 80 until Stream.Position = Stream.Size; 70 try 71 S := TMemoryStream.Create; 72 Stream.WriteToStream(S); 73 if Active then begin 74 S.Position := 0; 75 repeat 76 try 77 Lock.Acquire; 78 if CanWrite(0) then 79 SendStreamRaw(S); 80 finally 81 Lock.Release; 82 end; 83 if S.Position <> S.Size then 84 Sleep(1); 85 until S.Position = S.Size; 86 end; 87 finally 88 S.Free; 81 89 end; 82 90 end;
Note:
See TracChangeset
for help on using the changeset viewer.