unit uRS232BAR;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Timer1: TTimer;
Button1: TButton;
ScrollBar1: TScrollBar;
ProgressBar1: TProgressBar;
Label1: TLabel;
Edit2: TEdit;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
ch : integer;
Fehler : integer;
implementation
{$R *.DFM}
procedure OPENCOM(S:PCHAR) ;
stdcall;
external '
PORT.DLL';
function READBYTE : Integer ;
stdcall;
external '
PORT.DLL';
procedure TForm1.FormCreate(Sender: TObject);
begin
OpenCom (Pchar('
COM1:4800,n,8,1'));
ProgressBar1.Max := 255;
Form1.Caption := '
RS232BAR';
ScrollBar1.Min := 1;
// 1ms
ScrollBar1.Position := 10;
// 10ms
Timer1.Interval := ScrollBar1.Position;
Button1.Caption := '
Clear';
Label1.Caption := '
Samplerate: '+IntToStr(Timer1.Interval)+'
ms';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Edit1.Clear;
repeat ch := ReadByte
until ch=13;
repeat
ch := ReadByte;
Edit1.Text := Edit1.Text+chr(ch);
until ch=13;
try
ProgressBar1.Position := StrToInt(copy(Edit1.Text,7,3));
//Edit2.Text := copy(Edit1.Text,7,3);
except
inc (Fehler);
Edit2.Text := '
Fehler: '+IntToStr(Fehler);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Clear;
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
Timer1.Interval := ScrollBar1.Position;
Label1.Caption := '
Samplerate: '+IntToStr(Timer1.Interval)+'
ms';
end;
end.