Results 1 to 3 of 3
  1. #1
    300+ Forum Addict jmig's Avatar
    Join Date
    Apr 2007
    Location
    Lafayette, LA USA
    Posts
    440
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Coding the mastercard to work with FSUIPC

    I always knew I was a non entity when it came to programming. I just never knew how badly I sucked. I have been trying for two days to get one single little switch to do one simple little function, open and close the canopy.

    I have read tutorials and looked at examples, all for naught. Here is what I need to do. I have a switch connected to a handle that I want to open and lower the canopy in FSX.

    The switch is connected to the first pin on the master card and gives me 000 when closed in the OpenCockpits controller applet. So I know it and the MC are working.

    I tried to use the IOCard config to have it change the status of offset $3367 within FSUPIC. The new FSX offset guide shows 3367 to be a single byte and it shows 2^0 = Exit1 & 2^3 = Exit4. I know that those are the bits to control different doors. However, I donít know how to state 2^0 in SIOC or what the ^ means.

    Using an example on making a switch turn on a LED I tried the following:

    Var 0001, name canopySW, Link IOCARD_SW, Input 0, Type I

    Var 0002, name canopy, Link FSUIPC_INOUT, Offset $3367, Length 1

    IF &canopySW = 0 // If switch is OFF
    {
    &canopy = 0 // output is OFF
    }
    ELSE
    {
    &canopy = 1 // If not, output is ON
    }

    It too didnít work. I feel embarrassed and frustrated that I canít even get one little switch to work with FSUIPC and FSX. Can anyone help?
    John

    System:
    ASUS P5Q SE/R
    Intel Q9550 O/C to 3.4 GHz
    4 GB 1066 DDR2 RAM
    300 GB WD 10,000 RPM Raptor SATA Drive
    GeForce 8800 GT 512 KB RAM
    Matrox TH2Go with three 19" Sumsung 940 BX
    IR Track 4

  2. #2
    10+ Posting Member
    Join Date
    Feb 2008
    Location
    Canada
    Posts
    19
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Quote Originally Posted by jmig View Post
    it shows 2^0 = Exit1 & 2^3 = Exit4. I know that those are the bits to control different doors. However, I don’t know how to state 2^0 in SIOC or what the ^ means.
    From right to left, the 8 bits are numbered 0 to 7. So 2^0 is the right-most (or least significant) bit. 2^7 is the left-most (or most significant bit).

    (The caret ^ is the power sign. e.g. 5^2 = 5 x 5 = 25 but you don't really need to know that for this exercise.)

    SIOC is event-driven which means WHEN a variable changes, SIOC will execute the code ASSOCIATED with the variable. When you throw your switch, Var 0001 changes so you need some code UNDER var 0001 to change the bits in Var 0002.

    For a starting point, you were close. You just need to move the code to under Var 0001. Note the extra set of braces (curly brackets). Without them, the ENTIRE code may or may NOT be associated properly with Var 0001

    Var 0001, name canopySW, Link IOCARD_SW, Input 0, Type I
    {
    IF &canopySW = 0 // If switch is OFF
    {
    &canopy = 0 // output is OFF
    }
    ELSE
    {
    &canopy = 1 // If not, output is ON
    }
    }

    Var 0002, name canopy, Link FSUIPC_INOUT, Offset $3367, Length 1

    For now, you don't need any code under var 0002. You would need code under var 0002 if, say later, you wanted to control an LED whenever the door was opened/closed.

    After you get this going, you will need to modify your code to change only a SINGLE bit. For $3367, you say the bit 3 (or 2^3) opens/closes another door (exit4). If so, your switch will always close all other doors because you would always be changing the other bits to 0 (because you are always assigning 00000000 or 00000001 to Var 0002).

    You'd need to use CLEARBIT or SETBIT to alter a single bit. (CHANGEBIT and CHANGEBITN can also be used to condense the IF/THEN/ELSE downto a single line.)

    Checkout Nico Kaan's SIOC How-To page if you haven't already. (His "Landing Lights" example is similar to what you're doing.)

  3. Thanks jmig thanked for this post
  4. #3
    300+ Forum Addict jmig's Avatar
    Join Date
    Apr 2007
    Location
    Lafayette, LA USA
    Posts
    440
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Thank you so much! I will try this tomorrow. I figure that once I get a couple under my belt, I can figure the rest out.

    I was stumped.
    John

    System:
    ASUS P5Q SE/R
    Intel Q9550 O/C to 3.4 GHz
    4 GB 1066 DDR2 RAM
    300 GB WD 10,000 RPM Raptor SATA Drive
    GeForce 8800 GT 512 KB RAM
    Matrox TH2Go with three 19" Sumsung 940 BX
    IR Track 4

Similar Threads

  1. Old: Need some help with a bit of coding logic.
    By kiek in forum lekseecon Q&A and Discussions
    Replies: 1
    Last Post: 04-16-2010, 10:53 AM
  2. OC MasterCard Help.
    By AlexJ in forum General Builder Questions All Aircraft Types
    Replies: 15
    Last Post: 04-05-2010, 10:45 AM
  3. Mastercard OC
    By 150245 in forum OpenCockpits General Discussion
    Replies: 4
    Last Post: 03-09-2010, 02:02 PM
  4. [elements] Coding
    By null null in forum PM General Q & A
    Replies: 2
    Last Post: 12-02-2004, 12:59 PM
  5. PM commands don't work anymore via FSUIPC
    By null null in forum PM General Q & A
    Replies: 5
    Last Post: 11-27-2004, 03:48 PM