PDA

View Full Version : Writing my DLL, API parameter passing problem



netserv
01-30-2015, 11:49 AM
Hi Jean Luc !

I have a small problem with the API, in my dll.

when i want to pass a switch event, calling back the switch routine, i get an error message from hardware connect. "there was an error.... in FastTimer"

Maybe i do not have a correct entry point for the switch routine. But i think not. The message comes from your Hardare Connect routine, I guess.
Probably there are invalid parameters passed. I realized this in C++ (visual studio) All seems to work fine with hardware connect, except this.

I think it could be a question of parameter transfer, maybe there is a different notation for Pascal necessary?


at startup I get the procedure address as documented with:

SW_PROC = proc;


then i call SW_PROC inside the fastTimer routine as below:

int __stdcall FastTimer(void)
{
int inptCodeNr;
int inptValue;
int inptType;

devicelib::funcs::USB_Poll(&inptType, &inptCodeNr, &inptValue);
if (inCodeNr)
{
// got new data
if (inptType==MOD_DIGITAL)
{
// send data to switch input routine
SW_PROC(inCodeNr,inValue); // <----- here is the problem


}
}
}

Question: is the 'int' parameter in this case expected as signed or as unsigned?
So this is C++, maybe Pascal expects parameter passing in a different way.....
Also tried to pass constants, same effect.
any idea?

Guenther
http://a320.at

jeehell
01-31-2015, 11:11 AM
Hi,

The SW_PROC parameter are signed 32bits integers.
The message you get could mean that your fastimer procedure is taking too much time to run, and causes a crash when the next cycle arrives. This could mean it is a better idea to call the SW_PROC out of the fasttimer procedure, and use only the fasttimer for timing references.
Also, make sure the SW_PROC is using stdcall declaration convention.


JL

netserv
02-03-2015, 04:48 PM
thanks a lot Jena Luc!

Solved it. I am running an extra worker thread now, just for polling USB devices and all is runnig fine.

Just one more small question: I exprienced that the "Start" procedure is called from Hardware Connect only when I click "reset hardware" before. Should'nt it do this at startup automatically? I am running the Hardware Connect module only right now fo testing, no FSX and other modules running. Will it be triggered when te modules are loading?

thanx a lot!

jeehell
02-03-2015, 06:06 PM
Yes, it is loaded once the software is running (I think at least FSX, server, FSXconnect and OVHD).

JL

netserv
02-03-2015, 06:35 PM
very good. thanks.

Just for your information, I just saw, that each click on the reset hardware button loads another copy of the dll. There is no unload I guess.

So far no problem fo me.


Gü.

jeehell
02-03-2015, 08:10 PM
i have to look at that, probably a little bug on my side...

JL

netserv
02-04-2015, 03:26 AM
...no stress 8)

it's a minor issue, there are certainly other things to do.

just for your bug list.