[DUG] RFID - EAccess violation
Robo
robo555 at gmail.com
Thu May 28 00:14:13 NZST 2015
Are you able to debug which line of code the error is occuring on?
On Wed, May 27, 2015 at 1:56 PM, Marshland Engineering <
marshland at marshland.co.nz> wrote:
> I'm a bit out my depth. Is there something I have missed ?
>
> EAccess violation at address 000000000
>
> I purchased an RFID reader with sample code. I stripped out what was not
> necessary and ended up with this.
>
> Sorry for the long code
>
> **************************************************************
>
> unit Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
> ComCtrls, StdCtrls, XPMenu, ExtCtrls;
>
> type
> TForm1 = class(TForm)
> showm: TRichEdit;
> Button1: TButton;
> procedure falsereason(s:string);
> procedure bReadClick(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> function
>
> API_PCDRead(comHandle:Thandle;DeviceAddress:integer;mode:byte;add_blk,num_blk:integer;
> snr,buffer:pchar):integer;stdcall;external 'mi.dll';
>
> var
> Form1: TForm1;
> comhandle : Thandle ;
> reason:string;
> implementation
>
> {$R *.dfm}
>
> procedure TForm1.falsereason(s:string);
> begin
> if s='' then begin reason:=''; exit; end;
> if s='00' then begin reason:=''; exit ; end;
> etc
> if s='96' then begin reason:='The Operation Do Not Success....';
> exit;
> end;
> end;
>
> procedure TForm1.bReadClick(Sender: TObject);
> var
> buffer,bufferr:array [0..255] of char;
> receive,i :integer;
> keydata,cardnum,showmemo:string;
> key : pchar;
> begin
> setlength(keydata,6);
> for i:=1 to 6 do begin
> keydata[i]:=Chr(StrToInt('$FF'));
> end;
> key:=StrPCopy(buffer,keydata);
> receive:=API_PCDRead(0,0,$00,10,1,key,bufferr);
> case receive of
> 0:begin
> for i:=0 to 3 do begin
> cardnum:=cardnum+ inttohex(ord(buffer[i]),2);
> end;
> showm.Lines.Add('Number :'+cardnum);
> end;
> 1:begin
> falsereason(inttohex(ord(bufferr[0]),2));
> showm.Lines.Add(reason+#13#10);
> end
> else
> showm.Lines.Add('error,no data receive...'+#13#10);
> end;
> end;
>
> end.
> ****************************************************************
> I added the above to my code and it complies but crashes when I do a
> receive.
> EAccess
>
>
> unit uMain;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
> Forms,
> Dialogs, Grids, DBGrids, Menus, ComCtrls, StdCtrls, Printers, DBCtrls,
> Mask, ExtCtrls, IniFiles, DB, ShellAPI, XPMenu;
>
>
> type
> TfMain = class(TForm)
> pcMembers: TPageControl;
> Members: TTabSheet;
> Events: TTabSheet;
> DBGrid1: TDBGrid;
> DBGrid4: TDBGrid;
> DBGrid5: TDBGrid;
> Label3: TLabel;
> bFees: TButton;
> Button1: TButton;
> bEmail: TButton;
> dbgMembers: TDBGrid;
> Label5: TLabel;
> Label7: TLabel;
> dbgFeesMem: TDBGrid;
> dbgSubs: TDBGrid;
> Label4: TLabel;
> Label2: TLabel;
> puSubs: TPopupMenu;
> puSubsAdd: TMenuItem;
> puSubsDel: TMenuItem;
> puFeesListPrinter: TMenuItem;
> puFeesListScreen: TMenuItem;
> upFeesCardsNotSent: TMenuItem;
> PrintSet1: TPrinterSetupDialog;
> puEventFees: TPopupMenu;
> puFeesAdd: TMenuItem;
> puFeesDelete: TMenuItem;
> puFeesList: TMenuItem;
> puMembers: TPopupMenu;
> puAddMember: TMenuItem;
> puDeleteMember: TMenuItem;
> puBikes: TPopupMenu;
> puAddBike: TMenuItem;
> puDeleteBike: TMenuItem;
> dbmNotes: TDBMemo;
> Label6: TLabel;
> dbgIncident: TDBGrid;
> Label8: TLabel;
> PrintDialog1: TPrintDialog;
> puIncident: TPopupMenu;
> AddIncident1: TMenuItem;
> DeleteIncident1: TMenuItem;
> dtpMainDate: TDateTimePicker;
> DBEdit1: TDBEdit;
> Label1: TLabel;
> Label9: TLabel;
> cbMainYear: TComboBox;
> DBGrid2: TDBGrid;
> bPostFees: TButton;
> Button2: TButton;
> eCardNumber: TEdit;
> procedure dbgMembersDblClick(Sender: TObject);
> procedure FormCreate(Sender: TObject);
> procedure dbgSubsDblClick(Sender: TObject);
> procedure puSubsAddClick(Sender: TObject);
> procedure puSubsDelClick(Sender: TObject);
> procedure upFeesCardsNotSentClick(Sender: TObject);
> procedure puFeesListPrinterClick(Sender: TObject);
> procedure FormShow(Sender: TObject);
> procedure dbmNotesExit(Sender: TObject);
> procedure puFeesAddClick(Sender: TObject);
> procedure puFeesDeleteClick(Sender: TObject);
> procedure dbgFeesDblClick(Sender: TObject);
> procedure dbgMembersKeyPress(Sender: TObject; var Key: Char);
> procedure puFeesListClick(Sender: TObject);
> procedure Button1Click(Sender: TObject);
> procedure puAddMemberClick(Sender: TObject);
> procedure puDeleteMemberClick(Sender: TObject);
> procedure puAddBikeClick(Sender: TObject);
> procedure puDeleteBikeClick(Sender: TObject);
> procedure DBGrid2DblClick(Sender: TObject);
> procedure dbmNotesEnter(Sender: TObject);
> procedure puFeesListScreenClick(Sender: TObject);
> procedure bEmailClick(Sender: TObject);
> procedure DBGrid3ColExit(Sender: TObject);
> procedure dbgIncidentCellClick(Column: TColumn);
> procedure AddIncident1Click(Sender: TObject);
> procedure DeleteIncident1Click(Sender: TObject);
> procedure MembersShow(Sender: TObject);
> procedure Button2Click(Sender: TObject);
> procedure falsereason(s:string);
> private
> { Private declarations }
> public
> sKey:String;
> bFeesFirstTime:Boolean;
> end;
>
> function
>
> API_PCDRead(comHandle:Thandle;DeviceAddress:integer;mode:byte;add_blk,num_blk:integer;
> snr,buffer:pchar):integer;stdcall;external 'mi.dll';
>
> var
> fMain:TfMain;
> comhandle:Thandle ;
> Reason:String;
>
> implementation
>
> uses uDM, uMembers, uSubs, uMemCards, uEventFees, uLogon, uBikes,
> uMemoShow,
> uEmail, uIncident;
>
> {$R *.dfm}
>
> procedure TfMain.falsereason(s:string);
> begin
> if s='' then begin reason:=''; exit; end;
> if s='00' then begin reason:=''; exit ; end;
> etc
> if s='95' then begin reason:='The lock Operation Do Not Success....';
> exit; end;
> if s='96' then begin reason:='The Operation Do Not Success....';
> exit;
> end;
> end;
>
>
> ******** My other code,
>
> procedure TfMain.Button2Click(Sender: TObject);
> var
> buffer,bufferr:array [0..255] of char;
> receive,i :integer;
> keydata,cardnum,showmemo:string;
> key : pchar;
> begin
> setlength(keydata,6);
> for i:=1 to 6 do begin
> keydata[i]:=Chr(StrToInt('$FF'));
> end;
> key:=StrPCopy(buffer,keydata);
> receive:=API_PCDRead(0,0,$00,10,1,key,bufferr);
> case receive of
> 0:begin
> for i:=0 to 3 do begin
> cardnum:=cardnum+ inttohex(ord(buffer[i]),2);
> end;
> showm.Lines.Add('Number :'+cardnum);
> end;
> 1:begin
> falsereason(inttohex(ord(bufferr[0]),2));
> showm.Lines.Add(reason+#13#10);
> end
> else
> showm.Lines.Add('error,no data receive...'+#13#10);
> end;
> end;
>
> end.
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20150527/ed04356f/attachment.html
More information about the Delphi
mailing list