Changeset 407 for PinConnection/USerialPort.pas
- Timestamp:
- Aug 14, 2012, 10:31:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PinConnection/USerialPort.pas
r404 r407 7 7 uses 8 8 Classes, SysUtils, SynaSer, StdCtrls, Dialogs, UCommon, UThreading, 9 DateUtils, FileUtil ;9 DateUtils, FileUtil, SpecializedList; 10 10 11 11 type … … 19 19 20 20 TSerialPort = class; 21 TReceiveDataEvent = procedure(Stream: T MemoryStream) of object;21 TReceiveDataEvent = procedure(Stream: TListByte) of object; 22 22 23 23 { TSerialPortReceiveThread } … … 45 45 FStopBits: TStopBits; 46 46 FReceiveThread: TSerialPortReceiveThread; 47 FReceiveBuffer: T MemoryStream;47 FReceiveBuffer: TListByte; 48 48 function GetBaudRateNumeric: Integer; 49 49 function GetName: string; … … 70 70 property RTS: Boolean read FRTS write SetRTS; 71 71 property DTR: Boolean read FDTR write SetDTR; 72 property ReceiveBuffer: T MemoryStreamread FReceiveBuffer;72 property ReceiveBuffer: TListByte read FReceiveBuffer; 73 73 74 74 property BaudRateNumeric: Integer read GetBaudRateNumeric write SetBaudRateNumeric; … … 214 214 begin 215 215 inherited Create; 216 FReceiveBuffer := T MemoryStream.Create;216 FReceiveBuffer := TListByte.Create; 217 217 FBaudRate := br9600; 218 218 FName := 'COM1'; … … 335 335 InBufferUsed: Integer; 336 336 Buffer: array of Byte; 337 Read: Integer; 337 338 begin 338 339 InBufferUsed := 0; … … 344 345 if InBufferUsed > 0 then begin 345 346 SetLength(Buffer, InBufferUsed); 346 Re cvBuffer(Buffer, Length(Buffer));347 348 Parent.FReceiveBuffer.Size := Length(Buffer); 349 Parent.FReceiveBuffer. Position := 0;350 Parent.FReceiveBuffer. Write(Buffer[0], Length(Buffer));347 Read := RecvBuffer(Buffer, Length(Buffer)); 348 SetLength(Buffer, Read); 349 350 Parent.FReceiveBuffer.Count := Length(Buffer); 351 Parent.FReceiveBuffer.ReplaceBuffer(0, PByte(Buffer)^, Length(Buffer)); 351 352 if Assigned(Parent.FOnReceiveData) then 352 353 Parent.FOnReceiveData(Parent.FReceiveBuffer);
Note:
See TracChangeset
for help on using the changeset viewer.