Jump to content
The simFlight Network Forums

Recommended Posts

Posted

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);
}
}
}
[/CODE]

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

Posted

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

Posted

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);
}
}
[/CODE]

Posted

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

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.