Jump to content
The simFlight Network Forums

Recommended Posts

Hello,

i want to get some values (the speed, the altitude, etc.) out of the Microsoft Flightsimulator into an own C++ program.

I have been told, that I will have to use "FSUIPC".

Now I have a little problem:

I have downloaded the FSUIPC_SDK, but I still dont know how I can get the values like the speed or altitude oft the plane into my program.

I have read the instructions in the FSUIPC_SDK but I have not found a sollution.

It would be very nice, if someone could help me.

Thanks for your help.

Freddy

Share this post


Link to post
Share on other sites

I have downloaded the FSUIPC_SDK, but I still dont know how I can get the values like the speed or altitude oft the plane into my program.

Both speed and altitude are available in the list. Didn't you find them?

I have read the instructions in the FSUIPC_SDK but I have not found a sollution.

You are using C++ for the first time, or do you know how to program? If you do, then look at the easy example provided. Just adapt it to your use using the different offsets for the variables you want.

By all means ask specific questions, but please not general ones like 2how do I write a program", which this amounts to so far. ;-)

Regards,

Pete

Share this post


Link to post
Share on other sites

Thanks for the prompt answer.

I know how to program, but I don't understand how I can get the value, from for example the speed, into a variable of my own c++ program.

Unfortunately I don't understand the examples.

Regards,

Freddy

Share this post


Link to post
Share on other sites

I know how to program, but I don't understand how I can get the value, from for example the speed, into a variable of my own c++ program.

Unfortunately I don't understand the examples.

Basically. FSUIPC_Open at the start, FSUIPC_Close at the end. In between use FSUIPC_Read and FSUIPC_Write calls to specify the data to be exchanged and then an FSUIPC_Process to send the request off to FSUIPC.

The interface is enveloped in these 5 simple procedures to make things very simple for even beginners to understand! Please tell me what is so confusing?

If you don't want to use the procedures, the source is also provided so that you can see exactly how the interface works in terms of basic Windows API calls. When it comes down to it the only real interface to FSUIPC is a single SendMessageTimeout call.

If you are a programmer, surely you can follow these things? If you have specific questions, please formulate them, but it simply makes no sense at all to say "I know how to program but I don't understand even one line of any of this", which is what your statements seem to amount to. This really means you don't know how to program, surely?

Please be more specific. I am not going to write programs for you.

Regards,

Pete

Share this post


Link to post
Share on other sites

I have learned programing in school.

One problem is, that i get the Error Message

"[Linker Error]' FSUIPC_USER.LIB' contains invalid 0MF record, type 0x21 (possibly C0FF)"

when I'm trying to compile the example program:

#include 
#include 
#include "FSUIPC_User.h"

char *pszErrors[] =
	{	"Okay",
		"Attempt to Open when already Open",
		"Cannot link to FSUIPC or WideClient",
		"Failed to Register common message with Windows",
		"Failed to create Atom for mapping filename",
		"Failed to create a file mapping object",
		"Failed to open a view to the file map",
		"Incorrect version of FSUIPC, or not FSUIPC",
		"Sim is not version requested",
		"Call cannot execute, link not Open",
		"Call cannot execute: no requests accumulated",
		"IPC timed out all retries",
		"IPC sendmessage failed all retries",
		"IPC request contains bad data",
		"Maybe running on WideClient, but FS not running on Server, or wrong FSUIPC",
		"Read or Write request cannot be added, memory for Process is full",
	};


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{	DWORD dwResult;

	if (FSUIPC_Open(SIM_ANY, &dwResult))
	{	char chMsg[128], chTimeMsg[64];
		char chTime[3];
		BOOL fTimeOk = TRUE;
		static char *pFS[] = { "FS98", "FS2000", "CFS2", "CFS1", "Fly!", "FS2002", "FS2004" };  // Change made 060603

		// Okay, we're linked, and already the FSUIPC_Open has had an initial
		// exchange with FSUIPC to get its version number and to differentiate
		// between FS's.

		// Now to auto-Register with FSUIPC, to save the user of an Unregistered FSUIPC
		// having to Register UIPCHello for us:
		static char chOurKey[] = "IKB3BI67TCHE"; // As obtained from Pete Dowson

		if (FSUIPC_Write(0x8001, 12, chOurKey, &dwResult))
			FSUIPC_Process(&dwResult); // Process the request(s)

		// I've not checked the reslut of the above -- if it didn't register us,
		// and FSUIPC isn't fully user-Registered, the next request will not
		// return the FS lock time

		// As an example of retrieving data, well also get the FS clock time too:
		if (!FSUIPC_Read(0x238, 3, chTime, &dwResult) ||
				// If we wanted other reads/writes at the same time, we could put them here
				!FSUIPC_Process(&dwResult)) // Process the request(s)
			fTimeOk = FALSE;

		// Now display all the knowledge we've accrued:
		if (fTimeOk)
			wsprintf(chTimeMsg, "Request for time ok: FS clock = %02d:%02d:%02d", chTime[0], chTime[1], chTime[2]);

		else
			wsprintf(chTimeMsg, "Request for time failed: %s", pszErrors[dwResult]);

		wsprintf(chMsg, "Sim is %s,   FSUIPC Version = %c.%c%c%c%c\r%s",
			(FSUIPC_FS_Version && (FSUIPC_FS_Version <= 7)) ? pFS[FSUIPC_FS_Version - 1] : "Unknown FS", // Change made 060603
			'0' + (0x0f & (FSUIPC_Version >> 28)),
			'0' + (0x0f & (FSUIPC_Version >> 24)),
			'0' + (0x0f & (FSUIPC_Version >> 20)),
			'0' + (0x0f & (FSUIPC_Version >> 16)),
			(FSUIPC_Version & 0xffff) ? 'a' + (FSUIPC_Version & 0xff) - 1 : ' ',
			chTimeMsg);
		MessageBox (NULL, chMsg, "UIPChello: Link established to FSUIPC", 0) ;
	}

	else
		MessageBox (NULL, pszErrors[dwResult], "UIPChello: Failed to open link to FSUIPC", 0) ;

	FSUIPC_Close(); // Closing when it wasn't open is okay, so this is safe here
   return 0 ;
}

An the other problem is, that I dont understand how I can get the values, when the datatype of the functions like "FSUIPC_Read()" is BOOL?

Share this post


Link to post
Share on other sites

One problem is, that i get the Error Message

"[Linker Error]' FSUIPC_USER.LIB' contains invalid 0MF record, type 0x21 (possibly C0FF)" when I'm trying to compile the example program:

All my code, including examples, are actually C, not C++. Maybe you need to tell your linker that? I'm really as confused as the next person by the plethora of rather arcane settings you need to check in Microsoft language systems, especially linkers. Sorry.

Perhaps you need to take the source code of the Library (also supplied) and use that?

I dont understand how I can get the values, when the datatype of the functions like "FSUIPC_Read()" is BOOL?

Strange that you've not sussed any of the function prototypes out. There are many Windows functions which, like the FSUIPC_ ones, return a success/fail indication as the result, but store the data returned in the locatin you point to. After all, the data could be anything from a single byte to an area of offsets many kilobytes long -- it isn't suitable for returning as any "typed" function result.

If you look carefully at the prototypes for the Read and Write functions you will see that you have to supply not only the offset (start) value, but also the length in bytes (which could be large), and, most important, a pointer to the data to be Written or to the area where you want the Read to deposit the data. That might be a byte, a word, a DWORD, a double, an array, or a structure, or even an array of structures (as for the TCAS data, for example).

Please study it a bit more, and revise what you learned in school about pointers, arrays and structures. Look again at the example and see how the data it displays is read.

Regards,

Pete

Share this post


Link to post
Share on other sites

I have opened a new Project in C but I still have the Linker Error ...

I have inserted the IPCuser.c ans IPCuser.h into my source folder, and have inserted the IPCuser.c instead of the FSUIPC_User.lib into my project.

Now I have only one Error Message:

[Linker Error] Unresolved external '_main' referenced from C:\PROGRAMME\BORLAND\CBUILDER5\LIB\C0X32.OBJ

Share this post


Link to post
Share on other sites
I have opened a new Project in C but I still have the Linker Error ...

I have inserted the IPCuser.c ans IPCuser.h into my source folder, and have inserted the IPCuser.c instead of the FSUIPC_User.lib into my project.

Now I have only one Error Message:

[Linker Error] Unresolved external '_main' referenced from C:\PROGRAMME\BORLAND\CBUILDER5\LIB\C0X32.OBJ

You are using Borland? I'm afraid I can't help with that, I only ever used MS for FS development. Didn't you find a Borland ZIP with stuff you can use in the SDK? A kind previous Borland programmer submitted some helpful material -- check the UIPC_SDK_BCB5 zip file.

Pete

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • 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.