Jump to content
Sign in to follow this  
Guest newmav

Hijack Autopilot with FSUIPC?

Recommended Posts

Guest newmav

Thanks everyone on this forum for being so helpful. I finally have control over my external device from within a gauge.My next task is to "hijack" my F16 model to simulate an auto-evasion of a surface-to-air missile. I was wondering if I could do this from within the gauge if I were to incorportate FSUIPC (or without, if possible). I just want to move the plane quickly to something like a 45 degree pitch and 85 degree bank, for instance. Would this scenario work?Thanks for any help.

Share this post


Link to post
Share on other sites

Yes, FSUIPC can do that. You can write pitch, bank and yaw values directly.Doug

Share this post


Link to post
Share on other sites
Guest newmav

Thanks for your reply! I just tried it out using FSUIPC_Open2 and tried writing to pitch (offset 0x0578) with a size of 4 and a value of 45 (degrees down). I wrote and processed the request after 55 seconds of flight(1000 with FS timer). It did not seem to have an effect. Do you know of any examples I could look at where these kind of values are written to? Thanks for any help.

Share this post


Link to post
Share on other sites

Remember, the value stored at 0x578 is ( degrees / 360 * 65536 * 65536 ).To write a value of 45 degrees down, you need something like:SINT32 Pitch_Value;Pitch_Value = 45 * 65536 * 65536 / 360;FSUIPC_Write ( 0x0578, 4, &Pitch_Value, &Result );FSUIPC_Process ( &Result );Also, check the FSUIPC log file (in the Modules folder). It will give you an idea as to what is going on with your access through FSUIPC.Doug

Share this post


Link to post
Share on other sites
Guest newmav

I'm still having problems with my auto-evasion. I must not be coding correctly. I tried putting the values directly into the function too. Could you check it out? //SINT32 Pitch_Value = 45 * 65536 * 65536 / 360; - Gives warningFLOAT64 Pitch_Value = 45 * 65536 * 65536 / 360;DWORD Result;--------------------------------------if (init == 0) { //vest.SetTactorIndex (myConv, 64); //conversion table //vest.Init (); //initialize vest BOOL FSUIPC_Open2(DWORD dwFSReq, DWORD *pdwResult, BYTE *pMem, DWORD dwSize); vdata = fopen("c:vdata2.txt","w"); init = 1;if (elapsedTime >= 1000) { fprintf(vdata, "%f %f %f %f n", pitch, bank, elapsedTime, timeEnd); //Pitch_Value = (45 * 65536 * 65536 / 360); //BOOL FSUIPC_Write(DWORD dwOffset, DWORD dwSize, void *pSrce, DWORD *pdwResult); FSUIPC_Write ( 0x0578, 4, &Pitch_Value, &Result ); //BOOL FSUIPC_Process(DWORD *pdwResult); FSUIPC_Process ( &Result ); //timeEnd = timeStart; lookup_var(&time1); timeStart = time1.var_value.n;I also attached my FSUIPC log. Thanks again for the help - I hate to be a pain.

Share this post


Link to post
Share on other sites
Guest newmav

Oops - I attached a wrong FSUIPC log on the last one. Didn't realize that FSLook logged there too.

Share this post


Link to post
Share on other sites

Have you turned on the logging of FSUIPC writes (in the logging options of FSUIPC)? I don't want to make assumptions here - is the LagoF16.gau your gauge, or is it simply another gauge installed on the panel? Put another way, is your gauge making contact with FSUIPC?0x578 is a 4 byte integer offset - you cannot use a 64 bit float as the source variable. Don't worry about the warning when you declare Pitch_Value as SINT32. You could try DWORD instead, although I think they amount to the same thing.Doug

Share this post


Link to post
Share on other sites
Guest newmav

Thanks for your patience. I turned on the error logging and have no idea what these errors are (attached). I cut off the bottom half because it's so long and the rest are the same. Does FSUIPC continue trying after a failure? The write to pitch should have happened only once after I adjusted the timing.My gauge is actually an invisible one adapted from the attitude gauge of the Panels SDK and called Sample.gau. It doesn't look like it's being recognized, but the FSUIPC code is embedded in it. My other code that is working is also in this section along with the FSUIPC stuff (the PANEL_SERVICE_PRE_UPDATE section).Could you tell me what is going to happen if it works? Will it lag and then place the aircraft at that unusual attitude? Thanks for everything.

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

Is your FSUIPC registered?Patrick

Share this post


Link to post
Share on other sites
Guest newmav

Yep - It's registration button is disabled and reads that FSUIPC is registered. Do you think I'm not waiting long enough to open the link? I did try a long delay earlier, but that didn't seem to work either. Thanks for the help!

Share this post


Link to post
Share on other sites

How does this compare to what you have?BYTE Mem[300];DWORD Size = 300;DWORD FSReq = SIM_ANY;DWORD Result_Open;PANEL_SERVICE_PRE_INSTALL:FSUIPC_Open2(FSReq, &Result_Open, Mem, Size);break;You shouldn't need to put any kind of delay in before you issue the FSUIPC_Open2 command. I've never seen it have any kind of problems. To be on the safe side, however, I usually do something like this:PANEL_SERVICE_PRE_UPDATE: if ( ipc_open == 0 ) { FSUIPC_Open2(FSReq, &Result_Open, Mem, Size); FSUIPC_Write(0x8001, sizeof("KJSPC7LFRHG6dsd_xml2ipc.gau"), "KJSPC7LFRHG6dsd_xml2ipc.gau", &Result_Open); FSUIPC_Process(&Result_Open); if (Result_Open == 0 ) ipc_open = 1; }...break;Doug

Share this post


Link to post
Share on other sites
Guest newmav

Thank you very much! I'm embarrased to say, but I wasn't allocating memory for these processes. I just used your parameters - don't know if they are the most efficient for my purpose, but they work! I guess I don't have a full understanding of allocating memory for FSUIPC. I'm suprised at how quickly the transition occurs in MSFS! Thanks again!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...