root/trunk/libffado/src/libieee1394/configrom.cpp

Revision 478, 20.3 kB (checked in by wagi, 17 years ago)

- save cache information to $(localstatedir)/cache/libffade
- refactoring of build and load cache function

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  * Copyright (C) 2005-2007 by Jonathan Woithe
4  * Copyright (C) 2005-2007 by Pieter Palmers
5  *
6  * This file is part of FFADO
7  * FFADO = Free Firewire (pro-)audio drivers for linux
8  *
9  * FFADO is based upon FreeBoB
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License version 2.1, as published by the Free Software Foundation;
14  *
15  * This library 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 GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23  * MA 02110-1301 USA
24  */
25
26 #include "configrom.h"
27 #include "ieee1394service.h"
28
29 #include <stdio.h>
30 #include <string.h>
31
32 #include <iostream>
33 #include <iomanip>
34
35 using namespace std;
36
37 IMPL_DEBUG_MODULE( ConfigRom, ConfigRom, DEBUG_LEVEL_NORMAL );
38
39 static int busRead( struct csr1212_csr* csr,
40                     u_int64_t addr,
41                     u_int16_t length,
42                     void* buffer,
43                     void* private_data );
44
45 static int getMaxRom( u_int32_t* bus_info_data,
46                       void* private_data );
47
48 static struct csr1212_bus_ops configrom_csr1212_ops = {
49     busRead,
50     0,
51     0,
52     getMaxRom
53 };
54
55 struct config_csr_info {
56     Ieee1394Service* service;
57     fb_nodeid_t      nodeId;
58 };
59
60 //-------------------------------------------------------------
61
62 ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId )
63     : OscNode("ConfigRom")
64     , m_1394Service( &ieee1394service )
65     , m_nodeId( nodeId )
66     , m_avcDevice( false )
67     , m_guid( 0 )
68     , m_vendorName( "" )
69     , m_modelName( "" )
70     , m_vendorId( 0 )
71     , m_modelId( 0 )
72     , m_unit_specifier_id( 0 )
73     , m_unit_version( 0 )
74     , m_isIsoResourceManager( false )
75     , m_isCycleMasterCapable( false )
76     , m_isSupportIsoOperations( false )
77     , m_isBusManagerCapable( false )
78     , m_cycleClkAcc( 0 )
79     , m_maxRec( 0 )
80     , m_nodeVendorId( 0 )
81     , m_chipIdHi( 0 )
82     , m_chipIdLow( 0 )
83     , m_vendorNameKv( 0 )
84     , m_modelNameKv( 0 )
85     , m_csr( 0 )
86 {
87 }
88
89 ConfigRom::ConfigRom()
90     : OscNode("ConfigRom")
91     , m_1394Service( 0 )
92     , m_nodeId( -1 )
93     , m_avcDevice( false )
94     , m_guid( 0 )
95     , m_vendorName( "" )
96     , m_modelName( "" )
97     , m_vendorId( 0 )
98     , m_modelId( 0 )
99     , m_unit_specifier_id( 0 )
100     , m_unit_version( 0 )
101     , m_isIsoResourceManager( false )
102     , m_isCycleMasterCapable( false )
103     , m_isSupportIsoOperations( false )
104     , m_isBusManagerCapable( false )
105     , m_cycleClkAcc( 0 )
106     , m_maxRec( 0 )
107     , m_nodeVendorId( 0 )
108     , m_chipIdHi( 0 )
109     , m_chipIdLow( 0 )
110     , m_vendorNameKv( 0 )
111     , m_modelNameKv( 0 )
112     , m_csr( 0 )
113 {
114 }
115
116 ConfigRom::~ConfigRom()
117 {
118 }
119
120 bool
121 ConfigRom::operator == ( const ConfigRom& rhs )
122 {
123     return m_guid == rhs.m_guid;
124 }
125
126 bool
127 ConfigRom::initialize()
128 {
129      struct config_csr_info csr_info;
130      csr_info.service = m_1394Service;
131      csr_info.nodeId = 0xffc0 | m_nodeId;
132
133      m_csr = csr1212_create_csr( &configrom_csr1212_ops,
134                                  5 * sizeof(fb_quadlet_t),   // XXX Why 5 ?!?
135                                  &csr_info );
136     if (!m_csr || csr1212_parse_csr( m_csr ) != CSR1212_SUCCESS) {
137         debugError( "Could not parse config rom of node %d on port %d\n", m_nodeId, m_1394Service->getPort() );
138         if (m_csr) {
139             csr1212_destroy_csr(m_csr);
140             m_csr = 0;
141         }
142         return false;
143     }
144
145     // Process Bus_Info_Block
146     m_isIsoResourceManager = CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 31;
147     m_isCycleMasterCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 30 ) & 0x1;
148     m_isSupportIsoOperations = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 29 ) & 0x1;
149     m_isBusManagerCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 28 ) & 0x1;
150     m_cycleClkAcc = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 16 ) & 0xff;
151     m_maxRec = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[2] ) >> 12 ) & 0xf;
152     m_nodeVendorId = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) >> 8 );
153     m_chipIdHi = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) ) & 0xff;
154     m_chipIdLow = CSR1212_BE32_TO_CPU( m_csr->bus_info_data[4] );
155
156     // Process Root Directory
157     processRootDirectory(m_csr);
158
159     if ( m_vendorNameKv ) {
160         int len = ( m_vendorNameKv->value.leaf.len - 2) * sizeof( quadlet_t );
161         char* buf = new char[len+2];
162         memcpy( buf,
163                 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_vendorNameKv ),
164                 len );
165
166     while ((buf + len - 1) == '\0') {
167             len--;
168         }
169         // \todo XXX seems a bit strage to do this but the nodemgr.c code does
170         // it. try to figure out why this is needed (or not)
171     buf[len++] = ' ';
172     buf[len] = '\0';
173
174
175         debugOutput( DEBUG_LEVEL_VERBOSE, "Vendor name: '%s'\n", buf );
176         m_vendorName = buf;
177         delete[] buf;
178     }
179     if ( m_modelNameKv ) {
180         int len = ( m_modelNameKv->value.leaf.len - 2) * sizeof( quadlet_t );
181         char* buf = new char[len+2];
182         memcpy( buf,
183                 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_modelNameKv ),
184                 len );
185     while ((buf + len - 1) == '\0') {
186             len--;
187         }
188         // \todo XXX for edirol fa-66 it seems somehow broken. see above
189         // todo as well.
190     buf[len++] = ' ';
191     buf[len] = '\0';
192
193         debugOutput( DEBUG_LEVEL_VERBOSE, "Model name: '%s'\n", buf);
194         m_modelName = buf;
195         delete[] buf;
196     }
197
198     m_guid = ((u_int64_t)CSR1212_BE32_TO_CPU(m_csr->bus_info_data[3]) << 32)
199              | CSR1212_BE32_TO_CPU(m_csr->bus_info_data[4]);
200
201     if ( m_vendorNameKv ) {
202         csr1212_release_keyval( m_vendorNameKv );
203         m_vendorNameKv = 0;
204     }
205     if ( m_modelNameKv ) {
206         csr1212_release_keyval( m_modelNameKv );
207         m_modelNameKv = 0;
208     }
209     if ( m_csr ) {
210         csr1212_destroy_csr(m_csr);
211         m_csr = 0;
212     }
213     return true;
214 }
215
216 static int
217 busRead( struct csr1212_csr* csr,
218          u_int64_t addr,
219          u_int16_t length,
220          void* buffer,
221          void* private_data )
222 {
223     struct config_csr_info* csr_info = (struct config_csr_info*) private_data;
224
225     if ( !csr_info->service->read( csr_info->nodeId,
226                                    addr,
227                                    (size_t)length/4,
228                                    ( quadlet_t* )buffer) )
229     {
230         //debugOutput( DEBUG_LEVEL_VERBOSE, "ConfigRom: Read failed\n");
231         return -1;
232     }
233
234     return 0;
235 }
236
237 static int
238 getMaxRom( u_int32_t* bus_info_data,
239            void* /*private_data*/)
240 {
241     return (CSR1212_BE32_TO_CPU( bus_info_data[2] ) >> 8) & 0x3;
242 }
243
244
245 void
246 ConfigRom::processUnitDirectory( struct csr1212_csr* csr,
247                                  struct csr1212_keyval* ud_kv,
248                                  unsigned int *id )
249 {
250     struct csr1212_dentry *dentry;
251     struct csr1212_keyval *kv;
252     unsigned int last_key_id = 0;
253
254     debugOutput( DEBUG_LEVEL_VERBOSE, "process unit directory:\n" );
255     csr1212_for_each_dir_entry(csr, kv, ud_kv, dentry) {
256     switch (kv->key.id) {
257         case CSR1212_KV_ID_VENDOR:
258         if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
259                     debugOutput( DEBUG_LEVEL_VERBOSE,
260                                  "\tvendor_id = 0x%08x\n",
261                                  kv->value.immediate);
262                     m_vendorId = kv->value.immediate;
263         }
264         break;
265
266         case CSR1212_KV_ID_MODEL:
267                 debugOutput( DEBUG_LEVEL_VERBOSE,
268                              "\tmodel_id = 0x%08x\n",
269                              kv->value.immediate);
270                 m_modelId = kv->value.immediate;
271         break;
272
273         case CSR1212_KV_ID_SPECIFIER_ID:
274                 debugOutput( DEBUG_LEVEL_VERBOSE,
275                              "\tspecifier_id = 0x%08x\n",
276                              kv->value.immediate);
277                 m_unit_specifier_id = kv->value.immediate;
278         break;
279
280         case CSR1212_KV_ID_VERSION:
281                 debugOutput( DEBUG_LEVEL_VERBOSE,
282                              "\tversion = 0x%08x\n",
283                              kv->value.immediate);
284                 m_unit_version = kv->value.immediate;
285                 if ( m_unit_specifier_id == 0x0000a02d ) // XXX
286                 {
287                     if ( kv->value.immediate == 0x10001 ) {
288                         m_avcDevice = true;
289                     }
290                 }
291         break;
292
293         case CSR1212_KV_ID_DESCRIPTOR:
294         if (kv->key.type == CSR1212_KV_TYPE_LEAF &&
295             CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&
296             CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&
297             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
298             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
299             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)
300         {
301             switch (last_key_id) {
302             case CSR1212_KV_ID_VENDOR:
303                 csr1212_keep_keyval(kv);
304                             m_vendorNameKv = kv;
305                 break;
306
307             case CSR1212_KV_ID_MODEL:
308                             m_modelNameKv = kv;
309                 csr1212_keep_keyval(kv);
310                 break;
311
312             }
313         } /* else if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) ... */
314         break;
315
316         case CSR1212_KV_ID_DEPENDENT_INFO:
317         if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) {
318             /* This should really be done in SBP2 as this is
319              * doing SBP2 specific parsing. */
320             processUnitDirectory(csr, kv, id);
321         }
322
323         break;
324
325         default:
326         break;
327     }
328     last_key_id = kv->key.id;
329     }
330 }
331
332 void
333 ConfigRom::processRootDirectory(struct csr1212_csr* csr)
334 {
335     unsigned int ud_id = 0;
336     struct csr1212_dentry *dentry;
337     struct csr1212_keyval *kv;
338     unsigned int last_key_id = 0;
339
340     csr1212_for_each_dir_entry(csr, kv, csr->root_kv, dentry) {
341     switch (kv->key.id) {
342         case CSR1212_KV_ID_VENDOR:
343                 debugOutput( DEBUG_LEVEL_VERBOSE,
344                              "vendor id = 0x%08x\n", kv->value.immediate);
345         break;
346
347         case CSR1212_KV_ID_NODE_CAPABILITIES:
348                 debugOutput( DEBUG_LEVEL_VERBOSE,
349                              "capabilities = 0x%08x\n", kv->value.immediate);
350         break;
351
352         case CSR1212_KV_ID_UNIT:
353         processUnitDirectory(csr, kv, &ud_id);
354         break;
355
356         case CSR1212_KV_ID_DESCRIPTOR:
357         if (last_key_id == CSR1212_KV_ID_VENDOR) {
358             if (kv->key.type == CSR1212_KV_TYPE_LEAF &&
359             CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&
360             CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&
361             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
362             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
363             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)
364                     {
365                         m_vendorNameKv = kv;
366             csr1212_keep_keyval(kv);
367             }
368         }
369         break;
370     }
371     last_key_id = kv->key.id;
372     }
373
374 }
375
376 const fb_nodeid_t
377 ConfigRom::getNodeId() const
378 {
379     return m_nodeId;
380 }
381
382 const fb_octlet_t
383 ConfigRom::getGuid() const
384 {
385     return m_guid;
386 }
387
388 const Glib::ustring
389 ConfigRom::getGuidString() const
390 {
391     char* buf;
392     asprintf( &buf, "%08x%08x",
393               ( unsigned int ) ( getGuid() >> 32 ),
394               ( unsigned int ) ( getGuid() & 0xffffffff ) );
395     Glib::ustring result = buf;
396     free( buf );
397     return result;
398 }
399
400 const Glib::ustring
401 ConfigRom::getModelName() const
402 {
403     return m_modelName;
404 }
405
406 const Glib::ustring
407 ConfigRom::getVendorName() const
408 {
409     return m_vendorName;
410 }
411
412 const unsigned int
413 ConfigRom::getModelId() const
414 {
415     return m_modelId;
416 }
417
418 const unsigned int
419 ConfigRom::getVendorId() const
420 {
421     return m_vendorId;
422 }
423
424 const unsigned int
425 ConfigRom::getUnitSpecifierId() const
426 {
427     return m_unit_specifier_id;
428 }
429
430 const unsigned int
431 ConfigRom::getUnitVersion() const
432 {
433     return m_unit_version;
434 }
435
436 bool
437 ConfigRom::updatedNodeId()
438 {
439     struct csr1212_csr* csr = 0;
440     for ( fb_nodeid_t nodeId = 0;
441           nodeId < m_1394Service->getNodeCount();
442           ++nodeId )
443     {
444         struct config_csr_info csr_info;
445         csr_info.service = m_1394Service;
446         csr_info.nodeId = 0xffc0 | nodeId;
447
448         csr = csr1212_create_csr( &configrom_csr1212_ops,
449                                   5 * sizeof(fb_quadlet_t),   // XXX Why 5 ?!?
450                                   &csr_info );
451
452         if (!csr || csr1212_parse_csr( csr ) != CSR1212_SUCCESS) {
453             if (csr) {
454                 csr1212_destroy_csr(csr);
455             }
456             continue;
457         }
458
459
460         octlet_t guid =
461             ((u_int64_t)CSR1212_BE32_TO_CPU(csr->bus_info_data[3]) << 32)
462             | CSR1212_BE32_TO_CPU(csr->bus_info_data[4]);
463
464         if ( guid == getGuid() ) {
465             if ( nodeId != getNodeId() ) {
466                 debugOutput( DEBUG_LEVEL_VERBOSE,
467                              "Device with GUID 0x%08x%08x changed node id "
468                              "from %d to %d\n",
469                              ( unsigned int ) ( getGuid() >> 32 ),
470                              ( unsigned int ) ( getGuid() & 0xffffffff ),
471                              getNodeId(),
472                              nodeId );
473                 m_nodeId = nodeId;
474             }
475             if (csr) {
476                 csr1212_destroy_csr(csr);
477             }
478             return true;
479         }
480     }
481
482     if (csr) {
483         csr1212_destroy_csr(csr);
484     }
485
486     debugOutput( DEBUG_LEVEL_NORMAL,
487                  "Device with GUID 0x%08x%08x could not be found on "
488                  "the bus anymore (removed?)\n",
489                  m_guid >> 32,
490                  m_guid & 0xffffffff );
491     return false;
492 }
493
494 void
495 ConfigRom::printConfigRom() const
496 {
497     using namespace std;
498     printf( "Config ROM\n" );
499     printf( "\tCurrent Node Id:\t%d\n",       getNodeId() );
500     printf( "\tGUID:\t\t\t0x%08x%08x\n",
501             ( unsigned int )( getGuid() >> 32 ),
502             ( unsigned int ) ( getGuid() & 0xffffffff ) );
503     printf( "\tVendor Name:\t\t%s\n",         getVendorName().c_str() );
504     printf( "\tModel Name:\t\t%s\n",          getModelName().c_str() );
505     printf( "\tNode Vendor ID:\t\t0x%06x\n",  getNodeVendorId() );
506     printf( "\tModel Id:\t\t0x%08x\n",        getModelId() );
507     printf( "\tUnit Specifier ID:\t0x%06x\n",  getUnitSpecifierId() );
508     printf( "\tUnit version:\t\t0x%08x\n",        getUnitVersion() );
509     printf( "\tISO resource manager:\t%d\n",  isIsoResourseManager() );
510     printf( "\tCycle master capable:\t%d\n",  isSupportsIsoOperations() );
511     printf( "\tBus manager capable:\t%d\n",   isBusManagerCapable() );
512     printf( "\tCycle clock accuracy:\t%d\n", getCycleClockAccurancy() );
513     printf( "\tMax rec:\t\t%d (max asy payload: %d bytes)\n",
514             getMaxRec(), getAsyMaxPayload() );
515 }
516
517 unsigned short
518 ConfigRom::getAsyMaxPayload() const
519 {
520     // XXX use pow instead?
521     return 1 << ( m_maxRec + 1 );
522 }
523
524 bool
525 ConfigRom::serialize( Glib::ustring path, Util::IOSerialize& ser )
526 {
527     bool result;
528     result  = ser.write( path + "m_nodeId", m_nodeId );
529     result &= ser.write( path + "m_avcDevice",  m_avcDevice );
530     result &= ser.write( path + "m_guid", m_guid );
531     result &= ser.write( path + "m_vendorName", Glib::ustring( m_vendorName ) );
532     result &= ser.write( path + "m_modelName", Glib::ustring( m_modelName ) );
533     result &= ser.write( path + "m_vendorId", m_vendorId );
534     result &= ser.write( path + "m_modelId", m_modelId );
535     result &= ser.write( path + "m_unit_specifier_id", m_unit_specifier_id );
536     result &= ser.write( path + "m_unit_version",  m_unit_version );
537     result &= ser.write( path + "m_isIsoResourceManager", m_isIsoResourceManager );
538     result &= ser.write( path + "m_isCycleMasterCapable", m_isCycleMasterCapable );
539     result &= ser.write( path + "m_isSupportIsoOperations", m_isSupportIsoOperations );
540     result &= ser.write( path + "m_isBusManagerCapable", m_isBusManagerCapable );
541     result &= ser.write( path + "m_cycleClkAcc", m_cycleClkAcc );
542     result &= ser.write( path + "m_maxRec", m_maxRec );
543     result &= ser.write( path + "m_nodeVendorId", m_nodeVendorId );
544     result &= ser.write( path + "m_chipIdHi", m_chipIdHi );
545     result &= ser.write( path + "m_chipIdLow", m_chipIdLow );
546     return result;
547 }
548
549 ConfigRom*
550 ConfigRom::deserialize( Glib::ustring path, Util::IODeserialize& deser, Ieee1394Service& ieee1394Service )
551 {
552     ConfigRom* pConfigRom = new ConfigRom;
553     if ( !pConfigRom ) {
554         return 0;
555     }
556
557     pConfigRom->m_1394Service = &ieee1394Service;
558
559     bool result;
560     result  = deser.read( path + "m_nodeId", pConfigRom->m_nodeId );
561     result &= deser.read( path + "m_avcDevice", pConfigRom->m_avcDevice );
562     result &= deser.read( path + "m_guid", pConfigRom->m_guid );
563     result &= deser.read( path + "m_vendorName", pConfigRom->m_vendorName );
564     result &= deser.read( path + "m_modelName", pConfigRom->m_modelName );
565     result &= deser.read( path + "m_vendorId", pConfigRom->m_vendorId );
566     result &= deser.read( path + "m_modelId", pConfigRom->m_modelId );
567     result &= deser.read( path + "m_unit_specifier_id", pConfigRom->m_unit_specifier_id );
568     result &= deser.read( path + "m_unit_version", pConfigRom->m_unit_version );
569     result &= deser.read( path + "m_isIsoResourceManager", pConfigRom->m_isIsoResourceManager );
570     result &= deser.read( path + "m_isCycleMasterCapable", pConfigRom->m_isCycleMasterCapable );
571     result &= deser.read( path + "m_isSupportIsoOperations", pConfigRom->m_isSupportIsoOperations );
572     result &= deser.read( path + "m_isBusManagerCapable", pConfigRom->m_isBusManagerCapable );
573     result &= deser.read( path + "m_cycleClkAcc", pConfigRom->m_cycleClkAcc );
574     result &= deser.read( path + "m_maxRec", pConfigRom->m_maxRec );
575     result &= deser.read( path + "m_nodeVendorId", pConfigRom->m_nodeVendorId );
576     result &= deser.read( path + "m_chipIdHi", pConfigRom->m_chipIdHi );
577     result &= deser.read( path + "m_chipIdLow", pConfigRom->m_chipIdLow );
578
579     if ( !result ) {
580         delete pConfigRom;
581         return 0;
582     }
583
584     return pConfigRom;
585 }
586
587 bool
588 ConfigRom::setNodeId( fb_nodeid_t nodeId )
589 {
590     m_nodeId = nodeId;
591     return true;
592 }
593
594 OSC::OscResponse
595 ConfigRom::processOscMessage(OSC::OscMessage *m) {
596     OSC::OscResponse r=OSC::OscResponse(OSC::OscResponse::eUnhandled);
597
598     unsigned int nbArgs=m->nbArguments();
599     if (nbArgs>=1) {
600         OSC::OscArgument arg0=m->getArgument(0);
601         if(arg0.isString()) { // commands
602             string cmd=arg0.getString();
603
604             debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) CMD? %s\n", this, cmd.c_str());
605             if(cmd == "params") {
606                 debugOutput( DEBUG_LEVEL_VERBOSE, "Listing node params...\n");
607                 OSC::OscMessage& rm=r.getMessage();
608                 rm.addArgument("GUID");
609                 rm.addArgument("VendorName");
610                 rm.addArgument("ModelName");
611                 r.setType(OSC::OscResponse::eMessage);
612             }
613             if(cmd == "get") {
614                 if(nbArgs != 2) {
615                     debugError("Erronous get command received, wrong nb of arguments\n");
616                     m->print();
617                 } else {
618                     OSC::OscArgument arg1=m->getArgument(1);
619                     if(arg1.isString()) { // commands
620                         string target=arg1.getString();
621                         OSC::OscMessage& rm=r.getMessage();
622                         if(target == "GUID") {
623                             // FIXME: this will only return the lower 32 bits
624                             rm.addArgument((int64_t)getGuid());
625                         } else if(target == "VendorName") {
626                             rm.addArgument(getVendorName());
627                         } else if(target == "ModelName") {
628                             rm.addArgument(getModelName());
629                         } else {
630                             debugError("Erronous get command received, non-existant target\n");
631                             m->print();
632                         }
633                         r.setType(OSC::OscResponse::eMessage);
634                     } else {
635                         debugError("Erronous get command received, wrong argument type\n");
636                         m->print();
637                     }
638                 }
639             }
640         }
641     }
642
643     return r;
644
645 }
Note: See TracBrowser for help on using the browser.