AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Problem: Format %p ungültig o. nicht kompatibel mit Argument
Thema durchsuchen
Ansicht
Themen-Optionen

Problem: Format %p ungültig o. nicht kompatibel mit Argument

Ein Thema von carknue · begonnen am 20. Aug 2005 · letzter Beitrag vom 20. Aug 2005
 
carknue

Registriert seit: 26. Mai 2005
37 Beiträge
 
Turbo Delphi für Win32
 
#1

Problem: Format %p ungültig o. nicht kompatibel mit Argument

  Alt 20. Aug 2005, 14:27
Ich programmiere ein kleines Freeware Tool, welches die Ansteuerung von verschiedenen Radios übernimmt. Nun bin ich bei einem neuen Empfänger, der per dll angesteuert wird auf ein merkwürdiges Problem gestoßen, welches ich mir nicht erkären kann. Mein Problem ist, dass ich bei einem Aufruf einer Funktion aus dieser externen dll eine EConvertError '%P' Exception bekomme. Die Exception bekomme ich nur, wenn ich das Programm über die IDE(Delphi 6) laufenlasse. Starte ich direkt die exe, gibt es ohne error Behandlung im Programm nur die Meldung "Format %p ungültig o. nicht kompatibel mit Argument" Diese läßt sich mit OK wegklicken und es läuft einwandfrei weiter, auch die Funktion wurde korrekt ausgeführt. Aber dies passiert nur, wenn ich diese Funktion aus bestimmten Proceduren meines Programms aufrufe. Hier zu erstmal die C++ Header Datei mit dem Funktionaufruf für die dll. Es geht um die Funktion FrontendSetMode aus der dll. Der Aufruf innerhalb meiner "procedure TForm1.checkaorClick(Sender: TObject)" funktioniert ohne Probleme, rufe ich sie allerdings mit den gleichen Parametern über meine "Procedure Tform1.SetDWTMode(mode: smallint)" auf, so kommt der Format Fehlermeldung. Jetzt kommt dass, was ich überhaupt nicht verstehe, denn wenn ich die Funktion in meiner "procedure Tform1.SetFreq(freq: string)" aufrufe, kommt keine Fehlermeldung. Und wenn ich, wie in "procedure TForm1.Button4Click(Sender: TObject)" die Exception abfangen will, wird das Programm ander Stelle ohne Meldung geschlossen. Wer weiß Rat?


Zitat:
/*! Frontend error codes, all values not listed are RFU */
typedef enum _tFrontendError
{
eFrontendOk = 0, /*!< no error */
eFrontendErrorNotInitialized = -1, /*!< DLL not initialized (call FrontendOpen() first */
eFrontendErrorReceiverDisconnected = -2, /*!< receiver is not connected to the PC */
eFrontendErrorInvalidParameter = -3, /*!< parameter for the command was invalid */
eFrontendErrorCommandFailure = -4, /*!< command was not executed */
} tFrontendError;



/*! Frontend modes, all values not listed are RFU */
typedef enum _tFrontendMode
{
eFrontendModeUndefined = 0, /*!< undefined/unknown mode */
eFrontendModeDrm = 1, /*!< mode for DRM demodulation */
eFrontendModeAm = 2, /*!< mode for AM demodulation */
eFrontendModeFm = 6, /*!< mode for FM demodulation */
} tFrontendMode

/* ################################################## ################################################ */


/*! open Frontend, called once on startup; to recover from an error FrontendClose
* followed by a further FrontendOpen will be called
*
* \return <0 error, see _tFrontendError, >0 API Version see cFrontendApiVersion
*/
FRONTEND_API
short
FRONTEND_API_CALL
FrontendOpen(void);



/*! close Frontend, called on shutdown of the receiver or while recovering from errors
*
* \return 0 = no error, <0 error see _tFrontendError
*/
FRONTEND_API
short
FRONTEND_API_CALL
FrontendClose(void);

/*! set frontend mode
* \param mode set frontend to the given mode
* \return 0 = no error, <0 error, see _tFrontendError
*/
FRONTEND_API
short
FRONTEND_API_CALL
FrontendSetMode(tFrontendMode mode);


/*! set frontend to the given frequency in Hz
* \param freq frequency in Hz
* the allowed intervals are 150000 .. 29999000 for DRM/AM, and 87500000 .. 108000000 for FM
* \return 0 = no error, <0 error, see _tFrontendError
*/
FRONTEND_API
short
FRONTEND_API_CALL
FrontendSetFrequency(double freq);
Hier der relevante Code meines Programms

Delphi-Quellcode:
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, sndkey32, StdCtrls, ComCtrls, ExtCtrls, inifiles, DateUtils,
  CPort, CPortCtl, Grids, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP, Menus;

type
  TForm1 = class(TForm)
    
    Procedure SetDWTMode(mode: smallint);
    procedure SetFreq(freq: string);
    procedure dwtmodClick(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure checkaorClick(Sender: TObject);
    
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  
  dwt: smallint;

  FrontendOpen: function(): Integer; stdcall;
  FrontendClose: function(): Integer; stdcall;
  FrontendSetFrequency: function(freq: double): smallint; stdcall;
  FrontendSetMode: function(mode: smallint): smallint; stdcall;
  FrontendSetAntennaMode: function(n: smallint): smallint; stdcall;

implementation

{$R *.dfm}

Procedure Tform1.SetDWTMode(mode: smallint);
begin
if mode=1 then FrontendSetMode(1);
if mode=2 then FrontendSetMode(2);
if mode=6 then FrontendSetMode(6);
end;

procedure Tform1.SetFreq(freq: string);
var rfreq: integer;
    dwtfreq:double;

begin

 rfreq:=strtoint(freq);
 if (rfreq > 150) and (rfreq < 29999) then
 begin
 edit1.Text:=freq;
 if cbrx.ItemIndex=10 then
 begin
 dwtfreq:=rfreq*1000;
 dwt:=FrontendSetFrequency(dwtfreq);
 label2.Caption:=inttostr(dwt);
 end
end
end;

procedure TForm1.checkaorClick(Sender: TObject);

 begin
   ShowMessage('Be sure that the DWT application is not running anymore!');
   Dll:=LoadLibrary('afgusbfe.dll');
   dwt:=69;

   if (Dll=0) then ShowMessage('afgusbfe.dll not found !')
   else begin
    FrontendOpen:=GetProcAddress(dll,'FrontendOpen');
    FrontendClose:=GetProcAddress(dll,'FrontendClose');
    FrontendSetFrequency:=GetProcAddress(dll,'FrontendSetFrequency');
    FrontendSetMode:=GetProcAddress(dll,'FrontendSetMode');
    FrontendSetAntennaMode:=GetProcAddress(dll,'FrontendSetAntennaMode');

     dwt:=FrontendOpen;
     label2.Caption:=inttostr(dwt);
     dwt:=FrontendSetFrequency(3995000);
     label2.Caption:=inttostr(dwt);
     dwt:=FrontendSetMode(1);
     label2.Caption:=inttostr(dwt);
     ShowMessage('1');
     dwt:=FrontendSetMode(2);
     label2.Caption:=inttostr(dwt);
     ShowMessage('2');
     dwt:=FrontendSetMode(6);
     label2.Caption:=inttostr(dwt);
     ShowMessage('6');
   end;
 end;

procedure TForm1.dwtmodClick(Sender: TObject);
begin
 if dwtmod.ItemIndex=0 then SetDWTMode(1);
 if dwtmod.ItemIndex=1 then SetDWTMode(2);
 if dwtmod.ItemIndex=2 then SetDWTMode(6);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
try
FrontendSetMode(6);
except
on EConvertError do
begin
label2.Caption:='Error';
end;
end;
end;

end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz