Results 1 to 10 of 11
Thread: FSBUS Dll and Visual Basic
-
02-14-2010, 06:32 PM #1
FSBUS Dll and Visual Basic
Hi, someone know if is possible use Visual Basic to programming FSBUS Cards?
-
02-15-2010, 03:29 AM #2
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: FSBUS Dll and Visual Basic
I don´t konw. Try it and report your result.
-
02-15-2010, 08:53 AM #3
Re: FSBUS Dll and Visual Basic
I was wanting to do the same thing and click for example Start and Stop instead of a exe to run a DOS command program. Also wouldn't mind trying to get it to run in the lower right Taskbar with the clock. Started to try it but couldnt figure out VB C++ and didnt want to try to check out even more books from the Library just to learn C++ and VB C++. But who knows VB C++ might be REALLY easy to use but again didnt want to try to learn both but I might try to tackle this, this summer since i got laid off and dont have a Job yet. But for sure if you get a chance to try it let us know. PLEASE PLEASE lol
-
02-15-2010, 09:03 AM #4
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: FSBUS Dll and Visual Basic
Hi what you mean with VB C++??
-
02-15-2010, 09:26 AM #5
Re: FSBUS Dll and Visual Basic
Well isnt it Visual Basic C++ or am i thinking of something else?
-
02-15-2010, 09:53 AM #6
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: FSBUS Dll and Visual Basic
I know Visual Basic and Visual C++, but VB C++ i never heared.
-
02-15-2010, 01:13 PM #7
Re: FSBUS Dll and Visual Basic
NO...... LMAO i meant VB C++ = ( Visual Basicl C++) lol
-
02-19-2010, 02:52 PM #8
Re: FSBUS Dll and Visual Basic
So Im not sure if this helps but..... I did find some files on my computer talking about Visual Basic C++ here is the rar of the file i have and a little bit that talks about it
UIPC_SDK_VisualBasic.rar
FSUIPC Developer Kit: Library for Visual Basic programmers
==========================================================
To interface to FSUIPC (versions 1.998e or later) in your VB programs:
* insert the FSUIPC.bas module into your project
* call the appropriate Library routines in your code.
More on this last part (and please also refer to the UIPCHello example
provided):
Opening the link to FSUIPC
==========================
For this you use the following Library routine:
Function FSUIPC_Open(dwFSReq As Long, ByRef dwResult As Long) As Boolean
where dwFSReq specifies which Flight Simulator you want to connect to:
SIM_ANY for any supported by FSUIPC or equivalent
SIM_FS98 FS98
SIM_FS2K FS2000
SIM_FS2K2 FS2002
SIM_CFS2 CFS2
SIM_CFS1 CFS
SIM_FLY Fly! (not supported yet, and no promises implied!)
and dwResult is a LONG to receive an error number if the operation fails.
If FSUIPC_Open returns "FALSE" then the value in the result LONG will
tell you what went wrong. The errors currently possible are defined in
the FSUIPC.bas file (see the list of FSUIPC_ERR_ ... definitions).
If it returns "TRUE" then the link is open and ready for your requests.
Already the Library routine will have obtained some data for you:
Public FSUIPC_Version As Long ' HIWORD is 1000 x Version Number, minimum 1998
' LOWORD is build letter, with a = 1 etc.
Public FSUIPC_FS_Version As Long ' SIM_FS98, SIM_FS2K etc -- see above
Closing the link
================
Before terminating your program, or trying to re-open (e.g. to re-connect
after a lost connection, possibly due to FS crashing or closing), you must
Close the link to free up the resources it uses:
Sub FSUIPC_Close()
There is no harm done if you Close a link that is already Closed.
Specifying the requests
=======================
The interface to FSUIPC and hence the simulator is simply one of reads and
writes from and to specific "offsets". These were originally true offsets
into a specific Global data area within FS, but nowadays, at least in FS2000
and CFS they are more likely to be treated as Identifiers to specific
variables, and are translated within FSUIPC. However, you may still address
data with contiguous offsets in blocks, as FSUIPC breaks these down if it
needs to.
The following Library calls are used to accumulate Read and Write requests:
Function FSUIPC_Read(dwOffset As Long, dwSize As Long, pDest As Long, _
ByRef dwResult As Long) As Boolean
Function FSUIPC_Write(dwOffset As Long, dwSize As Long, pSrce As Long, _
ByRef dwResult As Long) As Boolean
Function FSUIPC_WriteS(dwOffset As Long, dwSize As Long, ByVal pSrce As Long, _
ByRef dwResult As Long) As Boolean
In each case you supply an offset, identifying the data required or to be
written, and a size (in bytes). The pointers "pDest" for reads and "pSrce"
for writes naturally must point to the area to receive the result or (for
writes) the area containing the data to be written. Use "FSUIPC_WriteS" to pass a
null terminated 'C' style string, similar to this:
WavFile = "SomeWavFile" & vbNullChar
FSUIPC_WriteS(&H4208, Len(WavFile) + 1, WavFile, dwResult)
The LONG for the result is used to identify the reason for error should the
return be FALSE. The only possible errors on these calls are an unopened
link or a full data area. You can only accumulate so much data before you need
to get FSUIPC to "process" it. This is next:
Processing the requests
=======================
Function FSUIPC_Process(dwResult As Long) As Boolean
This routine sends all the requests accumulated using the Read and Write calls
since the last Process call (if any). It is this call which actually operates
the interface.
As usual, the error number in the dwResult LONG needs to be checked if this
call returns FALSE, indicating an error.
Note that, if your program is run under WideClient, it is likely that your
first requests for data are met with zeroes for everything. This is because
WideClient sends off the request but meanwhile returns what it already has. If
you depend on seeing correct data from the outset, you will need to wait some
milliseconds (100 or more is good, 500 safer) and read again.
If you are continually reading the same data over and over in a loop, as when,
for instance, maintaining a moving map position and so on, the initial values
from Wideclient shouldn't be any bother. But remember, in loops, allow some
time for other processes to run, and also process your own Windows messages.
Contribution for VB programmers from Stuart Browne
==================================================
Although Visual Basic has no true 64 bit integer data types, it is actually possible to fake it. Believe it or not, internally the Currency data type IS actually a 64 bit integer. (Don't bother looking in books or the MSDN help files, they'll tell you it's only 32 bit.). Visual Basic scales down by a factor of 10,000 to show only four digits after the decimal point. So to work with the true 64 bit integer we must first load it into a Currency data type then transfer it to a Double AND multiply by 10,000.
Here's some example code extracting the 64bit Latitude Integer from offset 0560
Dim Fake64Bit As Currency
Dim dwResult As Long
Dim Latitude As Double
If FSUIPC_Read(&H560, 8, VarPtr(Fake64Bit), dwResult) Then
' "Read" proceeded without any problems
If FSUIPC_Process(dwResult) Then
' First we need to multiply the fake64bit number held in the currency VAR by 10,000
' to remove the decimal point - remember to force the double (#) to avoid overflow
Latitude = Fake64Bit * 10000#
' Now convert from FS units to degrees, again forcing the double to avoid overflow
Latitude = Latitude * 90# / (10001750# * 65536# * 65536#)
Else
' Unable to "Process"
lblStatus.Caption = "Processing: " & ResultText(dwResult)
End If
Else
' Unable to "Read"
lblStatus.Caption = "Reading: " & ResultText(dwResult)
End If
Contribution for VB programmers from Mark Schilberg
===================================================
Some VB programs will compile (by default?) using Unicode in strings rather
than ASCII. Unicode uses 16 bits (2 bytes) per character. FS, and so FSUIPC,
likes only ASCII. So, if you are writing strings to FSUIPC you may need
to convert your strings. Here is a method of doing this:
For intCount = 1 To Len(strMessage)
strMessageB = strMessageB & ChrB(Asc(Mid(strMessage, intCount, 1)))
Next intCount
strMessageB = strMessageB & Chr(0)
Presumably there's a way of reversing this when reading ASCII.
==============================================================================
original by Chris Brett (chris@formulate.clara.net), 14th December 2000
This file is based on Peter Dowson's original ReadThis.txt file for C.
-
02-20-2010, 04:03 PM #9
- Join Date
- Feb 2008
- Location
- Krefeld, Germany
- Posts
- 318
Re: FSBUS Dll and Visual Basic
-
02-20-2010, 08:23 PM #10
Re: FSBUS Dll and Visual Basic
I trie load the FSBUS Dll in to VB project but no sucess!! I take a look your code Stefan, thank you for your help.
I need a good book about VC++, the structure of this langage is much harder for me!! hehehe
Similar Threads
-
Looking for some basic help??
By Robert Byrne in forum General Builder Questions All Aircraft TypesReplies: 4Last Post: 12-22-2010, 05:48 AM -
Interfacing a Basic ASI Gauge
By Boeing 747 Flyer in forum Interfacing Real Aviation PartsReplies: 69Last Post: 06-21-2010, 05:25 PM -
BU0836 Basic Question
By GARich in forum General Builder Questions All Aircraft TypesReplies: 3Last Post: 03-24-2009, 03:59 PM -
USB basic help
By Redbirdman in forum Computer Hardware SetupReplies: 6Last Post: 03-18-2009, 05:44 PM -
Visual Basic Express and Simconnect
By DarylL in forum I/O Interfacing Hardware and SoftwareReplies: 0Last Post: 11-26-2007, 02:02 PM
Prettys Girls in your town
Is it just me? - Upper ECAM...