root/trunk/libffado/tests/test-echo.cpp

Revision 742, 7.7 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  * Copyright (C) 2005-2007 by Daniel Wagner
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #include <libraw1394/raw1394.h>
26 #include <libiec61883/iec61883.h>
27 #include <libavc1394/avc1394.h>
28
29 #include <argp.h>
30 #include <stdlib.h>
31 #include <iostream>
32
33 using namespace std;
34
35 ////////////////////////////////////////////////
36 // arg parsing
37 ////////////////////////////////////////////////
38 const char *argp_program_version = "test-echo 0.1";
39 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>";
40 static char doc[] = "test-echo -- test program for the ECHO AUDIOFIRE devices";
41 static char args_doc[] = "NODE_ID";
42 static struct argp_option options[] = {
43     {"verbose",   'v', 0,           0,  "Produce verbose output" },
44     {"port",      'p', "PORT",      0,  "Set port" },
45    { 0 }
46 };
47
48 struct arguments
49 {
50     arguments()
51         : verbose( false )
52         , test( false )
53         , port( 0 )
54         {
55             args[0] = 0;
56         }
57
58     char* args[1];
59     bool  verbose;
60     bool  test;
61     int   port;
62 } arguments;
63
64 // Parse a single option.
65 static error_t
66 parse_opt( int key, char* arg, struct argp_state* state )
67 {
68     // Get the input argument from `argp_parse', which we
69     // know is a pointer to our arguments structure.
70     struct arguments* arguments = ( struct arguments* ) state->input;
71
72     char* tail;
73     switch (key) {
74     case 'v':
75         arguments->verbose = true;
76         break;
77     case 't':
78         arguments->test = true;
79         break;
80     case 'p':
81         errno = 0;
82         arguments->port = strtol(arg, &tail, 0);
83         if (errno) {
84             perror("argument parsing failed:");
85             return errno;
86         }
87         break;
88     case ARGP_KEY_ARG:
89         if (state->arg_num >= 1) {
90             // Too many arguments.
91             argp_usage (state);
92         }
93         arguments->args[state->arg_num] = arg;
94         break;
95     case ARGP_KEY_END:
96         if (state->arg_num < 1) {
97             // Not enough arguments.
98             argp_usage (state);
99         }
100         break;
101     default:
102         return ARGP_ERR_UNKNOWN;
103     }
104     return 0;
105 }
106
107 static struct argp argp = { options, parse_opt, args_doc, doc };
108
109 ///////////////////////////
110 // main
111 //////////////////////////
112 int
113 main(int argc, char **argv)
114 {
115     // arg parsing
116     argp_parse (&argp, argc, argv, 0, 0, &arguments);
117
118     errno = 0;
119     char* tail;
120     int iNodeId = strtol(arguments.args[0], &tail, 0);
121     if (errno) {
122     perror("argument parsing failed:");
123     return -1;
124     }
125
126     raw1394handle_t pHandle = raw1394_new_handle_on_port( arguments.port );
127     if ( !pHandle ) {
128         if ( !errno ) {
129             cerr << "libraw1394 not compatible" << endl;
130         } else {
131             perror( "Could not get 1394 handle" );
132             cerr << "Is ieee1394 and raw1394 driver loaded?" << endl;
133         }
134         return -1;
135     }
136     quadlet_t cmd[6];
137     unsigned int response_len;
138    
139 //     cerr << "Opening descriptor" << endl;
140 //     0h 05m 21.760442s - GetDescriptorOpen:  cmd[0]= < 0x00 0x60 0x08 0x80 0x01 0xFF>
141 //     0h 05m 21.760687s - GetDescriptorOpen: resp[0]= < 0x09 0x60 0x08 0x80 0x01 0xFF > ACCEPTED
142
143
144 //     cmd[0] = 0x00600880;
145 //     cmd[1] = 0x01FF0000;
146 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
147 //     usleep(100000);
148 //     
149 //     cerr << "Reading descriptor" << endl;
150 // //     0h 05m 21.760700s - GetDescriptorRead:  cmd[0]= < 0x00 0x60 0x09 0x80 0xFF 0xFF 0x00 0x00 0x00 0x00>
151 // //     0h 05m 21.761123s - GetDescriptorRead: resp[0]= < 0x09 0x60 0x09 0x80 0x11 0xFF 0x01 0xF6 0x00 0x00 0x03 0x9E
152 //     cmd[0] = 0x00600980;
153 //     cmd[1] = 0xFFFF0000;
154 //     cmd[2] = 0x00000000;
155 //     cmd[2] = 0x00000000;
156 //     
157 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 3, &response_len, 10);
158 //     usleep(100000);
159 //     
160 //     cerr << "Closing descriptor" << endl;
161 //     cmd[0] = 0x00600880;
162 //     cmd[1] = 0x00FF0000;
163 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
164 //     usleep(100000);
165
166     cerr << "getting signal source" << endl;
167 //     0h 05m 21.762917s - at line 2283, fMaxAudioOutputChannels=2, fMaxAudioInputChannels=0
168 //     0h 05m 21.762919s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x00>
169 //     0h 05m 21.763149s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x60 0x60 0x00 0xFF 0x00 > IMPLEMENTED
170 //     0h 05m 21.763167s - Isoch out 0 gets its signal from sub/unit 0x60 Source Plug 0
171 //     0h 05m 21.763170s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x80>
172 //     0h 05m 21.763376s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x01 0xFF 0x80 > IMPLEMENTED
173 //     0h 05m 21.763394s - Isoch out 128 gets its signal from sub/unit 0x60 Source Plug 1
174 //     0h 05m 21.763397s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x81>
175 //     0h 05m 21.763637s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x02 0xFF 0x81 > IMPLEMENTED
176 //     0h 05m 21.763654s - Isoch out 129 gets its signal from sub/unit 0x60 Source Plug 2
177
178 //     0h 05m 21.764895s - Starting to look at subunit 1.  fNumberOfSubUnits = 2
179 //     0h 05m 21.764897s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x00>
180 //     0h 05m 21.765129s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x20 0xFF 0x00 0x60 0x00 > IMPLEMENTED
181 //     0h 05m 21.765140s - Subunit type12, addr:0x60 dest 0 gets its signal from sub/unit 0xff Source Plug 0
182 //     0h 05m 21.765142s - subunit 96 dest plug 0 is routed
183 //     0h 05m 21.765143s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x01>
184 //     0h 05m 21.765364s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0xFF 0x80 0x60 0x01 > IMPLEMENTED
185 //     0h 05m 21.765382s - Subunit type12, addr:0x60 dest 1 gets its signal from sub/unit 0xff Source Plug 128
186 //     0h 05m 21.765385s -      Plug being changed from 0x80 to 1 for internal bookeeping.
187 //     0h 05m 21.765389s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x02>
188 //     0h 05m 21.765632s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0xFF 0x81 0x60 0x02 > IMPLEMENTED
189 //     0h 05m 21.765651s - Subunit type12, addr:0x60 dest 2 gets its signal from sub/unit 0xff Source Plug 129
190 //     0h 05m 21.765653s -      Plug being changed from 0x81 to 2 for internal bookeeping.
191 //     0h 05m 21.765657s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x03>
192 //     0h 05m 21.765874s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x03 0x60 0x03 > IMPLEMENTED
193 //     0h 05m 21.765892s - Subunit type12, addr:0x60 dest 3 gets its signal from sub/unit 0x60 Source Plug 3
194
195     cmd[0] = 0x01FF1AFF;
196     cmd[1] = 0xFFFE6000;
197     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
198 //     usleep(100000);
199    
200     cmd[0] = 0x01FF1AFF;
201     cmd[1] = 0xFFFEFF00;
202     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
203     usleep(100000);
204
205
206
207     raw1394_destroy_handle( pHandle );
208     return 0;
209 }
Note: See TracBrowser for help on using the browser.