Products for USB Sensing and Control
It is currently Thu Apr 17, 2014 10:37 am

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Nov 18, 2008 6:14 am 
Offline
Fresh meat

Joined: Tue Nov 18, 2008 6:04 am
Posts: 3
Hi there,

I have made a time registration system using the RFID phidget, my program is based on the delphi sample code.

The problem I have is not a real problem, it's more of an annoyance..

What happens is this: I compile and run my program from within Delphi 7 Enterprise, the program then runs, I test if it's working properly with a couple rfid-tags and then exit the program via alt+f4.

Now most of the time that just closes the program and returns me to delphi so I can make further modifications, but about one in six times I run the program, when shutting it down I get an access violation.

Does anyone have an idea what can be causing this and how I can fix it?

Here's a screenshot of what happens:

ImageImage


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 10:56 am 
Offline
Site Admin

Joined: Fri Dec 05, 2003 3:45 pm
Posts: 259
Location: Canada
Can you post some code?

Chester


Top
 Profile Send private message  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 11:22 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2549
Location: Canada
do you close the reader before exiting?


Top
 Profile Send private message  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 2:20 pm 
Offline
Fresh meat

Joined: Tue Nov 18, 2008 6:04 am
Posts: 3
Yes, I have "rfid1.Close;" in my TForm1.FormCloseQuery.

Edit: here's some code, I stripped it down to bare minimum, to see if it wasn't any of my own (sql) code causing it..

Code:
unit rfid;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Phidget21COMEvents, Phidget21COM_TLB, StdCtrls, MMSystem, FMTBcd,
  ExtCtrls, jpeg, ComCtrls;

type
  TForm1 = class(TForm)
    Phidget21COMIPhidgetRFIDEvents1: TPhidget21COMIPhidgetRFIDEvents;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure Phidget21COMIPhidgetRFIDEvents1TagLost(Sender: TObject; const TagNumber: WideString);
    procedure Phidget21COMIPhidgetRFIDEvents1Detach(Sender: TObject);
    procedure Phidget21COMIPhidgetRFIDEvents1Attach(Sender: TObject);
    procedure Phidget21COMIPhidgetRFIDEvents1Tag(Sender: TObject; const TagNumber: WideString);
    procedure FormCreate(Sender: TObject);
    procedure UpdateTime(Sender: TObject);
    procedure ExitClick(Sender: TObject);
    procedure hudTagTimer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  rfid1 : IPhidgetRFID;
  MyManager : IPhidgetManager;
  beepsnd : PChar;
  beepsndc : PChar;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
    BorderStyle := bsNone;
    WindowState := wsMaximized;
    ShowCursor(false);
    beepsnd := PChar('chip-beep.wav');
    beepsndc := PChar('chip-beep-cancel1.wav');

    hudUser.Top := 194;
    hudUser.Left := 162;

    hudTag.Top := 326;
    hudTag.Left := 281;

    rfTime.Caption := FormatDateTime('yyy-mm-dd / hh:mm', Now);
   
    rfid1:=CoPhidgetRfid.Create;
    Phidget21COMIPhidgetRFIDEvents1.Connect(rfid1);
    rfid1.Open(-1);

    Form1.DoubleBuffered := true;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  ShowCursor(true);
  rfid1.AntennaOn := false;
  rfid1.LEDOn := false;
  rfid1.OutputState[1] := false;
  rfid1.OutputState[0] := false;
  rfid1.Close();
  CanClose := true;
end;

procedure TForm1.Phidget21COMIPhidgetRFIDEvents1Tag(Sender: TObject; const TagNumber: WideString);
var
  tagUser: string;
begin
  PlaySound(beepsnd, 0, SND_ASYNC);
  rfid1.LEDOn := true;
  rfid1.OutputState[1] := true;
  tagTimeout.Enabled := true;
end;

procedure TForm1.Phidget21COMIPhidgetRFIDEvents1TagLost(Sender: TObject; const TagNumber: WideString);
begin
  rfid1.LEDOn := false;
  rfid1.OutputState[1] := false;
  LTimeout.Caption := '3';
end;

procedure TForm1.Phidget21COMIPhidgetRFIDEvents1Attach(Sender: TObject);
begin
  rfSerial.Caption := String(rfid1.DeviceType+' verbonden. Serienummer #'+IntToStr(rfid1.SerialNumber));
  rfSerialShade.Caption := rfSerial.Caption;
  rfid1.AntennaOn := true;
  rfid1.LEDOn := false;
  rfid1.OutputState[1] := false;
  rfid1.OutputState[0] := false;
end;

procedure TForm1.Phidget21COMIPhidgetRFIDEvents1Detach(Sender: TObject);
begin
  rfSerial.Caption := String(rfid1.DeviceType+' losgekoppeld. Serienummer #'+IntToStr(rfid1.SerialNumber));
  rfSerialShade.Caption := rfSerial.Caption;
end;

procedure TForm1.UpdateTime(Sender: TObject);
begin
  rfTime.Caption := FormatDateTime('yyy-mm-dd / hh:mm', Now);
  rfTimeShade.Caption := rfTime.Caption;
end;

procedure TForm1.hudTagTimer(Sender: TObject);
begin
  LTimeout.Caption := IntToStr(StrToInt(LTimeout.Caption) - 1);
  if LTimeout.Caption = '0' then
  begin
    tagTimeout.Enabled := false;
    PlaySound(beepsndc, 0, SND_ASYNC);
  end;

 
end;

end.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 4:05 am 
Offline
Fresh meat

Joined: Tue Nov 18, 2008 6:04 am
Posts: 3
Anothing thing I noticed is an excessive amount of registry activity, namely 2500 registry openkey/querykey/closekey events in 10 seconds, is that normal?

Log here: http://www.hastings.nl/dropbox/Regmon-phidget-log.txt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 10:46 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2549
Location: Canada
Yes, that is normal - it is the library looking for device attaches / detaches.

-Patrick


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group