各位大蝦幫幫忙,有知道怎麽讀取RFID數據的嗎?
我是要通過COM口來讀取數據.
現在發現一個問題就是我在連接好COM口的關態下接通電源和RFID連上可讀出一次數據,但之後就讀不出來.
只有在斷來電源再接通電源後又可以讀出一次數據.
知道這是為什麽嗎?還是在通過什麽命令來再次接收呢?
我有看說明文檔,但是我通過COM口傳入命令RFID沒有什麽反應.
我附上說明檔,我用的是那ASCII.PDF方式的.
知道的大蝦們看看,急呀!
下面是我寫DELPHI的源代碼.
unit RFID_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, CPort, StdCtrls, ExtCtrls;
type
TRFID_Frm = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
Button1: TButton;
Label1: TLabel;
E_INPUT: TEdit;
ComPort1: TComPort;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ComPort1RxChar(Sender: TObject; Count: Integer);
procedure E_INPUTKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
RFID_Frm: TRFID_Frm;
implementation
{$R *.dfm}
procedure TRFID_Frm.Button2Click(Sender: TObject);
begin
try
ComPort1.Close;
ComPort1.ShowSetupDialog;
ComPort1.Open;
E_INPUT.SetFocus;
except
end;
end;
procedure TRFID_Frm.FormShow(Sender: TObject);
begin
E_INPUT.SetFocus;
ComPort1.Open;
end;
procedure TRFID_Frm.Button1Click(Sender: TObject);
var
vStr: string;
begin
try
vStr := Trim(E_INPUT.Text);
ComPort1.WriteStr(vStr);
E_INPUT.SetFocus;
E_INPUT.SelectAll;
except
end;
end;
procedure TRFID_Frm.ComPort1RxChar(Sender: TObject; Count: Integer);
var
vStr: string;
begin
try
vStr := '';
if Comport1.Connected then
begin
sleep(300);
Comport1.ReadStr(vStr, 1024);
end;
if trim(vStr) <> '' then
memo1.Lines.Add(vStr);
except
on e: exception do
begin
memo1.Lines.Add('Read Com Data Error:' + e.Message);
end;
end;
end;
procedure TRFID_Frm.E_INPUTKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
Button1Click(nil);
end;
end.
[此贴子已经被作者于2007-5-9 17:23:27编辑过]