Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi Pete.

I am making an external program for FSX using FSUIPC (java sdk) as interface for reading and writing data.

As an external program, i have no info about the state of the connection between my program and FSX:

To open the connection, "Open" returns an integer value that shows up if the connection has been successful (that's fine), but "Close" is void and returns no value. Is there any way for you to make the Close method to return a value to show up if disconnection has been successful or not?

As it is an external program, I can close FSX while my program keeps running trying to read and write values to fsx, so i am missing a method to test if connection is still alive.

Thanks in advance for your help.

Posted

"Close" is void and returns no value. Is there any way for you to make the Close method to return a value to show up if disconnection has been successful or not?

The "disconnection" cannot fail, as there is really no connection in the first place. The Open call is merely a sequence involving the allocation, via Windows, of a memory-mapped file to be used for the data exchange, followed by some FSUIPC_Reads and an FSUIPC_Process to check version numbers and so on. The validity of the "connection" is based merely on the returns, allowing for the timeout imposed by the SendMessageTimeOut call and a number of retries.

The Close call merely releases the memory-maped file which is created by the Open call. The memory thus allocated is used to perform the inter-process exchanges. The same mechanism is used by DDE (direct Data Exchange) and by the debuggers. Nothing actually "connects" as such, where's no transmission or reception other than the "SendMessageTimeOut" used to notify FSUIPC (in the FS Process) of new data.

As it is an external program, I can close FSX while my program keeps running trying to read and write values to fsx, so i am missing a method to test if connection is still alive.

The "connection" is alive until the Window handle used in the SendMessageTimeOut is no longer valid, which will be when FS (or WideClient for a WideFS client) terminates.

Therefore the only way you have is to check the response to the FSUIPC_Process, just as the FSUIPC_Open does. You may want to allow a few retries, in case FS or the PC generally is being held up by some intense activity, but bear in mind this is probably already being done inside the Process call in any case.

If you want to understand this a bit more, you may like to look at the source code for the FSUIPC_xxx routines you are using. I supply the C source for the LIBrary in the SDK, and the other languages have their sources too included in ttheir sections.

Regards

Pete

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.