Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VB.Net vs FSUIPC

Featured Replies

Ok I have an issue here.I am using VB.Net for my "CockpitLink" program.The result I get is as follows:With my fsuipc code I can read the values; all goos well.I can write the virtual joystick buttons presses: all goos well.But when I do both in the same session .. the read values go mad.So each time I have to enable in my code the "read timer" OR the "write timer". Actually they are on the same timer but I have to put either of both commands as comment to prevent 1 of the 2 peices of code to be triggered.Now I will try using the VB.Net code from the SDK just 1 time more. But I think I remember from last time that code did not work at all.Anyone uses fsuipc with .Net ??

Glad you solved the other problem :)Maybe you'd have better luck asking some help from Peter Dowson.I cannot help since i do not know VB at all :(

The other problem is not solved :(I only know now for sure where the problem is. And sadly again it is out of my area. It is Espens panel .. so again I have to ask 3rd party to take action and maybe get me going soon.Asking Pete is what I did. The problem there is that Pete doesn't know .Net So I'd rather ask people using fsuipc and .Net in a combo.At the moment all I know is that Bob Scott made the .Net part of the fsuipc SDK. His code won't even compile so .. maybe I can contact him.Other than that I know that Scott L. Fausel is using .Net for his software but I haven't heard from him for a while. I suppose he's got a succesfull code to link the dll to .Net since he is selling his software.No responce from either of these 3 people so far.Anyone else knows of a .Net program that uses fsuipc ?

I am currently involved in a FSUIPC/.Net project using C# and I have a few suggestions that might help.Your FSUIPC timer should Sleep() for 100 to 200ms. Don't let it run without some sort of built-in delay, otherwise you'll tie up the CPU at 100%Run the FSUIPC timer routine in it's own separate thread.DEFINITELY only call FSUIPC_Write and FSUIPC_READ (Or whatever they are called) in VB ONCE in your code, and inside the FSUIPC loop. Don't let other methods() make calls to FSUIPC. If you have to SET something inside a method for FSUIPC, set a flag or BIT value instead, then perform the FSUIPC call inside your FSUIPC loop, based on the flag value.Use the correct size INT values for FSUIPC. If you use INT(32) for a FSUIPC (Short) value, you will get screwy results.That should keep you busy for awhile ;-)

Ray S.

 

Check out my aviation portfolio:

http://scottshangar.net

-------Your FSUIPC timer should Sleep() for 100 to 200ms. Don't let it run without some sort of built-in delay, otherwise you'll tie up the CPU at 100%-------I have a timer that ticks every 200ms for reading the values.Then I have an other timer that ticks every 100ms (changed that now to 200) for scanning the Photon. The readings will change checkbox status and on check-changed events I will do a write command to fsuipc.-------Run the FSUIPC timer routine in it's own separate thread.-------? Don't understand what you mean.-------DEFINITELY only call FSUIPC_Write and FSUIPC_READ (Or whatever they are called) in VB ONCE in your code, and inside the FSUIPC loop. Don't let other methods() make calls to FSUIPC. If you have to SET something inside a method for FSUIPC, set a flag or BIT value instead, then perform the FSUIPC call inside your FSUIPC loop, based on the flag value.-------set a flag or bit value ?-------Use the correct size INT values for FSUIPC. If you use INT(32) for a FSUIPC (Short) value, you will get screwy results.That should keep you busy for awhile-------I hope you can give me some more info here. I do appreciate any help enormously! But it's not all clear to me yet.

Ok I've thought about it. Do I understand it right that the problem occurs because I am reading every 200ms and sometimes I do a write. When it so happens that this read and write go at the same time, .. is it then when the problem gets created ?How then can I make sure these reads and writes never come at the same time ?

>------->Run the FSUIPC timer routine in it's own separate thread.>------->>? Don't understand what you mean.>>-------Research 'Programming Multi-Threaded Applications in VB'. It sounds difficult, but instantiating multiple threads in VB is easy. If you have the FSUIPC loop running in a separate thread, you can have that loop always running inside it's own thread, while the rest of your code runs without encountering that 200MS delay. It will make your application run much faster. >DEFINITELY only call FSUIPC_Write and FSUIPC_READ (Or whatever>they are called) in VB ONCE in your code, and inside the>FSUIPC loop. Don't let other methods() make calls to FSUIPC.>If you have to SET something inside a method for FSUIPC, set a>flag or BIT value instead, then perform the FSUIPC call inside>your FSUIPC loop, based on the flag value.>------->>set a flag or bit value ?>>-------For example, if you have a method that sets the NAV1 frequency, set a variable instead. then inside the FSUIPC loop, set NAV1 using the variable value. Some programmers like to perform FSUIPC_Write() inside the NAV1() method (for example). This can get confusing.. not for the programmer, but for FSUIPCLikewise, say you have a method that can set the gear position. Here you'd use a flag (or just a SHORT()). Inside the Gear() Method, just set the variable to reflect the gear state, then inside your FSUIPC loop, you'd set the gear position based on the variable valueI guess it's easier to say "Perform all FSUIPC reads & writes inside the FSUIPC loop... not in other methods.">Use the correct size INT values for FSUIPC. If you use INT(32)>for a FSUIPC (Short) value, you will get screwy results.>------->>I hope you can give me some more info here. I do appreciate>any help enormously! But it's not all clear to me yet.If the FSUIPC offset is a 2-byte offset, use a SHORT(), not an INT() for your variable size. Likewise, if the offset is a 4-byte value, you would then use a variable the size of INT()

Ray S.

 

Check out my aviation portfolio:

http://scottshangar.net

Hmmz ...Ok, what I am doing is only writing to the "Virtual Joystick Buttons" offsets. So I'm not writing any NAV or Gear variables.Would it now be a sollution to not just write to that button offset a 1, then back a 0 (thats how the press is registered). Instead write in a loop always a 0 to it (over and over again) and only put a 1 in between when the button is pressed ?This thinking here made me realise that I was doing the write (value 1) and the write (value 2) directly after eachoter. I've now put a "Sleep(200)" in between.I'll check the help files for that Multi-Threaded thing.

Here's my FSUIPC Thread in C#, but should give you an idea as to how to go about it...#region FSUIPC IO Methods and MCP External Variables Logic private void SetMCPState(){//---------------------------------------------------// READ MSFS Values (Moved 3/29)//--------------------------------------------------- result = fsuipc.FSUIPC_Read(offsetGetALT, 8, ref FSTokens[0], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetIAS, 4, ref FSTokens[1], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetBank, 4, ref FSTokens[2], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetFLAPS, 4, ref FSTokens[3], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetWOW, 4, ref FSTokens[4], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetLOC, 4, ref FSTokens[5], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGNDALT, 4, ref FSTokens[6], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetHDG, 4, ref FSTokens[7], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetMAGVAR,2, ref FSTokens[8], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetMACH, 2, ref FSTokens[9], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetTAS, 2, ref FSTokens[10], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetOAT, 2, ref FSTokens[11], ref dwResult); //Engine Status result = fsuipc.FSUIPC_Read(offsetGetEng1, 2, ref FSTokens[12], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetEng2, 2, ref FSTokens[13], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetEng3, 2, ref FSTokens[14], ref dwResult); result = fsuipc.FSUIPC_Read(offsetGetEng4, 2, ref FSTokens[15], ref dwResult); result = fsuipc.FSUIPC_Read(offsetBUCKET, 4, ref FSTokens[16], ref dwResult); #endregion #region WRITE FSUIPC VALUES (For Processing) //--------------------------------------------------- // WRITE MCP States (BUTTONS) //--------------------------------------------------- result = fsuipc.FSUIPC_Write(offsetAPMaster,AP_Master_State,ref token, ref dwResult); result = fsuipc.FSUIPC_Write(offsetATARM, ATARM_State, ref token, ref dwResult); result = fsuipc.FSUIPC_Write(offsetFD, FDMaster_State, ref token, ref dwResult); result = fsuipc.FSUIPC_Write(offsetHDG, HDG_State + HDGSEL_State, ref token, ref dwResult); result = fsuipc.FSUIPC_Write(offsetVS, VS_State, ref token, ref dwResult); result = fsuipc.FSUIPC_Write(offsetLOC, LOC_State, ref token, ref dwResult); result = fsuipc.FSUIPC_Write(offsetAPP, APP_State, ref token, ref dwResult); // Internal Systems-Specific data result = fsuipc.FSUIPC_Write(offsetBUCKET, BUCKET, ref token, ref dwResult); #endregion//----------------------------------------------//// Engine Combusting Logic ////----------------------------------------------////Check for Engine Out (Not Combusting)//Still got a bug here: AT ARM Turns off intermittently //when VS or ALT is pressed: TIming issue I suspectif((Engine1Combusting == 0 || Engine2Combusting == 0 || Engine3Combusting == 0 || Engine4Combusting == 0) && AircraftOnGround == 0 && ATARM_State == 1 ){Turn_ATARM_Off();}#endregion //Now Process the Entire batch!!fsuipc.FSUIPC_Process(ref dwResult);#region GET RESULTS FROM FSUIPC PROCESSresult = fsuipc.FSUIPC_Get(ref FSTokens[0], ref FacePlate.AircraftAltitude);result = fsuipc.FSUIPC_Get(ref FSTokens[1], ref FacePlate.AircraftAirspeed);result = fsuipc.FSUIPC_Get(ref FSTokens[2], ref FacePlate.AircraftBankAngle);result = fsuipc.FSUIPC_Get(ref FSTokens[3], ref FacePlate.AircraftFlapPosition);result = fsuipc.FSUIPC_Get(ref FSTokens[4], ref FacePlate.AircraftOnGround);result = fsuipc.FSUIPC_Get(ref FSTokens[5], ref FacePlate.AircraftLOCCapture);result = fsuipc.FSUIPC_Get(ref FSTokens[6], ref FacePlate.GroundElevation);result = fsuipc.FSUIPC_Get(ref FSTokens[7], ref FacePlate.AircraftHeading);result = fsuipc.FSUIPC_Get(ref FSTokens[8], ref FacePlate.MAGVAR);result = fsuipc.FSUIPC_Get(ref FSTokens[9], ref FacePlate.AircraftMACH);result = fsuipc.FSUIPC_Get(ref FSTokens[10], ref FacePlate.AircraftTAS);result = fsuipc.FSUIPC_Get(ref FSTokens[11], ref FacePlate.OAT);//Enginesresult = fsuipc.FSUIPC_Get(ref FSTokens[12], ref FacePlate.Engine1Combusting);result = fsuipc.FSUIPC_Get(ref FSTokens[13], ref FacePlate.Engine2Combusting);result = fsuipc.FSUIPC_Get(ref FSTokens[14], ref FacePlate.Engine3Combusting);result = fsuipc.FSUIPC_Get(ref FSTokens[15], ref FacePlate.Engine4Combusting); //Our (Internal) Offsetsresult = fsuipc.FSUIPC_Get(ref FSTokens[16], ref FacePlate.BUCKET_InFromFSUIPC); #endregion#region Convert FSUIPC Values to readable values //-----------------------------------------------////Convert Everything to readable values ////-----------------------------------------------//calc_ALT = (int)(AircraftAltitude * 3.28201);//GOTS US A BAROMETRIC PRESSURE BUG HERE (3/26/2004)calc_IAS = (int)(AircraftAirspeed / 128);calc_TAS = (int)((AircraftTAS / 128) - 1024);calc_ELE = (int)((GroundElevation/256) * 3.28201);calc_tHDG = (int)(AircraftHeading / 11930465);calc_OAT = Convert.ToDouble(OAT) / 256.0;calc_SOS = (float)(38.967854 * Math.Sqrt(calc_OAT + 273.15));calc_MACH = (double)(calc_TAS / calc_SOS);#endregion }while(FSUIPC_Available == true);}#endregion

Ray S.

 

Check out my aviation portfolio:

http://scottshangar.net

Ok 2 things I notice in this code ..1) you use the process//Now Process the Entire batch!!fsuipc.FSUIPC_Process(ref dwResult);Let me check but I don't think I use it anywhere. Could this be a problem ?2) you use the getWhat does this do ?Ow and on the "speed up the proces" and "having your soft use 100% CPU" .. that's no problem. I use my laptop to run the soft for the interface on linked to the FS pc via widefs.

>Ok 2 things I notice in this code ..>>1) you use the process>>//Now Process the Entire batch!!>fsuipc.FSUIPC_Process(ref dwResult);>>>Let me check but I don't think I use it anywhere. Could this>be a problem ?Definitely!! :-)>>2) you use the get>>What does this do ?>>>Ow and on the "speed up the proces" and "having your soft use>100% CPU" .. that's no problem. I use my laptop to run the>soft for the interface on linked to the FS pc via widefs.As long as your CPU isn't maxed at 100%, you're good. That 200ms delay isn't too tight. Try 20ms or even 5, and you'll see what I mean.. :-)

Ray S.

 

Check out my aviation portfolio:

http://scottshangar.net

Get!result = fsuipc.FSUIPC_Get(ref FSTokens<0>, ref FacePlate.AircraftAltitude);This statement literally GETs the value read --into-- the FSUIPC array (At Token row 'Zero') and places it in the local variable "Faceplate.AircraftAltitude" for later...

Ray S.

 

Check out my aviation portfolio:

http://scottshangar.net

Ok so when do I put this process ?Only after reads ? Or also after writes ? And if I write 2 times to the same offset short after eachoter, do I process 2 times ?Also you say the Get action puts the read values into your variables. I do this:IAS = CStr(ReadFromFS(&H2BC, 4) / 128)andBinXpdr = Dec2Bin(CStr(ReadFromFS(&H354, 2)))... ?While waiting for your next thoughts, I'll be putting in the process calls here and there to check if it changes anything.

You should only have 1 read process, 1 write process per offset before you Process it.It's pointless to Write to an offset twice, then process it. Your FSUIPC values will always be set to the second WRITE value, the first one being overwritten by the 2nd write.So, in short:===========================All your READsAll your WRITEsProcess()All your GETs===========================.

Ray S.

 

Check out my aviation portfolio:

http://scottshangar.net

Hmmz .. ok so the Process doesn't help :(The thing is .. I can do all my reads in 1 time each timer tick.But if I have to do all the writes ... on a timer based ... I should have to change my entire code. Let me try this.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.