Last change
on this file was 10, checked in by chronos, 2 months ago |
- Modified: Improved serial console handling.
|
File size:
870 bytes
|
Line | |
---|
1 | unit FormConsole;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
|
---|
7 | Device, Serial;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormConsole }
|
---|
12 |
|
---|
13 | TFormConsole = class(TFormDevice)
|
---|
14 | Memo1: TMemo;
|
---|
15 | Timer1: TTimer;
|
---|
16 | procedure Timer1Timer(Sender: TObject);
|
---|
17 | private
|
---|
18 | FSerial: TSerial;
|
---|
19 | procedure SetSerial(AValue: TSerial);
|
---|
20 | public
|
---|
21 | property Serial: TSerial read FSerial write SetSerial;
|
---|
22 | end;
|
---|
23 |
|
---|
24 |
|
---|
25 | implementation
|
---|
26 |
|
---|
27 | {$R *.lfm}
|
---|
28 |
|
---|
29 | procedure TFormConsole.Timer1Timer(Sender: TObject);
|
---|
30 | begin
|
---|
31 | Memo1.Lines.Text := Memo1.Lines.Text + FSerial.ReadOutputBuffer;
|
---|
32 | end;
|
---|
33 |
|
---|
34 | procedure TFormConsole.SetSerial(AValue: TSerial);
|
---|
35 | begin
|
---|
36 | if FSerial = AValue then Exit;
|
---|
37 | if Assigned(FSerial) then begin
|
---|
38 | FSerial.OnOutput := nil;
|
---|
39 | end;
|
---|
40 | FSerial := AValue;
|
---|
41 | if Assigned(FSerial) then begin
|
---|
42 | Memo1.Lines.Text := FSerial.ReadOutputBuffer;
|
---|
43 | end;
|
---|
44 | end;
|
---|
45 |
|
---|
46 | end.
|
---|
47 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.