Mikock Posted February 8, 2012 Report Share Posted February 8, 2012 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 Link to comment Share on other sites More sharing options...
Pete Dowson Posted February 8, 2012 Report Share Posted February 8, 2012 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 Link to comment Share on other sites More sharing options...
Mikock Posted February 8, 2012 Author Report Share Posted February 8, 2012 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] Link to comment Share on other sites More sharing options...
Pete Dowson Posted February 8, 2012 Report Share Posted February 8, 2012 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now