⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comm485.pas

📁 主要提供delphi 5与单片机通讯的源码及定义的通讯协议
💻 PAS
字号:
unit Comm485;

interface

uses
  Classes,Sysutils,dbtables;

type
  COMTHread = class(TThread)
  private
    AData:word;
  protected
    procedure Execute; override;
    procedure SetData(A:word);
  public
     property Data:word read AData write SetData;
  end;

implementation
uses MainRS232;

{ Important: Methods and properties of objects in VCL can only be used in a
  method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure COMTHread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ COMTHread }

procedure COMTHread.Execute;
var
  ww:byte;
  ss:string;
  count,cn:integer;
  tbl:TTable;
begin
  { Place thread code here }
  AData:=$2f8;
  count:=0;
  cn:=0;
  tbl:=TTable.Create(nil);
  tbl.DatabaseName:='temp';
  tbl.TableName:='temp.db';
  tbl.Open;
  while true do
  begin
  asm
    mov dx,$2f8+5
    in al,dx
    and al,$21
    mov ww,al
  end;
  if ww=$21 then
  begin
  asm
     mov dx,$2f8
     in al,dx
     mov ww,al
  end;
  inc(count);
  if count=1 then
  begin
    if ww=175 then
    begin
       ss:=IntToStr(ww);
    end
    else
    begin
      count:=0;
    end;
  end
  else if (count=7) then
  begin
     count:=0;
     inc(cn);
     ss:=ss+'           '+IntToStr(ww);
     if Assigned(frmMain.memoSend) then
     frmMain.memoSend.lines.Add(ss+'   '+inttostr(cn));
     //beep;
     with tbl do
     begin
         append;
         fieldByName('SS').Asstring:=ss+'   '+inttostr(cn);
         post;
     end;
  end
  else // if b then
  begin
    ss:=ss+'          '+IntToStr(ww);
  end;

  end;
  end;
  tbl.Close;
  tbl.Free;
end;

procedure COMTHread.SetData(A: word);
begin
  // if AData=A then exit;
  // AData:=A;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -