Jump to content


Photo

Reading out some values from FS2004 (QT)

qt fs2004 fsuipc reading

  • Please log in to reply
3 replies to this topic

#1 Mikock

Mikock

    Member

  • Members
  • PipPip
  • 11 posts

Posted 08 February 2012 - 09:24 AM

Good morning!

Since some days I am tryingto read out some values from the FS2004 via FSUIPC.

I am using the QT Creator to show my result in a small and simple form.

I think my problem is an easy one. Here is my code:

(It's a SLOT function connected with a pushButton)

void MainWindow::connectFSUIPC(){
	DWORD dwResult;
	if(FSUIPC_Open(SIM_ANY, &dwResult)){
		char *chTime;
		if(FSUIPC_Read(0x0238, 1, &chTime, &dwResult)){
		    !FSUIPC_Process(&dwResult);
			QString str;
			str = *chTime;
			ui->labelFSUIPC->setText(str);
		}
	}
}

The connection and read out from the FS is successfully. I've tested it.

But the variable str is empty. My label shows nothing.

Maybe I made a conversion mistake?


Thank you for your help!

Michael
  • 0

#2 Pete Dowson

Pete Dowson

    Advanced Member

  • Moderators
  • 26,956 posts
  • LocationNear Stoke-on-Trent, UK

Posted 08 February 2012 - 09:54 AM

The connection and read out from the FS is successfully. I've tested it.
But the variable str is empty. My label shows nothing.


The FSUIPC_Open will make the connection and read some basic stuff like FSUIPC and FS versions, but the FSUIPC_Read and FSUIPC_Write functions don't do anything other than add the read/write request to a list. You've no performed the actual read/write until you call FSUIPC_Process, which you've omitted. Please do re-check the documentation and examples.

I've no idea what a QT Creator is. How is this supposed to work?

QString str;
str = *chTime;



Assuming "QString" is some clever type or class which converts basic numerical values into printable characters for you, how does it know the correct representation (decimal, hexadecimal and so on?

Regards
Pete
  • 0

#3 Mikock

Mikock

    Member

  • Members
  • PipPip
  • 11 posts

Posted 08 February 2012 - 10:11 AM

I am just starting with the programming with FSUIPC.

I have corrected some things now, and I'll get now some strange characters in the label. (better than nothing :))

I think my problem is still to convert the result into a normal string. What is the data typ of the result (chTime)?

Here is my corrected code:

if(FSUIPC_Open(SIM_ANY, &dwResult)){
	char chTime[3];
	if(FSUIPC_Read(0x0238, 3, chTime, &dwResult)){
		!FSUIPC_Process(&dwResult);
		ui->labelFSUIPC->setText(chTime);
	}
}

  • 0

#4 Pete Dowson

Pete Dowson

    Advanced Member

  • Moderators
  • 26,956 posts
  • LocationNear Stoke-on-Trent, UK

Posted 08 February 2012 - 10:40 AM

I have corrected some things now, and I'll get now some strange characters in the label. (better than nothing :))
I think my problem is still to convert the result into a normal string. What is the data typ of the result (chTime)?


It's an 8-bit binary value, like an integer but taking up only 1 byte (8-bits) instead of 4 bytes (32 bits).

The integer data types in FS/Windows/FSUIPC are:

BYTE = 8 bits = 1 byte (character)
WORD = 16 bits = 2 bytes (short integer)
DWORD = 32 bits = 4 bytes (integer)
QWORD or __int64 = 64 bits = 8 bytes (__int64 or long long).

I normally use the C library functions "sprintf" or "itoa" to convert binary numbers into decimal strings. Cast 'chTime' to an int.

Regards
Pete
  • 0





Also tagged with one or more of these keywords: qt, fs2004, fsuipc, reading

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


About simFlight - simflight.com - simflight.de - simflight.fr - simflight.nl - simflight.pt - simflight.es - simflight.it - simflight.jp - simrussia.com - simMarket