Jump to content

FSUIPC & VB - Write to FS2002


Recommended Posts

Hi all,

I have searched through the forum for a couple of hours now and had no luck, so I must revert to asking for help, for yet another person trying to interface with FS2002 using Visual Basic.

Here's my issue: I'm trying to write a statement to update the Radio Audio Switches (COM1 vs. COM2 is active, Marker Sound, etc). Looking at the SDK documentation, it says to set the pSrce value to something similar to the following:

2^7 COM1 transmit

2^6 COM2 transmit

2^5 COM receive both

Using simple multiplication, 2^7=128. If I perform an FSUIPC_Read, the value received is 128. However, if I pass that to FS2002 with FSUIPC_Write I get a Windows error stating that the memory address cannot be read/written to.

I'm guessing I must be missing something obvious when interpreting the 2^7 setting, so any help that anyone can offer would be much appreciated.

Thanks for your help,

Chris

Link to comment
Share on other sites

This is the code that I'm using...just a couple of lines to make sure I can get it working.....

Private Sub btnSwapCom2_Click()

Dim dwResult As Long

Dim auiComSwitch As Byte

auiComSwitch = 64

Call FSUIPC_Write(&H3122, 1, auiComSwitch, dwResult)

End Sub

Link to comment
Share on other sites

This is the code that I'm using...just a couple of lines to make sure I can get it working.....

Private Sub btnSwapCom2_Click()

Dim dwResult As Long

Dim auiComSwitch As Byte

auiComSwitch = 64

Call FSUIPC_Write(&H3122, 1, auiComSwitch, dwResult)

End Sub

I don't know VB, but perhaps the reference "auiComSwitch" in the call is giving a value of 64, instead of a POINTER (address) to the place where the value 64 is held. Don't you have a way of ensuring it is an address you pass?

Pete

Link to comment
Share on other sites

Pete,

You truly are a genius! I didn't realize that the VarPtr function that others are using in their VB code must be passing a pointer to the memory location. Sounds like it might be time for me to dig out the old "c" book and start coding with it instead. Thanks for the quick response, and I can see how this can be more than a full time job for you - you'll definitely be getting a payment for using FSUPIC and WideFS!

Thanks again,

Chris

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
 Share

×
×
  • 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.