Changeset 142

Show
Ignore:
Timestamp:
01/03/06 15:08:13 (18 years ago)
Author:
wagi
Message:

2006-01-04 Daniel Wagner <wagi@monom.org>

  • tests/test-extplugcmd.cpp: Changed test application
    to use PlugType? and PlugName? command for testing.
  • src/libfreebobavc/avc_extended_plug_info.cpp (serialize):
    The string.length() thing did not work as expected. A workaround
    added which converts the C++ string into a C string before strlen
    is used.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libfreebob/ChangeLog

    r141 r142  
     12006-01-04  Daniel Wagner  <wagi@monom.org> 
     2 
     3        * tests/test-extplugcmd.cpp: Changed test application 
     4        to use PlugType and PlugName command for testing. 
     5 
     6        * src/libfreebobavc/avc_extended_plug_info.cpp (serialize):  
     7        The string.length() thing did not work as expected. A workaround 
     8        added which converts the C++ string into a C string before strlen 
     9        is used. 
     10 
    1112006-01-03  Daniel Wagner  <wagi@monom.org> 
    212 
  • trunk/libfreebob/src/libfreebobavc/avc_extended_plug_info.cpp

    r140 r142  
    9696ExtendedPlugInfoPlugNameSpecificData::serialize( IOSSerialize& se ) 
    9797{ 
    98     se.write( ( byte_t ) m_name.length(), 
     98    byte_t length = strlen( m_name.c_str() ); 
     99    se.write( length, 
    99100              "ExtendedPlugInfoPlugNameSpecificData: string length" ); 
    100     for ( unsigned int i = 0; i < m_name.length(); ++i ) { 
     101    for ( unsigned int i = 0; i < length; ++i ) { 
    101102        se.write( static_cast<byte_t>( m_name[i] ), 
    102103                  "ExtendedPlugInfoPlugNameSpecificData: char" ); 
  • trunk/libfreebob/tests/test-extplugcmd.cpp

    r125 r142  
    11/* test-extplugcmd.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     2 * Copyright (C) 2005,06 by Daniel Wagner 
    33 * 
    44 * This file is part of FreeBob. 
     
    2626#include <argp.h> 
    2727 
    28  
    2928using namespace std; 
    3029 
     
    3231// arg parsing 
    3332//////////////////////////////////////////////// 
    34 const char *argp_program_version = "test-extplugcmd 0.1"; 
     33const char *argp_program_version = "test-extplugcmd 0.2"; 
    3534const char *argp_program_bug_address = "<freebob-devel@lists.sf.net>"; 
    36 static char doc[] = "test-extplugcmd -- get extended plug info"; 
    37 static char args_doc[] = "NODE_ID PLUG_ID"; 
     35static char doc[] = "test-extplugcmd -- tests some extended plug info commands on a BeBoB device"; 
     36static char args_doc[] = "NODE_ID"; 
    3837static struct argp_option options[] = { 
    39     {"verbose",   'v', 0,           0,            "Produce verbose output" }, 
    40     {"test",      't', 0,           0,            "Do tests instead get/set action" }, 
     38    {"verbose",   'v', 0,           0,  "Produce verbose output" }, 
    4139    {"port",      'p', "PORT",      0,  "Set port" }, 
    4240   { 0 } 
     
    5149        { 
    5250            args[0] = 0; 
    53             args[1] = 0; 
    54         } 
    55  
    56     char* args[2]; 
     51        } 
     52 
     53    char* args[1]; 
    5754    bool  verbose; 
    5855    bool  test; 
     
    8582        break; 
    8683    case ARGP_KEY_ARG: 
    87         if (state->arg_num >= 2) { 
     84        if (state->arg_num >= 1) { 
    8885            // Too many arguments. 
    8986            argp_usage (state); 
     
    9289        break; 
    9390    case ARGP_KEY_END: 
    94         if (state->arg_num < 2) { 
     91        if (state->arg_num < 1) { 
    9592            // Not enough arguments. 
    9693            argp_usage (state); 
     
    104101 
    105102static struct argp argp = { options, parse_opt, args_doc, doc }; 
    106  
    107 //////////////////////////////////////// 
    108 // Test application 
    109 //////////////////////////////////////// 
    110 void 
    111 doTest(Ieee1394Service& ieee1394service, int node_id, int plug_id) 
    112 { 
    113     PlugInfoCmd plugInfoCmd( &ieee1394service ); 
    114     plugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
    115     plugInfoCmd.setNodeId( node_id ); 
    116     plugInfoCmd.setVerbose( true ); 
    117  
    118     if ( !plugInfoCmd.fire() ) { 
    119         return; 
    120     } 
    121     return; 
    122 } 
    123103 
    124104//////////////////////////////////////// 
     
    127107 
    128108bool 
    129 doApp(Ieee1394Service& ieee1394service, int node_id, int plug_id ) 
     109doPlugType( Ieee1394Service& ieee1394service, int node_id ) 
    130110{ 
    131111    ExtendedPlugInfoCmd extPlugInfoCmd( &ieee1394service ); 
    132     UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, plug_id ); 
    133     extPlugInfoCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Output, 
     112    UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0 ); 
     113    extPlugInfoCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, 
    134114                                                PlugAddress::ePAM_Unit, 
    135115                                                unitPlugAddress ) ); 
     
    146126    } 
    147127 
    148     ExtendedPlugInfoInfoType extendedPlugInfoInfoType2( ExtendedPlugInfoInfoType::eIT_PlugName ); 
     128    ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 
     129    if ( infoType 
     130         && infoType->m_plugType ) 
     131    { 
     132            plug_type_t plugType = infoType->m_plugType->m_plugType; 
     133 
     134            printf( "iso input plug %d is of type %d (%s)\n", 
     135                    0, 
     136                    plugType, 
     137                    extendedPlugInfoPlugTypeToString( plugType ) ); 
     138    } else { 
     139        fprintf( stderr, "Not plug name specific data found\n" ); 
     140        return false; 
     141    } 
     142 
     143    return true; 
     144
     145 
     146 
     147bool 
     148doPlugName( Ieee1394Service& ieee1394service, int node_id ) 
     149
     150    ExtendedPlugInfoCmd extPlugInfoCmd( &ieee1394service ); 
     151    UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0 ); 
     152    extPlugInfoCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, 
     153                                                PlugAddress::ePAM_Unit, 
     154                                                unitPlugAddress ) ); 
     155    extPlugInfoCmd.setNodeId( node_id ); 
     156    extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); 
     157    extPlugInfoCmd.setVerbose( arguments.verbose ); 
     158    ExtendedPlugInfoInfoType extendedPlugInfoInfoType( ExtendedPlugInfoInfoType::eIT_PlugName ); 
    149159    extendedPlugInfoInfoType.initialize(); 
    150     extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType2 ); 
     160    extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 
     161 
    151162    if ( extPlugInfoCmd.fire() ) { 
    152163        CoutSerializer se; 
     
    154165    } 
    155166 
     167    ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); 
     168    if ( infoType 
     169         && infoType->m_plugName ) 
     170    { 
     171        printf( "iso input plug %d has name '%s'\n", 
     172                0, 
     173               infoType->m_plugName->m_name.c_str() ); 
     174    } else { 
     175        fprintf( stderr, "Not plug name specific data found\n" ); 
     176        return false; 
     177    } 
    156178 
    157179    return true; 
     180} 
     181 
     182bool 
     183doApp(Ieee1394Service& ieee1394service, int node_id ) 
     184{ 
     185    bool success; 
     186 
     187    success = doPlugType( ieee1394service, node_id ); 
     188    success &= doPlugName( ieee1394service, node_id ); 
     189 
     190    return success; 
    158191} 
    159192 
     
    174207        return -1; 
    175208    } 
    176     int plug_id = strtol(arguments.args[1], &tail, 0); 
    177     if (errno) { 
    178         perror("argument parsing failed:"); 
    179         return -1; 
    180     } 
    181  
    182209    Ieee1394Service ieee1394service; 
    183210    if ( !ieee1394service.initialize( arguments.port ) ) { 
     
    186213    } 
    187214 
    188     if ( arguments.test ) { 
    189         doTest( ieee1394service, node_id, plug_id ); 
    190     } else { 
    191         doApp( ieee1394service, node_id, plug_id ); 
    192     } 
     215    doApp( ieee1394service, node_id ); 
    193216 
    194217    return 0; 
  • trunk/libfreebob/TODO

    r141 r142  
    66  the DebugModule's methods. The idea is to have a more consistant 
    77  code. 
     8- All libfreebobavc interfaces should use references instead of pointers 
     9  like in  ExtendedPlugInfoCmd( Ieee1394Service* ieee1394service, ... ) 
     10  ->  ExtendedPlugInfoCmd( Ieee1394Service& ieee1394service,