Changeset 142
- Timestamp:
- 01/03/06 15:08:13 (18 years ago)
- Files:
-
- trunk/libfreebob/ChangeLog (modified) (1 diff)
- trunk/libfreebob/src/libfreebobavc/avc_extended_plug_info.cpp (modified) (1 diff)
- trunk/libfreebob/tests/test-extplugcmd.cpp (modified) (12 diffs)
- trunk/libfreebob/TODO (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libfreebob/ChangeLog
r141 r142 1 2006-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 1 11 2006-01-03 Daniel Wagner <wagi@monom.org> 2 12 trunk/libfreebob/src/libfreebobavc/avc_extended_plug_info.cpp
r140 r142 96 96 ExtendedPlugInfoPlugNameSpecificData::serialize( IOSSerialize& se ) 97 97 { 98 se.write( ( byte_t ) m_name.length(), 98 byte_t length = strlen( m_name.c_str() ); 99 se.write( length, 99 100 "ExtendedPlugInfoPlugNameSpecificData: string length" ); 100 for ( unsigned int i = 0; i < m_name.length(); ++i ) {101 for ( unsigned int i = 0; i < length; ++i ) { 101 102 se.write( static_cast<byte_t>( m_name[i] ), 102 103 "ExtendedPlugInfoPlugNameSpecificData: char" ); trunk/libfreebob/tests/test-extplugcmd.cpp
r125 r142 1 1 /* test-extplugcmd.cpp 2 * Copyright (C) 2005 by Daniel Wagner2 * Copyright (C) 2005,06 by Daniel Wagner 3 3 * 4 4 * This file is part of FreeBob. … … 26 26 #include <argp.h> 27 27 28 29 28 using namespace std; 30 29 … … 32 31 // arg parsing 33 32 //////////////////////////////////////////////// 34 const char *argp_program_version = "test-extplugcmd 0. 1";33 const char *argp_program_version = "test-extplugcmd 0.2"; 35 34 const 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";35 static char doc[] = "test-extplugcmd -- tests some extended plug info commands on a BeBoB device"; 36 static char args_doc[] = "NODE_ID"; 38 37 static 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" }, 41 39 {"port", 'p', "PORT", 0, "Set port" }, 42 40 { 0 } … … 51 49 { 52 50 args[0] = 0; 53 args[1] = 0; 54 } 55 56 char* args[2]; 51 } 52 53 char* args[1]; 57 54 bool verbose; 58 55 bool test; … … 85 82 break; 86 83 case ARGP_KEY_ARG: 87 if (state->arg_num >= 2) {84 if (state->arg_num >= 1) { 88 85 // Too many arguments. 89 86 argp_usage (state); … … 92 89 break; 93 90 case ARGP_KEY_END: 94 if (state->arg_num < 2) {91 if (state->arg_num < 1) { 95 92 // Not enough arguments. 96 93 argp_usage (state); … … 104 101 105 102 static struct argp argp = { options, parse_opt, args_doc, doc }; 106 107 ////////////////////////////////////////108 // Test application109 ////////////////////////////////////////110 void111 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 }123 103 124 104 //////////////////////////////////////// … … 127 107 128 108 bool 129 do App(Ieee1394Service& ieee1394service, int node_id, int plug_id )109 doPlugType( Ieee1394Service& ieee1394service, int node_id ) 130 110 { 131 111 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, 134 114 PlugAddress::ePAM_Unit, 135 115 unitPlugAddress ) ); … … 146 126 } 147 127 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 147 bool 148 doPlugName( 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 ); 149 159 extendedPlugInfoInfoType.initialize(); 150 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType2 ); 160 extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); 161 151 162 if ( extPlugInfoCmd.fire() ) { 152 163 CoutSerializer se; … … 154 165 } 155 166 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 } 156 178 157 179 return true; 180 } 181 182 bool 183 doApp(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; 158 191 } 159 192 … … 174 207 return -1; 175 208 } 176 int plug_id = strtol(arguments.args[1], &tail, 0);177 if (errno) {178 perror("argument parsing failed:");179 return -1;180 }181 182 209 Ieee1394Service ieee1394service; 183 210 if ( !ieee1394service.initialize( arguments.port ) ) { … … 186 213 } 187 214 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 ); 193 216 194 217 return 0; trunk/libfreebob/TODO
r141 r142 6 6 the DebugModule's methods. The idea is to have a more consistant 7 7 code. 8 - All libfreebobavc interfaces should use references instead of pointers 9 like in ExtendedPlugInfoCmd( Ieee1394Service* ieee1394service, ... ) 10 -> ExtendedPlugInfoCmd( Ieee1394Service& ieee1394service,