Andreww Posted November 29, 2003 Report Posted November 29, 2003 I am experiencing a termination of Flight Sim when I resize the panel window that my FSUIPC gauge is placed on. To find the cause I removed all the FSUIPC elements, and added them back. It would appear that this section is not correct. Might I need to delay the connection to FSUIPC? I have asked many others for help, and with their knowledge in C/C++ they cannot see why there would be any issues with the following code. BYTE FsuipcMem=1024; DWORD dwResult; ******** case PANEL_SERVICE_CONNECT_TO_WINDOW: FSUIPC_Open2(SIM_ANY, &dwResult, &FsuipcMem, 1024); FSUIPC_Process(&dwResult); break; I am including the following in my C file, #include "fs2k2gauges.h" #include "FSUIPC_User.h" #include "FDUMP.h" #include "ModuleUser.c" As well as the FSUIPC_User.lib in the makefile. I do apologise for my lack of knowledge in C. If anyone might know what the cause of such an issue is, I would very much appreciate any help or suggestions you could offer. Regards, Andrew
Pete Dowson Posted November 29, 2003 Report Posted November 29, 2003 I am experiencing a termination of Flight Sim when I resize the panel window that my FSUIPC gauge is placed on. To find the cause I removed all the FSUIPC elements, and added them back. It would appear that this section is not correct. Might I need to delay the connection to FSUIPC? No. it is nothing to do with when you connect. You are corrupting memory by incorrect declarations. BYTE FsuipcMem=1024; Are you thinking that this reserved 1024 bytes for your FSUIPC connection? It does not. This defines a single byte (yes, just 8 bitss of data), then tries to initialise it to 1024 (which is impossible, as the maximum in one byte is 255. Doesn't the compiler complain about this?) To reserve 1024 bytes of memory you need to do this: BYTE FsuipcMem[1024]; Please refer to some C programming books! :? FSUIPC_Open2(SIM_ANY, &dwResult, &FsuipcMem, 1024); FSUIPC_Process(&dwResult); This is wrong in two ways. If FSuipcMem is an array, as it is when you define it correctly, then you either need to provide its address just as "FsuipcMem", OR give the address of the first byte in it, like this "&FsuipcMem[0]". Second, the FSUIPC_Process call processes your reads and writes, but you have done no reads and writes here, so it is a waste of time. It shouldn't do any harm, but it might. As well as the FSUIPC_User.lib in the makefile. You must NOT use that library in a Gauge. The correct library is the "moduleuser.lib" which is included in the Module User part of the SDK. Regards, Pete
Andreww Posted November 29, 2003 Author Report Posted November 29, 2003 Pete, I purchased a book and studied arrays. With your help, I have solved the problem. Thank you for your time. Regards, Andy
Pete Dowson Posted November 29, 2003 Report Posted November 29, 2003 I purchased a book and studied arrays. With your help, I have solved the problem. Good! Also, good luck with C. It may be difficult at first, and, indeed, it is much easier to make mistakes in C, but I think you will find it worth it in the long run. I think it gives you much more control, more power, but of course with power comes responsibility. You have to be more careful too! Regards, Pete
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