Ignore:
Timestamp:
Aug 7, 2024, 12:12:42 AM (2 months ago)
Author:
chronos
Message:
  • Modified: Improved serial console handling.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/Forms/FormConsole.pas

    r5 r10  
    44
    55uses
    6   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Device;
     6  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
     7  Device, Serial;
    78
    89type
     
    1213  TFormConsole = class(TFormDevice)
    1314    Memo1: TMemo;
     15    Timer1: TTimer;
     16    procedure Timer1Timer(Sender: TObject);
     17  private
     18    FSerial: TSerial;
     19    procedure SetSerial(AValue: TSerial);
    1420  public
    15     procedure ConsoleWrite(Data: Byte);
     21    property Serial: TSerial read FSerial write SetSerial;
    1622  end;
    1723
     
    2127{$R *.lfm}
    2228
    23 procedure TFormConsole.ConsoleWrite(Data: Byte);
     29procedure TFormConsole.Timer1Timer(Sender: TObject);
    2430begin
    25   Memo1.Lines.Text := Memo1.Lines.Text + Chr(Data);
     31  Memo1.Lines.Text := Memo1.Lines.Text + FSerial.ReadOutputBuffer;
     32end;
     33
     34procedure TFormConsole.SetSerial(AValue: TSerial);
     35begin
     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;
    2644end;
    2745
Note: See TracChangeset for help on using the changeset viewer.