The example program that came with the dll works perfectly.
Timer Sub:
' The timer handles the real-time updating of the Form.
' The default group (ie, no group specified) is
' Processed and every Offset in the default group is updated.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
' Process the default group
FSUIPCConnection.Process()
' IAS - Simple integer returned so just divide as per the
' FSUIPC documentation for this offset and display the result.
Dim airpeedKnots As Double = (airSpeed.Value / 128D)
Me.iastxt.Text = airpeedKnots.ToString("f1")
Me.alttxt.Text = altitude.ToString("f1")
' Compass heading
' Used to demonstrate disconnecting and reconnecting an Offset.
' We display the data in the field regardless of whether
' it's been updated or not.
Me.hdgtxt.Text = compass.Value.ToString("F2")
Catch exFSUIPC As FSUIPCException
If exFSUIPC.FSUIPCErrorCode = FSUIPCError.FSUIPC_ERR_SENDMSG Then
' Send message error - connection to FSUIPC lost.
' Show message, disable the main timer loop and relight the
' connection button:
' Also Close the broken connection.
Me.Timer1.Enabled = False
Me.cnctfsbtn.Enabled = True
FSUIPCConnection.Close()
MessageBox.Show("The connection to Flight Sim has been lost.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
' not the disonnect error so some other baddness occured.
' just rethrow to halt the application
Throw exFSUIPC
End If
Catch ex As Exception
' Sometime when the connection is lost, bad data gets returned
' and causes problems with some of the other lines.
' This catch block just makes sure the user doesn't see any
' other Exceptions apart from FSUIPCExceptions.
End Try
End Sub
cnctfsbtn (Connect to FS Button) code:
Private Sub cnctfsbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cnctfsbtn.Click
Try
' Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
FSUIPCConnection.Open()
Me.cnctfsbtn.Enabled = False
Me.Timer1.Interval = 200
Me.Timer1.Enabled = True
Dim airpeedKnots As Double = (airSpeed.Value / 128D)
Me.iastxt.Text = airpeedKnots.ToString("f1")
Me.hdgtxt.Text = compass.Value.ToString("F2")
Me.alttxt.Text = altitude.Value.ToString("00,000")
Catch ex As Exception
' Badness occurred - show the error message
MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Code at top of VB script:
Imports FSUIPC
Public Class AFVA_ACARS
' Constants
Private Const AppTitle As String = "AFVA Acars"
' Register the Offsets we're interesing in for this application
Dim airSpeed As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2BC) ' Basic integer read example
Dim avionics As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2E80) ' Basic integer read and write example
Dim fsLocalDateTime As Offset(Of Byte()) = New FSUIPC.Offset(Of Byte())(&H238, 10) ' Example of reading an arbitary set of bytes.
Dim aircraftType As Offset(Of String) = New FSUIPC.Offset(Of String)("AircraftInfo", &H3160, 24) ' Example of string and use of a group
Dim lights As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&HD0C, 2) ' Example of BitArray used to manage a bit field type offset.
Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' Example for disconnecting/reconnecting
Dim pause As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H262, True) ' Example of a write only offset.
Dim altitude As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H574)
Dim verspd As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&HCCFE)
Any errors in the code above?
EDIT: Forgot the log:
********* FSUIPC4, Version 4.50 by Pete Dowson *********
User Name=""
User Addr=""
FSUIPC4 not user registered
WIDEFS7 not user registered, or expired
[Continuation log requested by user]
Running inside FSX (using SimConnect Acc/SP2 Oct07)
Module base=61000000
Wind smoothing fix is fully installed
102531 System time = 20:48:42, Simulator time = 13:47:39 (04:47Z)
102531 LogOptions changed, now 00000000 0000001D
102609 Ready Flags: Ready-To-Fly=Y, In Menu=N, In Dlg=N
109359 READ0 3304, 4 bytes: 00 00 00 45 ...E
109359 READ0 3308, 4 bytes: 08 00 DE FA ....
125078 Ready Flags: Ready-To-Fly=Y, In Menu=Y, In Dlg=Y
125078 Sim stopped: average frame rate for last 22 secs = 81.8 fps
131031 LogOptions changed, now 00000000 00000001
[Log closed by user request, and continued in new file]
151875 System time = 20:49:31, Simulator time = 13:48:04 (04:48Z)
151875 *** FSUIPC log file being closed
Average frame rate for running time of 49 secs = 78.3 fps
Memory managed: 22 Allocs, 21 Freed
********* FSUIPC Log file closed ***********