Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    150+ Forum Groupie
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    227
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Help with FSbus C++ software

    Hi all,

    I'm busy to transfer my old fsbus software to the latest version, but I need some help with it.

    I'm using an offsets of the TSR software of Thomas Richter.

    I want to write to offset 0x6DB7 bit 0 ( = below glide slope annunciator).

    But what's the format, you write to a specific bit ?

    I can't find it in the doc's provided.

    Hope someone can help.

    Best regards

    Jan Geurtsen

  2. #2
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Hi,
    yes that isnt in the Documentation. It is a part of C++.

    You have to define the Offset that you are need and every single Bit.
    A part of the .h file.
    Code:
    enum _OVERHEADIN {
    CI_No_Smoking_on = (GROUP_OVERHEADIN * OBJECTS_PER_GROUP),
    FS_LIGHT};
    
    #define FS_LIGHT_NAV		0x01    //01
    #define FS_LIGHT_Strobe		0x02    //02
    With the 0x01 you assing bit 0.

    0x01 = Bit0
    0x02 = Bit1
    0x04 = Bit2
    0x08 = Bit3
    0x10 = Bit4
    0x20 = Bit5
    0x40 = Bit6
    0x80 = Bit7

    Than you can use the bits in you code.
    A Sample Part from my Cockpit.
    Code:
    	
    case CI_SWITCH_Strobe_Stad:
    		if (val==0)
    		{
    			Light |= FS_LIGHT_NAV;
    			Light |= FS_LIGHT_Strobe;
    			//printf("Light On \n");
    			FsWrite (FS_LIGHT,Light);
    		}
    		else
    		{
    			Light &= ~FS_LIGHT_NAV;
    			Light &= ~FS_LIGHT_Strobe;
    			//printf("Light Off \n");
    			FsWrite (FS_LIGHT,Light);
    		}
    		break;
    That is an input for one Light Switch.

    Stefan

  3. #3
    150+ Forum Groupie
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    227
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Quote Originally Posted by sgaert View Post
    Hi,
    yes that isnt in the Documentation. It is a part of C++.

    You have to define the Offset that you are need and every single Bit.
    A part of the .h file.
    Code:
    enum _OVERHEADIN {
    CI_No_Smoking_on = (GROUP_OVERHEADIN * OBJECTS_PER_GROUP),
    FS_LIGHT};
    
    #define FS_LIGHT_NAV		0x01    //01
    #define FS_LIGHT_Strobe		0x02    //02
    With the 0x01 you assing bit 0.

    0x01 = Bit0
    0x02 = Bit1
    0x04 = Bit2
    0x08 = Bit3
    0x10 = Bit4
    0x20 = Bit5
    0x40 = Bit6
    0x80 = Bit7

    Than you can use the bits in you code.
    A Sample Part from my Cockpit.
    Code:
    	
    case CI_SWITCH_Strobe_Stad:
    		if (val==0)
    		{
    			Light |= FS_LIGHT_NAV;
    			Light |= FS_LIGHT_Strobe;
    			//printf("Light On \n");
    			FsWrite (FS_LIGHT,Light);
    		}
    		else
    		{
    			Light &= ~FS_LIGHT_NAV;
    			Light &= ~FS_LIGHT_Strobe;
    			//printf("Light Off \n");
    			FsWrite (FS_LIGHT,Light);
    		}
    		break;
    That is an input for one Light Switch.

    Stefan
    Thanks Stefan,
    I doesn't reconize it as a bit input.

    Best regards

    Jan Geurtsen

  4. #4
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Yes that is a Bit Input.

    http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
    Look to Bitwise operators.

  5. #5
    150+ Forum Groupie
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    227
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Hi

    I've made some code (see below) which light my hardware Exec light of the Project magenta CDU.
    Will this be work?
    I'm not able to test it because I'm abroad.

    It's using adress 0x052c bit 1 so I add the following to the .h file

    #ifndef _TSR_H
    #define _TSR_H

    #define FS_CduExecLight 0x01 //01

    void BuildTsrObjects();
    void cbTsr (int oid, int val, double dval);

    enum e_Tsr {

    C_CduExecLight = (GROUP_TSR * OBJECTS_PER_GROUP),

    };

    #endif


    And this to the .cpp file:

    #include "stdafx.h"
    #include "Tsr.h"


    extern void TsrBuildObjects()
    {

    MkFsbusObject(BTP_D_OUT, C_CduExecLight,"OID",cbTsr,17,24);
    MkFsObject(FS_CduExecLight, "OID", cbTsr, 0x052c,2, TP_I16, FS_NORMAL);
    }
    void cbTsr( int oid,int val,double dval)
    {
    switch(oid)

    {
    case FS_CduExecLight:
    FsbusWrite (C_CduExecLight,val);
    }

    }



    Best regards

    Jan Geurtsen

  6. #6
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Hi Jan,

    that is a realy hard question.
    First yes it will work, BUT that is fortuity.
    It only work i case of that you Value is in Bit0.
    You dont readout the bit you read the Value in case on Bit0 it is both the same.

    That always work as long you only need Bit0 if you like to use Bit1 or greater you need other code.

    In my code a had make 1 funktion how switches all Lights. I was to lame to write always the same code for every output.

    As first that is only for Outputs controlled by Bitīs. Im my case the max Number of Bits in a Offset is 8. It is possible to add more.

    As First we need an array with all our Informations.
    I use that Style FS_Objekt, Output_Bit0, Output_Bit1, Output_Bit2,.... and so on. Importend is that you have to fill every "line" of the array complet. I had made an C_non Output to an Output that you dont have connectet on your IO or DOut card.
    That you have to write to the cpp file.
    Code:
    int LEDAusgabe[][9]={{FS_APAusgabe1,CO_APDisA,CO_APCmdA,CO_APCmdB,CO_APCwsA,CO_APCwsB,CO_APVS,CO_APALT,CO_APAPP},
    {FS_APAusgabe2,CO_APLOC,CO_APLNav,CO_APVNav,CO_APFLCH,CO_APHDGHold,CO_APIAS,CO_APN1,CO_APAT},
    {FS_OHLED1,CO_FUEL_PUMP_LEFT_FWD,CO_FUEL_PUMP_LEFT_AFT,CO_FUEL_PUMP_CENTRE_LEFT_LIGHT,CO_FUEL_PUMP_CENTRE_RIGHT_LIGHT,CO_FUEL_PUMP_RIGHT_FWD,CO_FUEL_PUMP_RIGHT_AFT,CO_DOORS_WING_L_AFT,CO_DOORS_WING_R_AFT}
    };
    int LEDMax =19; // how many lines have your array??????????????
    Now there are all Objektbuild funktion.
    After that comes the normal Eventfunktion withe the "old" switch call. BUT we dont need any switch.
    Here is my complete funktion.
    Code:
    extern void LedausgabeEventHandler (int oid, int val, double dval)
    {
    	int Led;
    	Led = val;
    	int arrayPostition=-1;
    
    	for(int i=0;i<LEDMax ;i++)
    	{
    		if(oid==LEDAusgabe[i][0])
    			arrayPostition=i;
    	}
    
    	if(arrayPostition!=-1)
    	{
    		for (int i=1;i<9;i++)
    		{
    			int x=(Led & 0x01);
    			
    			FsbusWrite (LEDAusgabe[arrayPostition][i], x);
    			Led = (Led >> 1);
    		}
    	}
    }
    With that i Switch all my LED, btw. it takes 160ms to change all LED (300). That is so fast.

    Stefan

  7. #7
    150+ Forum Groupie
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    227
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Quote Originally Posted by sgaert View Post
    Hi Jan,

    that is a realy hard question.
    First yes it will work, BUT that is fortuity.
    It only work i case of that you Value is in Bit0.
    You dont readout the bit you read the Value in case on Bit0 it is both the same.

    That always work as long you only need Bit0 if you like to use Bit1 or greater you need other code.

    In my code a had make 1 funktion how switches all Lights. I was to lame to write always the same code for every output.

    As first that is only for Outputs controlled by Bitīs. Im my case the max Number of Bits in a Offset is 8. It is possible to add more.

    As First we need an array with all our Informations.
    I use that Style FS_Objekt, Output_Bit0, Output_Bit1, Output_Bit2,.... and so on. Importend is that you have to fill every "line" of the array complet. I had made an C_non Output to an Output that you dont have connectet on your IO or DOut card.
    That you have to write to the cpp file.
    Code:
    int LEDAusgabe[][9]={{FS_APAusgabe1,CO_APDisA,CO_APCmdA,CO_APCmdB,CO_APCwsA,CO_APCwsB,CO_APVS,CO_APALT,CO_APAPP},
    {FS_APAusgabe2,CO_APLOC,CO_APLNav,CO_APVNav,CO_APFLCH,CO_APHDGHold,CO_APIAS,CO_APN1,CO_APAT},
    {FS_OHLED1,CO_FUEL_PUMP_LEFT_FWD,CO_FUEL_PUMP_LEFT_AFT,CO_FUEL_PUMP_CENTRE_LEFT_LIGHT,CO_FUEL_PUMP_CENTRE_RIGHT_LIGHT,CO_FUEL_PUMP_RIGHT_FWD,CO_FUEL_PUMP_RIGHT_AFT,CO_DOORS_WING_L_AFT,CO_DOORS_WING_R_AFT}
    };
    int LEDMax =19; // how many lines have your array??????????????
    Now there are all Objektbuild funktion.
    After that comes the normal Eventfunktion withe the "old" switch call. BUT we dont need any switch.
    Here is my complete funktion.
    Code:
    extern void LedausgabeEventHandler (int oid, int val, double dval)
    {
        int Led;
        Led = val;
        int arrayPostition=-1;
     
        for(int i=0;i<LEDMax ;i++)
        {
            if(oid==LEDAusgabe[i][0])
                arrayPostition=i;
        }
     
        if(arrayPostition!=-1)
        {
            for (int i=1;i<9;i++)
            {
                int x=(Led & 0x01);
     
                FsbusWrite (LEDAusgabe[arrayPostition][i], x);
                Led = (Led >> 1);
            }
        }
    }
    With that i Switch all my LED, btw. it takes 160ms to change all LED (300). That is so fast.

    Stefan

    Hi Stefan.

    Have you declared i.e. CO_APDisA as offset 0x0000, bit x in the *.h file?



    Best regards

    Jan Geurtsen

  8. #8
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    if you read bits you dont need to declare anything in the H file, you only need to build the enum.

  9. #9
    150+ Forum Groupie
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    227
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Quote Originally Posted by sgaert View Post
    if you read bits you dont need to declare anything in the H file, you only need to build the enum.
    Hi Stefan,

    Thanks again for your great help.
    Do you have a example piece of the enum code?

    Best regards

    Jan Geurtsen

  10. #10
    300+ Forum Addict
    Join Date
    Feb 2008
    Location
    Krefeld, Germany
    Posts
    325
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with FSbus C++ software

    Code:
    enum e_LEDOUT{
    	CO_APDisA = (GROUP_LEDOUT * OBJECTS_PER_GROUP),
    	CO_APCmdA,
    	CO_APCmdB,
    	CO_APCwsA,
    	CO_APCwsB,
    	CO_APVS,
    	CO_APALT,
    	CO_APAPP,
    	FS_APAusgabe1,
    	FS_APAusgabe2,
    	CO_APLOC,
    	CO_APLNav,
    	CO_APVNav,
    	CO_APFLCH,// and so on
    };

Page 1 of 2 12 LastLast

Similar Threads

  1. FSBUS HELP
    By mondo50m in forum General Builder Questions All Aircraft Types
    Replies: 14
    Last Post: 10-31-2010, 04:53 PM
  2. Help with FSBUS DLL
    By Anderson/SBSP in forum I/O Interfacing and Hardware
    Replies: 9
    Last Post: 08-19-2009, 03:49 AM
  3. Fsbus 2.4.3
    By Anderson/SBSP in forum I/O Interfacing Hardware and Software
    Replies: 9
    Last Post: 11-30-2008, 04:25 PM
  4. FSBUS IO PCB HELP please
    By 388TH_A in forum I/O Interfacing Hardware and Software
    Replies: 1
    Last Post: 11-23-2008, 01:19 AM
  5. Anyone got fsbus 2.2?
    By mpl330 in forum I/O Interfacing Hardware and Software
    Replies: 8
    Last Post: 04-18-2007, 11:04 AM