Changeset 574

Show
Ignore:
Timestamp:
08/27/07 08:41:50 (16 years ago)
Author:
ppalmers
Message:

- scons can now auto-generate the DBUS interface adaptor/proxy classes
- implemented a very basic DBUS client/server pair:

test-dbus and test-dbus-server

- some small missing key fixes in the scons files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/external/dbus/SConscript

    r570 r574  
    2121dbus_env = Environment( ENV = buildenv ) 
    2222 
    23 CacheDir( 'cache/objects' ) 
     23#CacheDir( 'cache/objects' ) 
    2424 
    25 dbus_env.MergeFlags( env['DBUS1_FLAGS'] ) 
     25if env.has_key('DBUS1_FLAGS'): 
     26    dbus_env.MergeFlags( env['DBUS1_FLAGS'] ) 
    2627 
    2728# add the local version of libdbus++ 
     
    3031dbus_env.AppendUnique( LIBS=["dbus-c++"] ) 
    3132dbus_env.AppendUnique( CCFLAGS=["-DDBUS_API_SUBJECT_TO_CHANGE"] ) 
     33 
     34# this is required to indicate that the DBUS version we use has support 
     35# for platform dependent threading init functions 
     36# this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is 
     37# always true 
     38dbus_env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] ) 
    3239 
    3340sources = [ 
     
    4754] 
    4855 
    49 if env['DEBUG']: 
     56if env.has_key('DEBUG') and env['DEBUG']: 
    5057        dbus_env.AppendUnique( CCFLAGS=["-DDEBUG","-g"] ) 
    5158 
     
    8087 
    8188def dbusxx_xml2cpp_emitter(target, source, env): 
    82        dbus_env.Depends(target, dbusxx_xml2cpp) 
    83        return (target, source) 
     89    dbus_env.Depends(target, dbusxx_xml2cpp) 
     90    return (target, source) 
    8491 
    85 dbusxx_xml2cpp_builder = Builder(action = dbusxx_xml2cpp[0].abspath + ' $SOURCE --adaptor=$TARGET', 
    86        emitter = dbusxx_xml2cpp_emitter, 
    87        suffix = '.h', src_suffix = '.xml') 
     92dbusxx_xml2cpp_adaptor_builder = Builder(action = dbusxx_xml2cpp[0].abspath + ' $SOURCE --adaptor=$TARGET', 
     93    emitter = dbusxx_xml2cpp_emitter, 
     94    suffix = '.h', src_suffix = '.xml') 
    8895 
    89 Export('dbusxx_xml2cpp_builder') 
     96dbusxx_xml2cpp_proxy_builder = Builder(action = dbusxx_xml2cpp[0].abspath + ' $SOURCE --proxy=$TARGET', 
     97    emitter = dbusxx_xml2cpp_emitter, 
     98    suffix = '.h', src_suffix = '.xml') 
     99 
     100Export('dbusxx_xml2cpp_adaptor_builder') 
     101Export('dbusxx_xml2cpp_proxy_builder') 
  • trunk/libffado/SConstruct

    r573 r574  
    139139        env.AppendUnique( CCFLAGS=["-O2"] ) 
    140140 
     141# this is required to indicate that the DBUS version we use has support 
     142# for platform dependent threading init functions 
     143# this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is 
     144# always true 
     145env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] ) 
     146 
    141147if env['ENABLE_ALL']: 
    142148        env['ENABLE_BEBOB'] = True 
     
    170176# The relevant MergeFlags-calls should be moved to the SConscript-files where 
    171177# its needed... 
    172 env.MergeFlags( env['LIBRAW1394_FLAGS'] ) 
    173 env.MergeFlags( env['LIBAVC1394_FLAGS'] ) 
    174 env.MergeFlags( env['LIBIEC61883_FLAGS'] ) 
    175 env.MergeFlags( env['ALSA_FLAGS'] ) 
    176 env.MergeFlags( env['LIBXML26_FLAGS'] ) 
    177 env.MergeFlags( env['LIBLO_FLAGS'] ) 
     178if env.has_key('LIBRAW1394_FLAGS'): 
     179    env.MergeFlags( env['LIBRAW1394_FLAGS'] ) 
     180if env.has_key('LIBAVC1394_FLAGS'): 
     181    env.MergeFlags( env['LIBAVC1394_FLAGS'] ) 
     182if env.has_key('LIBIEC61883_FLAGS'): 
     183    env.MergeFlags( env['LIBIEC61883_FLAGS'] ) 
     184if env.has_key('ALSA_FLAGS'): 
     185    env.MergeFlags( env['ALSA_FLAGS'] ) 
     186if env.has_key('LIBXML26_FLAGS'): 
     187    env.MergeFlags( env['LIBXML26_FLAGS'] ) 
     188if env.has_key('LIBLO_FLAGS'): 
     189    env.MergeFlags( env['LIBLO_FLAGS'] ) 
    178190 
    179191# 
     
    204216env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) ) 
    205217 
    206  
    207 subdirs=['src','libffado','tests','support','external'] 
     218# build helper tools first 
     219subdirs=['external'] 
    208220if build_base: 
    209221        env['build_base']="#/"+build_base 
     
    214226        env.SConscript( dirs=subdirs, exports="env" ) 
    215227 
     228if not env.GetOption('clean'): 
     229    Default( 'external' ) 
     230     
     231Import( 'dbusxx_xml2cpp_adaptor_builder' ) 
     232env.Append(BUILDERS = {'XML2CPP_ADAPTOR' : dbusxx_xml2cpp_adaptor_builder}) 
     233 
     234Import( 'dbusxx_xml2cpp_proxy_builder' ) 
     235env.Append(BUILDERS = {'XML2CPP_PROXY' : dbusxx_xml2cpp_proxy_builder}) 
     236 
     237# now build our own stuff, which can use the tools defined above 
     238subdirs=['src','libffado','tests','support'] 
     239if build_base: 
     240        env['build_base']="#/"+build_base 
     241        for subdir in subdirs: 
     242                env.SConscript( dirs=subdir, exports="env", build_dir=build_base+subdir ) 
     243else: 
     244        env['build_base']="#/" 
     245        env.SConscript( dirs=subdirs, exports="env" ) 
     246 
    216247 
    217248# By default only src is built but all is cleaned 
    218249if not env.GetOption('clean'): 
    219         Default( 'external' ) 
    220         Default( 'src' ) 
    221         if env['BUILD_TESTS']: 
    222                 Default( 'tests' ) 
    223         #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) ) 
    224         env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) ) 
     250    Default( 'src' ) 
     251    if env['BUILD_TESTS']: 
     252        Default( 'tests' ) 
     253    #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) ) 
     254    env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) ) 
  • trunk/libffado/support/mixer/SConscript

    r571 r574  
    33Import( 'env' ) 
    44 
    5 if env['HAVE_PYUIC']: 
     5if env.has_key('HAVE_PYUIC') and env['HAVE_PYUIC']: 
    66 
    77        env = env.Copy() 
  • trunk/libffado/tests/SConscript

    r567 r574  
    55env = env.Copy() 
    66 
    7 env.PrependUnique( CPPPATH=["#/src"] ) 
    8 env.PrependUnique( LIBPATH=[env['build_base']+"src"] ) 
    9 env.PrependUnique( LIBS=["ffado"] ) 
     7env.PrependUnique( CPPPATH=["#/src", "#/external/dbus/include"] ) 
     8env.PrependUnique( LIBPATH=[env['build_base']+"src", env['build_base']+"external/dbus"] ) 
     9env.PrependUnique( LIBS=["ffado", "dbus-c++"] ) 
     10 
     11env.MergeFlags( ["!pkg-config --cflags --libs dbus-1"] ) 
    1012 
    1113# 
     
    1315# 
    1416#for app in ["test-ffado", "test-extplugcmd", "test-fw410", "test-volume", "test-mixer", "test-cycletimer", "test-timestampedbuffer", "test-ieee1394service", "test-streamdump"]: 
    15 for app in ["test-ffado", "test-fw410", "test-cycletimer", "test-timestampedbuffer", "test-ieee1394service", "test-streamdump", "test-dbus"]: 
    16        env.Program( target=app, source = app+".cpp" ) 
     17for app in ["test-ffado", "test-fw410", "test-cycletimer", "test-timestampedbuffer", "test-ieee1394service", "test-streamdump"]: 
     18    env.Program( target=app, source = app+".cpp" ) 
    1719 
    1820env.Program( target="test-sytmonitor", source = env.Split( "test-sytmonitor.cpp SytMonitor.cpp" ) ) 
    1921 
     22env.XML2CPP_PROXY('controlclient-glue.h', 'controlstuff.xml') 
     23env.Program( target="test-dbus", source = env.Split( "test-dbus.cpp controlclient.cpp" ) ) 
     24 
     25env.XML2CPP_ADAPTOR('controlserver-glue.h', 'controlstuff.xml') 
     26env.Program( target="test-dbus-server", source = env.Split( "test-dbus-server.cpp controlserver.cpp" ) ) 
     27 
    2028env.SConscript( dirs="streaming", exports="env" ) 
    2129 
  • trunk/libffado/tests/test-dbus.cpp

    r565 r574  
    11/* 
    22 * Copyright (C) 2007 by Pieter Palmers 
    3  * Copyright (C) 2005-2007 by Daniel Wagner 
    43 * 
    54 * This file is part of FFADO 
     
    2423 */ 
    2524 
    26 #include <libraw1394/raw1394.h> 
    27 #include <libiec61883/iec61883.h> 
    28 #include <libavc1394/avc1394.h> 
    29  
    3025#include <argp.h> 
    3126#include <stdlib.h> 
    3227#include <iostream> 
     28#include <signal.h> 
     29 
     30#include "controlclient.h" 
     31#include <dbus-c++/dbus.h> 
    3332 
    3433using namespace std; 
     34 
     35DECLARE_GLOBAL_DEBUG_MODULE; 
    3536 
    3637//////////////////////////////////////////////// 
    3738// arg parsing 
    3839//////////////////////////////////////////////// 
    39 const char *argp_program_version = "test-echo 0.1"; 
     40const char *argp_program_version = "test-dbus 0.1"; 
    4041const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 
    41 static char doc[] = "test-echo -- test program for the ECHO AUDIOFIRE devices"; 
    42 static char args_doc[] = "NODE_ID"; 
     42static char doc[] = "test-dbus -- test client for the DBUS interface"; 
     43static char args_doc[] = ""; 
    4344static struct argp_option options[] = { 
    4445    {"verbose",   'v', 0,           0,  "Produce verbose output" }, 
    45     {"port",      'p', "PORT",      0,  "Set port" }, 
    4646   { 0 } 
    4747}; 
     
    5151    arguments() 
    5252        : verbose( false ) 
    53         , test( false ) 
    54         , port( 0 ) 
    5553        { 
    5654            args[0] = 0; 
    5755        } 
    5856 
    59     char* args[1]; 
     57    char* args[50]; 
    6058    bool  verbose; 
    61     bool  test; 
    62     int   port; 
    6359} arguments; 
    6460 
     
    7167    struct arguments* arguments = ( struct arguments* ) state->input; 
    7268 
    73     char* tail; 
     69//     char* tail; 
    7470    switch (key) { 
    7571    case 'v': 
    7672        arguments->verbose = true; 
    7773        break; 
    78     case 't': 
    79         arguments->test = true; 
    80         break; 
    81     case 'p': 
    82         errno = 0; 
    83         arguments->port = strtol(arg, &tail, 0); 
    84         if (errno) { 
    85             perror("argument parsing failed:"); 
    86             return errno; 
    87         } 
    88         break; 
    8974    case ARGP_KEY_ARG: 
    90         if (state->arg_num >= 1) { 
     75        if (state->arg_num >= 50) { 
    9176            // Too many arguments. 
    9277            argp_usage (state); 
     
    9580        break; 
    9681    case ARGP_KEY_END: 
    97         if (state->arg_num < 1) { 
    98             // Not enough arguments. 
    99             argp_usage (state); 
    100         } 
    10182        break; 
    10283    default: 
     
    11192// main 
    11293////////////////////////// 
     94 
     95DBus::BusDispatcher dispatcher; 
     96static const int THREADS = 1; 
     97static bool spin = true; 
     98 
     99void leave( int sig ) 
     100{ 
     101    spin = false; 
     102    dispatcher.leave(); 
     103} 
     104 
     105void* worker_thread( void* ) 
     106{ 
     107    DBus::Connection conn = DBus::Connection::SessionBus(); 
     108 
     109    Control::ControlClient client(conn, SERVER_PATH, SERVER_NAME); 
     110 
     111    int i=0; 
     112    while(spin) 
     113    { 
     114        try { 
     115            client.Echo(i++); 
     116        } catch(...) { 
     117            cout << "error on Echo()\n"; 
     118        }; 
     119//         try { 
     120//             std::map< DBus::String, DBus::String > info = client.Info(); 
     121//             cout << info["testset1"] << " - " << info["testset2"] << std::endl; 
     122//         } catch(...) { 
     123//             cout << "error on Info()\n"; 
     124//         }; 
     125 
     126        cout << "* " << i << "*\n"; 
     127        sleep(1); 
     128    } 
     129 
     130    return NULL; 
     131} 
     132 
     133void run_client_tests() { 
     134    DBus::default_dispatcher = &dispatcher; 
     135 
     136    pthread_t thread; 
     137 
     138    pthread_create(&thread, NULL, worker_thread, NULL); 
     139 
     140    dispatcher.enter(); 
     141 
     142    pthread_join(thread, NULL); 
     143} 
     144 
    113145int 
    114146main(int argc, char **argv) 
    115147{ 
     148    signal(SIGTERM, leave); 
     149    signal(SIGINT, leave); 
     150     
     151    setDebugLevel(DEBUG_LEVEL_VERBOSE); 
     152     
    116153    // arg parsing 
    117154    argp_parse (&argp, argc, argv, 0, 0, &arguments); 
    118155 
    119156    errno = 0; 
    120     char* tail; 
    121     int iNodeId = strtol(arguments.args[0], &tail, 0); 
     157//     char* tail; 
     158     
    122159    if (errno) { 
    123     perror("argument parsing failed:"); 
    124     return -1; 
     160        perror("argument parsing failed:"); 
     161        return -1; 
    125162    } 
    126163 
    127     raw1394handle_t pHandle = raw1394_new_handle_on_port( arguments.port ); 
    128     if ( !pHandle ) { 
    129         if ( !errno ) { 
    130             cerr << "libraw1394 not compatible" << endl; 
    131         } else { 
    132             perror( "Could not get 1394 handle" ); 
    133             cerr << "Is ieee1394 and raw1394 driver loaded?" << endl; 
    134         } 
    135         return -1; 
    136     } 
    137     quadlet_t cmd[6]; 
    138     unsigned int response_len; 
     164    debugOutput(DEBUG_LEVEL_NORMAL, "DBUS test application\n"); 
     165 
     166    DBus::_init_threading(); 
     167 
     168    run_client_tests(); 
     169 
     170    debugOutput(DEBUG_LEVEL_NORMAL, "bye...\n"); 
    139171     
    140 //     cerr << "Opening descriptor" << endl; 
    141 //     0h 05m 21.760442s - GetDescriptorOpen:  cmd[0]= < 0x00 0x60 0x08 0x80 0x01 0xFF> 
    142 //     0h 05m 21.760687s - GetDescriptorOpen: resp[0]= < 0x09 0x60 0x08 0x80 0x01 0xFF > ACCEPTED 
    143  
    144  
    145 //     cmd[0] = 0x00600880; 
    146 //     cmd[1] = 0x01FF0000; 
    147 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 
    148 //     usleep(100000);  
    149 //      
    150 //     cerr << "Reading descriptor" << endl; 
    151 // //     0h 05m 21.760700s - GetDescriptorRead:  cmd[0]= < 0x00 0x60 0x09 0x80 0xFF 0xFF 0x00 0x00 0x00 0x00> 
    152 // //     0h 05m 21.761123s - GetDescriptorRead: resp[0]= < 0x09 0x60 0x09 0x80 0x11 0xFF 0x01 0xF6 0x00 0x00 0x03 0x9E  
    153 //     cmd[0] = 0x00600980; 
    154 //     cmd[1] = 0xFFFF0000; 
    155 //     cmd[2] = 0x00000000; 
    156 //     cmd[2] = 0x00000000; 
    157 //       
    158 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 3, &response_len, 10); 
    159 //     usleep(100000); 
    160 //      
    161 //     cerr << "Closing descriptor" << endl; 
    162 //     cmd[0] = 0x00600880; 
    163 //     cmd[1] = 0x00FF0000; 
    164 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 
    165 //     usleep(100000); 
    166  
    167     cerr << "getting signal source" << endl; 
    168 //     0h 05m 21.762917s - at line 2283, fMaxAudioOutputChannels=2, fMaxAudioInputChannels=0 
    169 //     0h 05m 21.762919s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x00> 
    170 //     0h 05m 21.763149s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x60 0x60 0x00 0xFF 0x00 > IMPLEMENTED 
    171 //     0h 05m 21.763167s - Isoch out 0 gets its signal from sub/unit 0x60 Source Plug 0 
    172 //     0h 05m 21.763170s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x80> 
    173 //     0h 05m 21.763376s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x01 0xFF 0x80 > IMPLEMENTED 
    174 //     0h 05m 21.763394s - Isoch out 128 gets its signal from sub/unit 0x60 Source Plug 1 
    175 //     0h 05m 21.763397s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x81> 
    176 //     0h 05m 21.763637s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x02 0xFF 0x81 > IMPLEMENTED 
    177 //     0h 05m 21.763654s - Isoch out 129 gets its signal from sub/unit 0x60 Source Plug 2 
    178  
    179 //     0h 05m 21.764895s - Starting to look at subunit 1.  fNumberOfSubUnits = 2 
    180 //     0h 05m 21.764897s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x00> 
    181 //     0h 05m 21.765129s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x20 0xFF 0x00 0x60 0x00 > IMPLEMENTED 
    182 //     0h 05m 21.765140s - Subunit type12, addr:0x60 dest 0 gets its signal from sub/unit 0xff Source Plug 0 
    183 //     0h 05m 21.765142s - subunit 96 dest plug 0 is routed 
    184 //     0h 05m 21.765143s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x01> 
    185 //     0h 05m 21.765364s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0xFF 0x80 0x60 0x01 > IMPLEMENTED 
    186 //     0h 05m 21.765382s - Subunit type12, addr:0x60 dest 1 gets its signal from sub/unit 0xff Source Plug 128 
    187 //     0h 05m 21.765385s -      Plug being changed from 0x80 to 1 for internal bookeeping. 
    188 //     0h 05m 21.765389s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x02> 
    189 //     0h 05m 21.765632s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0xFF 0x81 0x60 0x02 > IMPLEMENTED 
    190 //     0h 05m 21.765651s - Subunit type12, addr:0x60 dest 2 gets its signal from sub/unit 0xff Source Plug 129 
    191 //     0h 05m 21.765653s -      Plug being changed from 0x81 to 2 for internal bookeeping. 
    192 //     0h 05m 21.765657s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x03> 
    193 //     0h 05m 21.765874s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x03 0x60 0x03 > IMPLEMENTED 
    194 //     0h 05m 21.765892s - Subunit type12, addr:0x60 dest 3 gets its signal from sub/unit 0x60 Source Plug 3 
    195  
    196     cmd[0] = 0x01FF1AFF; 
    197     cmd[1] = 0xFFFE6000; 
    198     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 
    199 //     usleep(100000); 
    200      
    201     cmd[0] = 0x01FF1AFF; 
    202     cmd[1] = 0xFFFEFF00; 
    203     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10); 
    204     usleep(100000); 
    205  
    206  
    207  
    208     raw1394_destroy_handle( pHandle ); 
    209172    return 0; 
    210173}