kinetic2080 Posted September 17, 2004 Report Posted September 17, 2004 Im a complete newbie and wondered if any veterans could help me getting started with FSUIPC in vb .net. I want to make a small demo which reads the aircrafts current alltitude and displays it in a textbox. In the fsuipc shell.vb form/module. I've added a button component (button1) and a textbox component (textbox1). I've tried the follwing code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i 'Open/connect to fsuipc Call FSUIPC_Initialization() 'Try to call altitude data at offest 0x0020 size 4 FSUIPC_Get(32, 4, i) 'Didn't work returns blank :( 'FSUIPC_Get(32, i) MsgBox(i) TextBox1.Text = i 'Close Call FSUIPC_Close() End Sub Im pretty sure I've got the intialize part right, because it works when FS is open, and doesn't work when it's not open. However the FSUIPC_Get() procedure just returns and empty variable. Maybe I've got something wrong with the variable types. Im sure the offset is right, it should be 0x0020 hex = 32 dec. Any help would be much appreciated. -Kinetic
vdkeybus Posted September 17, 2004 Report Posted September 17, 2004 I've never worked with VB.Net, but you seem to make some mistakes regarding the ordering of calls, which is something I do know from using the C/C++ SDK. It is essential that you write your code according to the guidelines contained in the VB.net SDK: ' FUNCTION LIBRARY FOR FSUIPC ' based on C code supplied by Pete Dowson ' ' BASIC USAGE GOES LIKE THIS: ' - call FSUIPC_Initialization() to initialize important vars at beginning ' of program. ' - call FSUIPC_Open() to connect with FSUIPC if it's available. ' - call a series of FSUIPC_Read and/or FSUIPC_Write and/or FSUIPC_WriteS (be careful when ' combining these in the one transaction, for your own sanity). ' - call FSUIPC_Process() to actually get/set the data from/to FS. ' - For reads, call FSUIPC_Get to retrieve data read from FSUIPC (New for VB .Net) ' - repeat steps 3, 4, and 5 as necessary ' - at program termination, call FSUIPC_Close(). So, before you Get() something, you should have Open()ed a link, issued some Read()s or Write()s, and issued a single Process() call. Hope this gets you rid of some logical errors. Syntactical ones (ByVal, ByRef, the way textboxes are treated) are, as implied in the beginning, not exactly my area of expertise... J.
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