A
Andy_chen
Unregistered / Unconfirmed
GUEST, unregistred user!
简单的串口程序,使用线程对串口进行扫描。用一个按钮“receive”接收数据。
procedure TportForm.receiveButtonClick(Sender: TObject);
begin
if Thread1Active = false then
begin
ReceiveThread1.Create(false);// := TReceiveThread.Create(true);
Thread1Active := true;
end;
end;
Thread1Active :为全局变量
ReceiveThread1:TReceieveThread
线程中使用循环
while (not Terminated)and truedo
begin
sleep(80);
i := sio_read(port,@receivedata[0],n);
if i >= 0 then
begin
s := ansistring(receivedata);
portform.Memo1.Lines.Add(s);
end;
为何运行会出错
procedure TportForm.receiveButtonClick(Sender: TObject);
begin
if Thread1Active = false then
begin
ReceiveThread1.Create(false);// := TReceiveThread.Create(true);
Thread1Active := true;
end;
end;
Thread1Active :为全局变量
ReceiveThread1:TReceieveThread
线程中使用循环
while (not Terminated)and truedo
begin
sleep(80);
i := sio_read(port,@receivedata[0],n);
if i >= 0 then
begin
s := ansistring(receivedata);
portform.Memo1.Lines.Add(s);
end;
为何运行会出错