TurbofanDude Posted May 27, 2012 Report Share Posted May 27, 2012 Hi there, I am sorry if I sound silly asking, but I am trying to receive some critical info from FSUIPC (airspeed, etc.) through a C++ program. I have called FSUIPC_Open and then tried FSUIPC_Read, but the char is null. Is there any chance you can point me in the direction? This is the code: char speeds[3]; void launchfsuipc() { DWORD dwCLOSED; DWORD res; if(FSUIPC_Open(SIM_ANY,&dwCLOSED)) { //link ok FSUIPC_Read(0x238, 3, speeds,&res); stringstream ss; ss << speeds[1] << speeds[2] << speeds[3]; MessageBoxA(NULL, ss.str().c_str(), "", MB_OK); } else { //link failed MessageBoxA(NULL, "YO HOMIE I FAILED", "YO", MB_OK); }}[/CODE]Thanks,--Collin Biedenkapp Link to comment Share on other sites More sharing options...
Pete Dowson Posted May 27, 2012 Report Share Posted May 27, 2012 I am sorry if I sound silly asking, but I am trying to receive some critical info from FSUIPC (airspeed, etc.) through a C++ program. I have called FSUIPC_Open and then tried FSUIPC_Read, but the char is null. Is there any chance you can point me in the direction? All FSUIPC_Read and FSUIPC_Write do is add your request to the queue of requests waiting to be processed. Please look at the examples provided and read the text files and other documents provided. The only communication with FSUIPC occurs when you execute the FSUIPC_Process call. You should be accumulating all your requests for a sinlge Process each cycle, for efficiency, because each Process call involves a process switch. The read and write costs themselves are negligible, they just handle data in your own program. Regards Pete Link to comment Share on other sites More sharing options...
TurbofanDude Posted May 28, 2012 Author Report Share Posted May 28, 2012 (edited) Ah, I was looking at the wrong example. I apologize, thanks! I have used a code exactly as in the example (except for MessageBoxA due to a different character set and a C++ compiler), and I am getting garbage data in the strings for FSX time. How can I get a length of actual data received in order to use a null terminator? Edited May 28, 2012 by Collin Biedenkapp Link to comment Share on other sites More sharing options...
Pete Dowson Posted May 28, 2012 Report Share Posted May 28, 2012 I have used a code exactly as in the example (except for MessageBoxA due to a different character set and a C++ compiler), and I am getting garbage data in the strings for FSX time. The FS time data isn't character based, but binary values -- i.e. numbers. If you want strings to display you'll have to convert numbers to string character representations, eg. by using sprintf or similar. How can I get a length of actual data received in order to use a null terminator? Numerical values have fixed defined lengths in any case -- a bytes is 1 bytes, a word is 2 bytes, etc. Different numbers have different sizes or representations. Any strings actually provided in the offset list are either of a defined length or already have a zero terminator in any case! There's a FAQ subforum thread telling you about numbers and bits for those new to programming. Pete Link to comment Share on other sites More sharing options...
TurbofanDude Posted May 28, 2012 Author Report Share Posted May 28, 2012 Wow, I really need to slow down. I'm not new, just rushing. I apologize and I appreciate your help. I'll take another look, and I won't ask again until I've read up first. Collin Link to comment Share on other sites More sharing options...
TurbofanDude Posted June 2, 2012 Author Report Share Posted June 2, 2012 This is my current function. I have read through the guides and I cannot figure it out. I am now unable to get the data to read properly, and I am unaware of the way to apply the expression formula. unsigned short PITCH[2];void launchfsuipc() { DWORD dwResult; if (FSUIPC_Open(SIM_ANY, &dwResult)) { DWORD result; FSUIPC_Read(0x842,2,PITCH, &result); DWORD result1; FSUIPC_Process(&result1); //Does PITCH[0] not contain the correct value? } else MessageBoxA(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}[/CODE] Link to comment Share on other sites More sharing options...
Pete Dowson Posted June 2, 2012 Report Share Posted June 2, 2012 This is my current function. I have read through the guides and I cannot figure it out. I am now unable to get the data to read properly, and I am unaware of the way to apply the expression formula. What are you actually reading in PITCH[0]? Why have you defined PITCH as an array of 2 16-bit unsigned words? Offset 0842 is the vertical speed and as documented, it is one signed 16-bit word,i.e. 2 bytes long. You are correctly reading two bytes, so what is the other PITCH word for? And why "unsgined" when is distinctly tells you it is signed? I don't understand why you'd want to call the vertical speed "PITCH", -- that smacks of carelessness. And what is this "expression formula" which you want to apply, and why can't you? If you want the vertical speed in floating point feet per minute just do this: signed short VS;double verticalspeed;... FSUIPC_Read(0x842,2,&VS, &result);...verticalspeed = - (VS * 3.28084);}[/CODE]As always, please PLEASE take more care when looking up and checking offset use and access. Why aren't you using the tools provided, like Logging and FSInterogate to work out what you need to do?RegardsPete Link to comment Share on other sites More sharing options...
TurbofanDude Posted June 2, 2012 Author Report Share Posted June 2, 2012 I apologize, again, and I thank you for your help. I was using FSInterrogate some, but clearly not enough. Upon your help and further investigation of the variables, I am able to receive and process them properly. I appreciate the help, and I promise I will not post again until I have throughout researched the issue first. For the record, the PITCH variable was being used as I copied this code from another one I had written earlier, and I hadn't switched the variable name yet. I am storing them in a struct with their appropriate types and names now. -- Collin Link to comment Share on other sites More sharing options...
Pete Dowson Posted June 3, 2012 Report Share Posted June 3, 2012 I apologize, again, and I thank you for your help. I was using FSInterrogate some, but clearly not enough. Upon your help and further investigation of the variables, I am able to receive and process them properly.. Super! Glad you sorted it all out. I hope you manage to continue, but please don't feel unable to come back if you experience any more complex problems! 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