Jump to content
The simFlight Network Forums

Polling Issue - FSUIPCClient.dll


Recommended Posts

Good afternoon everyone,

I just want to start with I am not a programmer and I have read all documentation with the best of my comprehension abilities. I can't seem to identify a cause for my issue. I am writting a VB.NET application (yes it's a weak language but it is all that I know) that is basically updating some text fields with values from the autopilot. Here are some specifics:

Microsoft FSX

Using default aircraft - Cessna 172

WideFS Client connected to remote FSX system

Latest version of FSUIPCClient.dll

Here is the code behind a timer that is polling every 300ms:

Private Sub Poll_Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Poll_Timer.Tick

Dim airSpeed As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2BC)

Dim altAltitude As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H7D4)

Dim altRate As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H7F2)

Dim altHead As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H7CC)

FSUIPCConnection.Process()

Dim altALT As Double = (altAltitude.Value / 65536D) * 3.28084D

Dim altHDG As Double = (altHead.Value / 65536D) * 360D

Me.TxtAPALT.Text = altALT.ToString("f0")

Me.TxtAPRate.Text = altRate.Value.ToString("f0")

Me.TxtAPHDG.Text = altHDG.ToString("f0")

End Sub

This code works perfectly for a little while. It updates the fields and reports changes accurately and timely, I was pretty happy with it . . . until . . . it randomly gets the following error:

FSUIPC Error #15: FSUIPC_ERR_SIZE. The amount of data requested exceeded the maximum allowed in one Process().

Can someone help me out with this? I would much rather have something fail consistently than to do it when every it feels like it. It makes it a whole lot harder to diagnose. I would think if I was requesting data that was out of bounds, it would do it from the get go. The error occurs even if the values remain static and could pop up after 10 seconds or 5 minutes.

I fully expect to hear that I'm an idiot, need to read the docs, need to look here or there, but honestly that is where I started and it got me here. I appreciate any assistance anyone can offer.

Thanks,

Dave

Link to comment
Share on other sites

Hi Dave,

What's going wrong is that you're declaring the offset variables every time the timer ticks in Poll_Timer_Tick.

This is bad because you're creating new instances of the offset requests every time the timer ticks. Even though your variables go out of scope after the method ends they are still registered with the FSUIPCClient DLL,

So each tick adds 4 new offsets to the list of offsets being requested by the DLL. After 30 seconds your program is actually requesting 400 offsets. After a while you'll exceed the total amount of data that can be handled by FSUIPC and you get the FSUIPC_ERR_SIZE exception.

When working with the DLL only declare (Dim) the offsets once during the lifetime of the application. The easiest way to do this is to place the declarations at the form or class level, rather than in the timer loop. Like this:

Dim airSpeed As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2BC)
Dim altAltitude As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H7D4)
Dim altRate As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H7F2)
Dim altHead As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H7CC)

Private Sub Poll_Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Poll_Timer.Tick

  FSUIPCConnection.Process()

  Dim altALT As Double = (altAltitude.Value / 65536D) * 3.28084D
  Dim altHDG As Double = (altHead.Value / 65536D) * 360D

  Me.TxtAPALT.Text = altALT.ToString("f0")
  Me.TxtAPRate.Text = altRate.Value.ToString("f0")
  Me.TxtAPHDG.Text = altHDG.ToString("f0")

End Sub

I've just had a look at the manual and it doesn't really make this clear which is my fault. I'll have to amend it in future releases. Sorry to dash your expectations but it turns you are not an idiot after all. :smile:

Paul

Link to comment
Share on other sites

Outstanding, that took care of my issue!!

Thank you very much for your assistance. Your DLL and Mr. Dowson's FSUIPC has let me take my Flight Sim exerpience to a whole new level, from just enjoying the flying to getting my hands dirty making a realistic sim to sit in. Outstanding work, my compliments to both of you guys.

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.