Changeset 40 for trunk/freebob

Show
Ignore:
Timestamp:
12/05/04 07:09:21 (19 years ago)
Author:
pieterpalmers
Message:

Added:
- Information retrieval functions for several infoblocks
- Status printing functions for several infoblocks
- debugPrintShort to print debug comments without leading context info
- optional ANSI colored output of debug commands (see debugmodule.h)
- optional colored HTML output of debug commands for e.g. printouts (see debugmodule.h)
- AvDeviceSubunit?->Reserve() / unReserve() / isReserved()
- AvDevice::[set|get][Input|Output]PlugSignalFormat? functions (incomplete)
- added preliminary detection of internal connections

Changed:
- removed a lot of obsolete test code from ieee1394service.cpp
- added some other test code to ieee1394service.cpp

Bugfixes:
- Corrected bug in AvClusterInfoBlock?. This originated from an error in the spec.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freebob/src/avclusterinfoblock.cpp

    r38 r40  
    4848 
    4949        for(unsigned int i=0;i<nb_signals;i++) { 
    50                 unsigned int plug_info=readWord(0x0A+i*4); 
    51                 unsigned char stream_position=readByte(0x0A+i*4+2); 
    52                 unsigned char stream_location=readByte(0x0A+i*4+3); 
     50                unsigned int plug_info=readWord(0x09+i*4); 
     51                unsigned char stream_position=readByte(0x09+i*4+2); 
     52                unsigned char stream_location=readByte(0x09+i*4+3); 
    5353                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Signal %d: plug_info=0x%04X, stream_position=0x%02X, stream_location=0x%02X\n",i,plug_info,stream_position,stream_location); 
    5454                 
     
    8080} 
    8181 
     82void AvClusterInfoBlock::printSignalInfo(unsigned char idx) { 
     83        if (idx<getNbSignals() && (0x09+idx*4<getLength())) { 
     84                unsigned int plug_info=readWord(0x09+idx*4); 
     85                unsigned char stream_position=readByte(0x09+idx*4+2); 
     86                unsigned char stream_location=readByte(0x09+idx*4+3); 
     87                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Signal %d: plug_info=0x%04X, stream_position=0x%02X, stream_location=0x%02X\n",idx,plug_info,stream_position,stream_location); 
     88        } else { 
     89                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Signal %d not present!\n",idx); 
     90         
     91        } 
     92} 
     93 
     94void AvClusterInfoBlock::printName() { 
     95        unsigned int next_block_position=iBaseAddress+0x06+readWord(0x04); 
     96         
     97        if(next_block_position<iBaseAddress+getLength()) { 
     98                // parse the optional name block 
     99                AvNameInfoBlock *tmpNameInfoBlock=new AvNameInfoBlock(cParent,next_block_position); 
     100                if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 
     101                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Name: %s\n",tmpNameInfoBlock->getName()); 
     102                 
     103                } else { 
     104                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   no name block present\n"); 
     105                } 
     106                if(tmpNameInfoBlock) { 
     107                        delete tmpNameInfoBlock; 
     108                        tmpNameInfoBlock=NULL; 
     109                } 
     110        } 
     111 
     112} 
  • trunk/freebob/src/avclusterinfoblock.h

    r38 r40  
    4444        AvClusterInfoBlock(AvDescriptor *parent, int address); // read an infoblock from a parent starting from a specific position 
    4545        virtual ~AvClusterInfoBlock(); 
     46        unsigned char getStreamFormat() {return readByte(0x06);}; 
     47        unsigned char getPortType() {return readByte(0x07);}; 
     48        unsigned char getNbSignals() {return readByte(0x08);}; 
    4649 
     50        void printSignalInfo(unsigned char idx); 
     51        void printName(); 
    4752         
    4853protected: 
  • trunk/freebob/src/avdescriptor.cpp

    r26 r40  
    164164        iLength=response[2] & 0xFFFF; 
    165165         
    166         debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor length=0x%04X %d\n",iLength,iLength);    
     166        debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor length=0x%04X %d ",iLength,iLength);     
    167167 
    168168        // now get the rest of the descriptor 
     
    183183        // first read 
    184184        if(bytes_read<iLength) { 
    185                 debugPrint(DEBUG_LEVEL_DESCRIPTOR,".");        
     185                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,".");   
    186186                // apparently the lib modifies the request, so redefine it completely 
    187187                request[0] = AVC1394_CTYPE_CONTROL | qTarget 
     
    208208        // now do the remaining reads 
    209209        while(bytes_read<iLength) { 
    210                 debugPrint(DEBUG_LEVEL_DESCRIPTOR,".");        
     210                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,".");   
    211211                // apparently the lib modifies the request, so redefine it completely 
    212212                request[0] = AVC1394_CTYPE_CONTROL | qTarget 
     
    229229                 
    230230        } 
    231         debugPrint(DEBUG_LEVEL_DESCRIPTOR,"\n");       
     231        debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n");  
    232232         
    233233         
  • trunk/freebob/src/avdevice.cpp

    r38 r40  
    4343FBReturnCodes 
    4444AvDevice::Initialize() { 
    45    if (!m_bInitialised) { 
     45         
     46        if (!m_bInitialised) { 
    4647 
    4748        m_handle = raw1394_new_handle(); 
     
    154155                                                if(tmpAvDeviceSubunit && tmpAvDeviceSubunit->isValid()) { 
    155156                                                        cSubUnits.push_back(tmpAvDeviceSubunit); 
    156  
     157                                                        //setDebugLevel(DEBUG_LEVEL_ALL); 
     158                                                        debugPrint (DEBUG_LEVEL_DEVICE, "Trying to reserve the subunit...\n"); 
     159                                                        tmpAvDeviceSubunit->reserve(0x01); 
     160                                                        debugPrint (DEBUG_LEVEL_DEVICE, "  isReserved?: %d\n",tmpAvDeviceSubunit->isReserved()); 
     161                                                        tmpAvDeviceSubunit->unReserve(); 
     162                                                        //setDebugLevel(DEBUG_LEVEL_MODERATE); 
     163                                                         
    157164 
    158165                                                } else { 
     
    203210        response = avc1394_transaction_block(m_handle, iNodeId, request, request_len, 2); 
    204211        if (request != NULL) { 
    205                 debugPrint (DEBUG_LEVEL_TRANSFERS, "\n------- TRANSACTION START -------\n"); 
     212                debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION START -------\n"); 
    206213                debugPrint (DEBUG_LEVEL_TRANSFERS,"  REQUEST:     "); 
    207214                /* request is in machine byte order. this function is for intel architecure */ 
    208215                for (i=0;i<request_len;i++) { 
    209216                        request_pos=(unsigned char *)(request+i); 
    210                         debugPrint (DEBUG_LEVEL_TRANSFERS, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3)); 
    211                 } 
    212                 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n"); 
     217                        debugPrintShort (DEBUG_LEVEL_TRANSFERS, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3)); 
     218                } 
     219                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 
    213220                debugPrint (DEBUG_LEVEL_TRANSFERS,"      => "); 
    214                 debugPrint (DEBUG_LEVEL_TRANSFERS,"                     "); 
     221                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"                     "); 
    215222                request_pos=(unsigned char *)(request); 
    216                 debugPrint (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X  subunit_id=%02X  opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF); 
    217                 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n"); 
     223                debugPrintShort (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X  subunit_id=%02X  opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF); 
     224                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 
    218225        } 
    219226        if (response != NULL) { 
     
    221228                debugPrint (DEBUG_LEVEL_TRANSFERS,"  -> RESPONSE: "); 
    222229                for (i=0;i<response_len;i++) { 
    223                         debugPrint (DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i]); 
    224                 } 
    225                 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n"); 
     230                        debugPrintShort (DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i]); 
     231                } 
     232                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 
    226233                debugPrint (DEBUG_LEVEL_TRANSFERS,"      => "); 
    227234                switch (response[0]&0xFF000000) { 
    228235                        case AVC1394_RESPONSE_NOT_IMPLEMENTED: 
    229                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Not Implemented      "); 
     236                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Not Implemented      "); 
    230237                        break; 
    231238                        case AVC1394_RESPONSE_ACCEPTED: 
    232                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Accepted             "); 
     239                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Accepted             "); 
    233240                        break; 
    234241                        case AVC1394_RESPONSE_REJECTED: 
    235                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Rejected             "); 
     242                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Rejected             "); 
    236243                        break; 
    237244                        case AVC1394_RESPONSE_IN_TRANSITION: 
    238                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"In Transition        "); 
     245                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"In Transition        "); 
    239246                        break; 
    240247                        case AVC1394_RESPONSE_IMPLEMENTED: 
    241                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Implemented / Stable "); 
     248                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Implemented / Stable "); 
    242249                        break; 
    243250                        case AVC1394_RESPONSE_CHANGED: 
    244                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Changed              "); 
     251                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Changed              "); 
    245252                        break; 
    246253                        case AVC1394_RESPONSE_INTERIM: 
    247                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Interim              "); 
     254                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Interim              "); 
    248255                        break; 
    249256                        default: 
    250                                 debugPrint (DEBUG_LEVEL_TRANSFERS,"Unknown response     "); 
    251                         break; 
    252                 } 
    253                 debugPrint (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X  subunit_id=%02X  opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF); 
    254                 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n"); 
     257                                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Unknown response     "); 
     258                        break; 
     259                } 
     260                debugPrintShort (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X  subunit_id=%02X  opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF); 
     261                debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 
    255262        } 
    256263        debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION END -------\n"); 
     
    258265 
    259266} 
     267 
     268FBReturnCodes AvDevice::setInputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { 
     269        quadlet_t request[6]; 
     270        quadlet_t *response; 
     271 
     272        request[0] = AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     273                                        | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | plug; 
     274        request[1] = (0x80000000) | ((fmt & 0x3F)<<24) | (fdf & 0x00FFFFFF); 
     275        response = avcExecuteTransaction(request, 2, 2); 
     276        if (response != NULL) { 
     277         
     278        } 
     279 
     280} 
     281 
     282FBReturnCodes AvDevice::getInputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf) { 
     283        quadlet_t request[6]; 
     284        quadlet_t *response; 
     285 
     286        request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     287                                        | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | plug; 
     288        request[1] = 0xFFFFFFFF; 
     289        response = avcExecuteTransaction(request, 2, 2); 
     290        if (response != NULL) { 
     291                *fmt=((response[1] >> 24) & 0x3F); 
     292                *fdf=response[1]& 0x00FFFFFF; 
     293        } 
     294 
     295} 
     296FBReturnCodes AvDevice::setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { 
     297        quadlet_t request[6]; 
     298        quadlet_t *response; 
     299 
     300        request[0] = AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     301                                        | AVC1394_COMMAND_OUTPUT_PLUG_SIGNAL_FORMAT | plug; 
     302        request[1] = (0x80000000) | ((fmt & 0x3F)<<24) | (fdf & 0x00FFFFFF); 
     303        response = avcExecuteTransaction(request, 2, 2); 
     304        if (response != NULL) { 
     305         
     306        } 
     307 
     308} 
     309 
     310FBReturnCodes AvDevice::getOutputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf) { 
     311        quadlet_t request[6]; 
     312        quadlet_t *response; 
     313 
     314        request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     315                                        | AVC1394_COMMAND_OUTPUT_PLUG_SIGNAL_FORMAT | plug; 
     316        request[1] = 0xFFFFFFFF; 
     317        response = avcExecuteTransaction(request, 2, 2); 
     318        if (response != NULL) { 
     319                *fmt=((response[1] >> 24) & 0x3F); 
     320                *fdf=response[1]& 0x00FFFFFF; 
     321        } 
     322 
     323} 
     324 
     325AvDeviceSubunit *AvDevice::getSubunit(unsigned char type, unsigned char id) { 
     326        vector<AvDeviceSubunit *>::iterator it; 
     327        for( it = cSubUnits.begin(); it != cSubUnits.end(); it++ ) { 
     328                if ((*it) && ((*it)->getType()==type) && ((*it)->getId()==id)) { 
     329                        return *it; 
     330                } 
     331        } 
     332        return NULL; 
     333 
     334} 
     335 
     336#define AVC1394_COMMAND_SIGNAL_SOURCE 0x00001A00 
     337 
     338void AvDevice::printConnections() { 
     339        quadlet_t request[6]; 
     340        quadlet_t *response; 
     341                        //setDebugLevel(DEBUG_LEVEL_ALL); 
     342                         
     343        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n");   
     344 
     345        for (unsigned int i=0;i<getNbIsoSourcePlugs();i++) { 
     346                request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     347                                                | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 
     348                request[1]=0xFFFEFF00 | ((i & 0xFF)); 
     349                 
     350                response = avcExecuteTransaction(request, 2, 2); 
     351         
     352                if (response != NULL) { 
     353                        unsigned char output_status=(response[0]&0xE0) >> 5; 
     354                        unsigned char conv=(response[0]&0x10) >> 4; 
     355                        unsigned char signal_status=(response[0]&0x0F); 
     356                         
     357                        unsigned int signal_source=((response[1]>>16)&0xFFFF); 
     358                         
     359                        unsigned char source_subunit_type=(signal_source>>11)&0x1F; 
     360                        unsigned char source_subunit_id=(signal_source>>8)&0x07; 
     361                        unsigned char source_plug=signal_source&0xFF; 
     362                         
     363                        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice:   OPCR 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 
     364                        // find the subunit this plug is connected to  
     365                        AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 
     366                        if(tmpSubunit) { 
     367                                tmpSubunit->printSourcePlugConnections(source_plug); 
     368                        } 
     369                         
     370                } 
     371        } 
     372         
     373        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n");      
     374 
     375        for (unsigned int i=0;i<getNbExtSourcePlugs();i++) { 
     376                request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     377                                                | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 
     378                request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 
     379                 
     380                response = avcExecuteTransaction(request, 2, 2); 
     381         
     382                if (response != NULL) { 
     383                        unsigned char output_status=(response[0]&0xE0) >> 5; 
     384                        unsigned char conv=(response[0]&0x10) >> 4; 
     385                        unsigned char signal_status=(response[0]&0x0F); 
     386                         
     387                        unsigned int signal_source=((response[1]>>16)&0xFFFF); 
     388                         
     389                        unsigned char source_subunit_type=(signal_source>>11)&0x1F; 
     390                        unsigned char source_subunit_id=(signal_source>>8)&0x07; 
     391                        unsigned char source_plug=signal_source&0xFF; 
     392                         
     393                        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice:   EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status);      
     394                         
     395                        // find the subunit this plug is connected to  
     396                        AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 
     397                        if(tmpSubunit) { 
     398                                tmpSubunit->printSourcePlugConnections(source_plug); 
     399                        }                        
     400                } 
     401        } 
     402 
     403        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n");     
     404 
     405        for (unsigned int i=0;i<getNbIsoDestinationPlugs();i++) { 
     406                request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     407                                                | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 
     408                request[1]=0xFFFEFF00 | ((i & 0xFF)); 
     409                 
     410                response = avcExecuteTransaction(request, 2, 2); 
     411         
     412                if (response != NULL) { 
     413                        unsigned char output_status=(response[0]&0xE0) >> 5; 
     414                        unsigned char conv=(response[0]&0x10) >> 4; 
     415                        unsigned char signal_status=(response[0]&0x0F); 
     416                         
     417                        unsigned int signal_source=((response[1]>>16)&0xFFFF); 
     418                         
     419                        unsigned char source_subunit_type=(signal_source>>11)&0x1F; 
     420                        unsigned char source_subunit_id=(signal_source>>8)&0x07; 
     421                        unsigned char source_plug=signal_source&0xFF; 
     422                         
     423                        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice:   OPCR 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 
     424                        // find the subunit this plug is connected to  
     425                        AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 
     426                        if(tmpSubunit) { 
     427                                //tmpSubunit->printDestinationPlugConnections(source_plug); 
     428                        } 
     429                         
     430                } 
     431        } 
     432         
     433        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n");        
     434 
     435        for (unsigned int i=0;i<getNbExtDestinationPlugs();i++) { 
     436                request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 
     437                                                | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 
     438                request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 
     439                 
     440                response = avcExecuteTransaction(request, 2, 2); 
     441         
     442                if (response != NULL) { 
     443                        unsigned char output_status=(response[0]&0xE0) >> 5; 
     444                        unsigned char conv=(response[0]&0x10) >> 4; 
     445                        unsigned char signal_status=(response[0]&0x0F); 
     446                         
     447                        unsigned int signal_source=((response[1]>>16)&0xFFFF); 
     448                         
     449                        unsigned char source_subunit_type=(signal_source>>11)&0x1F; 
     450                        unsigned char source_subunit_id=(signal_source>>8)&0x07; 
     451                        unsigned char source_plug=signal_source&0xFF; 
     452                         
     453                        debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice:   EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status);      
     454                         
     455                        // find the subunit this plug is connected to  
     456                        AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 
     457                        if(tmpSubunit) { 
     458                                //tmpSubunit->printDestinationPlugConnections(source_plug); 
     459                        }                        
     460                } 
     461        } 
     462         
     463} 
  • trunk/freebob/src/avdevice.h

    r31 r40  
    3838    quadlet_t * avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len); 
    3939 
    40     FBReturnCodes AvDevice::Initialize(); 
     40    FBReturnCodes Initialize(); 
    4141 
    42     bool AvDevice::isInitialised(); 
     42    bool isInitialised(); 
    4343 
     44    FBReturnCodes setInputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf); 
     45    FBReturnCodes getInputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf);   
     46    FBReturnCodes setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf); 
     47    FBReturnCodes getOutputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf);   
     48     
     49//      getSourcePlugConnection(); 
     50        void printConnections(); 
     51             
     52        unsigned char getNbAsyncSourcePlugs() { return iNbAsyncSourcePlugs; } ; 
     53    unsigned char getNbAsyncDestinationPlugs() { return iNbAsyncDestinationPlugs; } ; 
     54    unsigned char getNbIsoSourcePlugs() { return iNbIsoSourcePlugs; } ; // oPCR 
     55    unsigned char getNbIsoDestinationPlugs() { return iNbIsoDestinationPlugs; } ; // iPCR 
     56    unsigned char getNbExtSourcePlugs() { return iNbExtSourcePlugs; } ; 
     57    unsigned char getNbExtDestinationPlugs() { return iNbExtDestinationPlugs; } ; 
     58     
     59    int getNodeId() { return iNodeId; } ; 
     60 
     61 protected: 
     62        AvDeviceSubunit *getSubunit(unsigned char type, unsigned char id); 
     63  
    4464 private: 
    4565        int iNodeId; 
  • trunk/freebob/src/avdevicemusicsubunit.cpp

    r35 r40  
    2727#include "avmusicstatusdescriptor.h" 
    2828#include "avmusicidentifierdescriptor.h" 
     29#include "avpluginfoblock.h" 
     30#include "avclusterinfoblock.h" 
    2931 
    3032#define CORRECT_INTEGER_ENDIANNESS(value) (((((value)>>8) & 0xFF)) | ((((value)) & 0xFF)<<8)) 
     
    156158} 
    157159 
     160void AvDeviceMusicSubunit::printSourcePlugConnections(unsigned char plug) { 
     161        if(cStatusDescriptor) { 
     162                AvPlugInfoBlock *plugInfo=cStatusDescriptor->getSourcePlugInfoBlock(plug); 
     163                 
     164                if(plugInfo) { 
     165                        plugInfo->printConnections(); 
     166                } else { 
     167                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not find source plug 0x%02X in the descriptor.\n",plug); 
     168                } 
     169                 
     170                         
     171        } else { 
     172                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: no Status Descriptor present!\n"); 
     173        } 
     174         
     175} 
     176 
     177 
    158178 
    159179AvDeviceMusicSubunit::AvDeviceMusicSubunit(AvDevice *parent, unsigned char  id) : AvDeviceSubunit(parent,0x0C,id) 
  • trunk/freebob/src/avdevicemusicsubunit.h

    r31 r40  
    4040    void printMusicPlugInfo(); 
    4141    void printMusicPlugConfigurations(); 
     42         
     43        virtual void printSourcePlugConnections(unsigned char plug); 
     44         
     45 protected: 
     46         
    4247     
    4348 private: 
  • trunk/freebob/src/avdevicesubunit.cpp

    r35 r40  
    7474} 
    7575 
     76void AvDeviceSubunit::printSourcePlugConnections(unsigned char plug) { 
     77                        debugPrint(DEBUG_LEVEL_SUBUNIT," No internal connection information available.\n"); 
     78         
     79} 
     80 
     81 
    7682AvDeviceSubunit::AvDeviceSubunit(AvDevice *parent, unsigned char target, unsigned char  id) 
    7783{ 
     
    128134        return iNbSourcePlugs; 
    129135} 
     136 
     137int AvDeviceSubunit::reserve(unsigned char priority) { 
     138        unsigned char byte; 
     139        quadlet_t request[6]; 
     140        quadlet_t *response; 
     141 
     142        if (!cParent) { 
     143                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 
     144                bValid=false; 
     145                return -1; 
     146        } 
     147 
     148        request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 
     149                                        | AVC1394_COMMAND_RESERVE | priority; 
     150        request[1] = 0xFFFFFFFF; 
     151        request[2] = 0xFFFFFFFF; 
     152        request[3] = 0xFFFFFFFF; 
     153        response = cParent->avcExecuteTransaction(request, 4, 4); 
     154        if (response != NULL) { 
     155                if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED))  { 
     156                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve successfull.\n"); 
     157                        return priority; 
     158                } else { 
     159                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve not successfull.\n"); 
     160                        return -1; 
     161                } 
     162        } 
     163 
     164} 
     165  
     166int AvDeviceSubunit::isReserved() { 
     167        unsigned char byte; 
     168        quadlet_t request[6]; 
     169        quadlet_t *response; 
     170 
     171        if (!cParent) { 
     172                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 
     173                bValid=false; 
     174                return -1; // the device isn't usable, not due to reservation, but anyway... 
     175        } 
     176 
     177        request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 
     178                                        | AVC1394_COMMAND_RESERVE | 0xFF; 
     179        request[1] = 0xFFFFFFFF; 
     180        request[2] = 0xFFFFFFFF; 
     181        request[3] = 0xFFFFFFFF; 
     182        response = cParent->avcExecuteTransaction(request, 4, 4); 
     183        if (response != NULL) { 
     184                if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED))  { 
     185                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve check successfull.\n"); 
     186                        return (response[0]&0x000000FF); 
     187                } else { 
     188                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve check not successfull.\n"); 
     189                         
     190                        return -1; 
     191                } 
     192        } 
     193 
     194} 
     195 
     196int AvDeviceSubunit::unReserve() { 
     197        unsigned char byte; 
     198        quadlet_t request[6]; 
     199        quadlet_t *response; 
     200 
     201        if (!cParent) { 
     202                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 
     203                bValid=false; 
     204                return -1; 
     205        } 
     206 
     207        request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 
     208                                        | AVC1394_COMMAND_RESERVE | 0x00; 
     209        request[1] = 0xFFFFFFFF; 
     210        request[2] = 0xFFFFFFFF; 
     211        request[3] = 0xFFFFFFFF; 
     212        response = cParent->avcExecuteTransaction(request, 4, 4); 
     213        if (response != NULL) { 
     214                if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED))  { 
     215                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit unreserve successfull.\n"); 
     216                        return 0; 
     217                } else { 
     218                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit unreserve not successfull.\n"); 
     219                        return -1; 
     220                } 
     221        } 
     222 
     223} 
     224  
     225 
     226 
  • trunk/freebob/src/avdevicesubunit.h

    r35 r40  
    3333    unsigned char getNbSourcePlugs(); 
    3434 
     35    int reserve(unsigned char priority); 
     36    int unReserve(); 
     37    int isReserved(); 
     38     
     39        unsigned char getType() {return iTarget;} ; 
     40        unsigned char getId() {return iId;} ; 
     41         
    3542    virtual void test(); 
    36     void printOutputPlugConnections(); 
     43    virtual void printOutputPlugConnections(); 
    3744     
     45        virtual void printSourcePlugConnections(unsigned char plug); 
     46         
    3847 protected: 
    3948        bool bValid;     
  • trunk/freebob/src/avmusicidentifierdescriptor.cpp

    r26 r40  
    7575        debugPrint(DEBUG_LEVEL_DESCRIPTOR,"\t   -> capabilities: "); 
    7676        if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_GENERAL)) { 
    77                 debugPrint(DEBUG_LEVEL_DESCRIPTOR," general "); 
     77                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," general "); 
    7878        } 
    7979        if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIO)) { 
    80                 debugPrint(DEBUG_LEVEL_DESCRIPTOR," audio "); 
     80                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," audio "); 
    8181        } 
    8282        if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_MIDI)) { 
    83                 debugPrint(DEBUG_LEVEL_DESCRIPTOR," midi "); 
     83                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," midi "); 
    8484        } 
    8585        if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_SMPTE)) { 
    86                 debugPrint(DEBUG_LEVEL_DESCRIPTOR," smtpe "); 
     86                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," smtpe "); 
    8787        } 
    8888        if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_SAMPLECOUNT)) { 
    89                 debugPrint(DEBUG_LEVEL_DESCRIPTOR," samplecount "); 
     89                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," samplecount "); 
    9090        } 
    9191        if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC)) { 
    92                 debugPrint(DEBUG_LEVEL_DESCRIPTOR," audiosync "); 
     92                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," audiosync "); 
    9393        } 
    94         debugPrint(DEBUG_LEVEL_DESCRIPTOR,"\n"); 
     94        debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n"); 
    9595         
    9696        // start parsing the optional capability stuff 
  • trunk/freebob/src/avmusicpluginfoblock.cpp

    r39 r40  
    5454 
    5555        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Creating... length=0x%04X\n",getLength()); 
    56         debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock:   Music plug id=0x%02X\n",plug_id); 
     56        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock:   Music plug id=0x%04X\n",plug_id); 
    5757        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock:   Plug type=0x%02X\n",plug_type); 
    5858        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock:   routing support=0x%02X\n",routing_support); 
  • trunk/freebob/src/avmusicstatusdescriptor.cpp

    r38 r40  
    3232#include "avoutputplugstatusinfoblock.h" 
    3333#include "avroutingstatusinfoblock.h" 
     34#include "avpluginfoblock.h" 
    3435 
    3536AvMusicStatusDescriptor::AvMusicStatusDescriptor(AvDevice *parent, unsigned char id) : AvDescriptor(parent, AVC1394_SUBUNIT_TYPE_MUSIC | (id << 16),0x80) { 
     
    121122 
    122123} 
     124         
     125AvPlugInfoBlock *AvMusicStatusDescriptor::getSourcePlugInfoBlock(unsigned char plug) { 
     126        if (cRoutingStatusInfoBlock) { 
     127                return cRoutingStatusInfoBlock->getSourcePlugInfoBlock(plug); 
     128        } else return NULL; 
     129} 
     130 
     131AvPlugInfoBlock *AvMusicStatusDescriptor::getDestinationPlugInfoBlock(unsigned char plug) { 
     132        if (cRoutingStatusInfoBlock) { 
     133                return cRoutingStatusInfoBlock->getDestinationPlugInfoBlock(plug); 
     134        } else return NULL; 
     135 
     136} 
    123137 
    124138AvMusicStatusDescriptor::~AvMusicStatusDescriptor()  { 
  • trunk/freebob/src/avmusicstatusdescriptor.h

    r38 r40  
    3434class AvOutputPlugStatusInfoBlock; 
    3535class AvRoutingStatusInfoBlock; 
     36class AvPlugInfoBlock; 
    3637 
    3738class AvMusicStatusDescriptor : public AvDescriptor { 
     
    4243    void printCapabilities(); 
    4344 
     45        AvPlugInfoBlock *getSourcePlugInfoBlock(unsigned char plug); 
     46        AvPlugInfoBlock *getDestinationPlugInfoBlock(unsigned char plug); 
     47         
    4448 protected: 
    4549       AvGeneralMusicInfoBlock          *cGeneralMusicInfoBlock; 
  • trunk/freebob/src/avpluginfoblock.cpp

    r38 r40  
    113113 
    114114} 
     115         
     116AvClusterInfoBlock *AvPlugInfoBlock::getCluster(unsigned int idx) { 
     117        if ((idx < getNbClusters()) && (idx < cClusterInfoBlocks.size())) { 
     118                return cClusterInfoBlocks.at(idx); 
     119        } else return NULL; 
     120} 
    115121 
     122void AvPlugInfoBlock::printConnections() { 
     123        for (unsigned int i=0; i<getNbClusters();i++) { 
     124                AvClusterInfoBlock *tmpCluster=getCluster(i); 
     125                if (tmpCluster) { 
     126                        tmpCluster->printName(); 
     127                } 
     128        } 
     129} 
  • trunk/freebob/src/avpluginfoblock.h

    r38 r40  
    4747        virtual ~AvPlugInfoBlock(); 
    4848 
     49        unsigned char getPlugId() { return readByte(0x06); }; 
     50        unsigned int getSignalFormat() { return readWord(0x07); }; 
     51        unsigned char getPlugType() { return readByte(0x09); }; 
     52        unsigned int getNbClusters() { return readWord(0x0A); }; 
     53        unsigned int getNbChannels() { return readWord(0x0C); }; 
     54         
     55        AvClusterInfoBlock *getCluster(unsigned int idx); 
     56         
     57        void printConnections(); 
    4958         
    5059protected: 
  • trunk/freebob/src/avroutingstatusinfoblock.cpp

    r38 r40  
    4040 
    4141        unsigned int next_block_position=address+0x0A; 
    42         unsigned int nb_source_plugs=readByte(6); 
    43         unsigned int nb_dest_plugs=readByte(7); 
    44         unsigned int nb_music_plugs=readWord(8); 
     42        unsigned int nb_dest_plugs=readByte(0x06); 
     43        unsigned int nb_source_plugs=readByte(0x07); 
     44        unsigned int nb_music_plugs=readWord(0x08); 
    4545        AvPlugInfoBlock *tmpAvPlugInfoBlock=NULL; 
    4646        AvMusicPlugInfoBlock *tmpAvMusicPlugInfoBlock=NULL; 
     
    5151        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock:   Number of music plugs=%d\n",nb_music_plugs); 
    5252 
    53                  
    54         if (nb_source_plugs>0) { 
    55                 for (unsigned int i=0;i<nb_source_plugs;i++) { 
    56                         debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: source plug=%d\n",i); 
     53        if (nb_dest_plugs>0) { 
     54                for (unsigned int i=0;i<nb_dest_plugs;i++) { 
     55                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: destination plug=%d\n",i); 
    5756                        tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 
    5857                         
     
    6261                                 
    6362                                // add to child list 
    64                                 cSourcePlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 
     63                                cDestinationPlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 
    6564                                 
    6665                                //tmpAvPlugInfoBlock->printContents(); 
     
    7877                } 
    7978        } 
    80  
    81         if (nb_dest_plugs>0) { 
    82                 for (unsigned int i=0;i<nb_dest_plugs;i++) { 
    83                         debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: destination plug=%d\n",i); 
     79         
     80        if (nb_source_plugs>0) { 
     81                for (unsigned int i=0;i<nb_source_plugs;i++) { 
     82                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: source plug=%d\n",i); 
    8483                        tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 
    8584                         
     
    8988                                 
    9089                                // add to child list 
    91                                 cDestinationPlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 
     90                                cSourcePlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 
    9291                                 
    9392                                //tmpAvPlugInfoBlock->printContents(); 
     
    153152} 
    154153 
     154AvPlugInfoBlock * AvRoutingStatusInfoBlock::getSourcePlugInfoBlock(unsigned char plug) { 
     155        vector<AvPlugInfoBlock *>::iterator it; 
     156        for( it = cSourcePlugInfoBlocks.begin(); it != cSourcePlugInfoBlocks.end(); it++ ) { 
     157                if((*it) && ((*it)->getPlugId() == plug)) { 
     158                        return *it; 
     159                } 
     160        } 
     161        return NULL; 
     162 
     163} 
     164 
     165AvPlugInfoBlock * AvRoutingStatusInfoBlock::getDestinationPlugInfoBlock(unsigned char plug) { 
     166        vector<AvPlugInfoBlock *>::iterator it; 
     167        for( it = cDestinationPlugInfoBlocks.begin(); it != cDestinationPlugInfoBlocks.end(); it++ ) { 
     168                if((*it) && ((*it)->getPlugId() == plug)) { 
     169                        return *it; 
     170                } 
     171        } 
     172        return NULL; 
     173 
     174} 
  • trunk/freebob/src/avroutingstatusinfoblock.h

    r38 r40  
    4343        virtual ~AvRoutingStatusInfoBlock(); 
    4444 
     45        unsigned char getNbDestinationPlugs() {return readByte(0x06);}; 
     46        unsigned char getNbSourcePlugs() {return readByte(0x07);}; 
     47        unsigned int getNbMusicPlugs() {return readWord(0x08);}; 
     48         
     49        AvPlugInfoBlock *getSourcePlugInfoBlock(unsigned char plug); 
     50        AvPlugInfoBlock *getDestinationPlugInfoBlock(unsigned char plug); 
    4551         
    4652protected: 
  • trunk/freebob/src/debugmodule.h

    r38 r40  
    2525#include "ieee1394service.h" 
    2626 
    27 #define DEBUG_LEVEL_INFO                (1<<0) 
    28 #define DEBUG_LEVEL_DEVICE              (1<<1) 
    29 #define DEBUG_LEVEL_SUBUNIT             (1<<2) 
    30 #define DEBUG_LEVEL_DESCRIPTOR          (1<<3) 
    31 #define DEBUG_LEVEL_INFOBLOCK           (1<<4) 
     27// global debug control. undefine to disable debug output 
     28#define DEBUG 
    3229 
    33 #define DEBUG_LEVEL_TRANSFERS           (1<<5) 
     30// debug print control flags 
     31#define DEBUG_LEVEL_INFO            (1<<0) 
     32#define DEBUG_LEVEL_DEVICE          (1<<1) 
     33#define DEBUG_LEVEL_SUBUNIT         (1<<2) 
     34#define DEBUG_LEVEL_DESCRIPTOR      (1<<3) 
     35#define DEBUG_LEVEL_INFOBLOCK       (1<<4) 
     36#define DEBUG_LEVEL_TRANSFERS       (1<<5) 
    3437 
    35 #define DEBUG_LEVEL_ALL  (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK | DEBUG_LEVEL_TRANSFERS ) 
    36  
     38// convenience defines 
     39#define DEBUG_LEVEL_ALL      (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK | DEBUG_LEVEL_TRANSFERS ) 
     40#define DEBUG_LEVEL_LOW      (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE) 
    3741#define DEBUG_LEVEL_MODERATE (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT) 
    3842#define DEBUG_LEVEL_HIGH     (DEBUG_LEVEL_MODERATE | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK) 
    3943 
    40 #define DEBUG_LEVEL DEBUG_LEVEL_HIGH  
    41  
    42 #define DEBUG 
     44// control the type of output to be generated by the debug macro's 
     45//  make sure that only one of them is defined. comment out the others. 
     46//  note: the HTML option is only usefull if you enclose the output in <pre>....</pre> tags 
     47#define DEBUG_OUTPUT_ANSICOLORED   
     48//#define DEBUG_OUTPUT_STANDARD 
     49//#define DEBUG_OUTPUT_HTML 
    4350 
    4451#ifdef DEBUG 
    45         #define debugError(format, args...) fprintf( stderr, "%s %s %d: " format,  __FILE__, __FUNCTION__, __LINE__, ##args ) 
    46 //      #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) { int idebug=Level; while(idebug) {printf(" "); idebug=idebug>>1;} printf( format, ##args ); } 
    47         #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("DEBUG %s %s %d :"  format, __FILE__, __FUNCTION__, __LINE__, ##args ); 
     52        // this allows for debug level control inside the code (e.g. enable transfer logging for some specific code block) 
     53        static int DEBUG_LEVEL=DEBUG_LEVEL_HIGH; 
     54        #define setDebugLevel(x) (DEBUG_LEVEL=x) 
     55                 
     56    #ifdef DEBUG_OUTPUT_ANSICOLORED 
    4857 
     58                #define debugError(format, args...) fprintf( stderr, "\033[37m\033[41m" "ERROR: %s %s %d: " format "\033[0m\033[49m ",  __FILE__, __FUNCTION__, __LINE__, ##args ) 
     59                         
     60                #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("\033[37m" "DEBUG %s %s %d:" "%s " format "\033[0m", __FILE__, __FUNCTION__, __LINE__, getLevelColor(Level), ##args ); 
     61                #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & Level) printf("%s" format "\033[0m",getLevelColor(Level), ##args ); 
     62 
     63                inline char *getLevelColor(unsigned int Level) { 
     64                        switch(Level) { 
     65                                case DEBUG_LEVEL_INFO: 
     66                                        return "\033[31m"; 
     67                                break; 
     68                                case DEBUG_LEVEL_DEVICE: 
     69                                        return "\033[32m"; 
     70                                break; 
     71                                case DEBUG_LEVEL_SUBUNIT: 
     72                                        return "\033[33m"; 
     73                                break; 
     74                                case DEBUG_LEVEL_DESCRIPTOR: 
     75                                        return "\033[34m"; // blue 
     76                                break; 
     77                                case DEBUG_LEVEL_INFOBLOCK: // purple 
     78                                        return "\033[35m"; 
     79                                break; 
     80                                case DEBUG_LEVEL_TRANSFERS: 
     81                                        return "\033[36m"; 
     82                                break; 
     83                                default: 
     84                                        return "\033[0m"; 
     85                                break; 
     86                                                 
     87                        } 
     88                } 
     89 
     90        #endif 
     91         
     92        #ifdef DEBUG_OUTPUT_HTML 
     93                #define debugError(format, args...) fprintf( stdout, "<P style='background: red;'><FONT color='white'>" "ERROR: %s %s %d: " format "</FONT></P>",  __FILE__, __FUNCTION__, __LINE__, ##args ) 
     94                #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("<FONT color='darkGray'>" "DEBUG %s %s %d:" "%s " format "</FONT></FONT>", __FILE__, __FUNCTION__, __LINE__, getLevelColor(Level), ##args ); 
     95                #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & Level) printf("%s" format "</FONT>",getLevelColor(Level), ##args ); 
     96                inline char *getLevelColor(unsigned int Level) { 
     97                        switch(Level) { 
     98                                case DEBUG_LEVEL_INFO: 
     99                                        return "<FONT color='darkRed'>"; 
     100                                break; 
     101                                case DEBUG_LEVEL_DEVICE: 
     102                                        return "<FONT color='darkGreen'>"; 
     103                                break; 
     104                                case DEBUG_LEVEL_SUBUNIT: 
     105                                        return "<FONT color='darkYellow'>"; 
     106                                break; 
     107                                case DEBUG_LEVEL_DESCRIPTOR: 
     108                                        return "<FONT color='darkBlue'>"; // blue 
     109                                break; 
     110                                case DEBUG_LEVEL_INFOBLOCK: // purple 
     111                                        return "<FONT color='darkMagenta'>"; 
     112                                break; 
     113                                case DEBUG_LEVEL_TRANSFERS: 
     114                                        return "<FONT color='darkCyan'>"; 
     115                                break; 
     116                                default: 
     117                                        return "<FONT color='black'>"; 
     118                                break; 
     119                                                 
     120                        } 
     121                } 
     122        #endif   
     123         
     124        #ifdef DEBUG_OUTPUT_STANDARD 
     125                #define debugError(format, args...) fprintf( stderr, "ERROR: %s %s %d: " format,  __FILE__, __FUNCTION__, __LINE__, ##args ) 
     126                #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("DEBUG %s %s %d :"  format, __FILE__, __FUNCTION__, __LINE__, ##args ); 
     127                #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & Level) printf(format, ##args ); 
     128        #endif 
     129         
    49130#else 
     131        #define DEBUG_LEVEL 
     132        #define setDebugLevel(x) 
    50133        #define debugError(format, args...)  
    51134        #define debugPrint(Level, format, args...)  
  • trunk/freebob/src/ieee1394service.cpp

    r38 r40  
    2222#include <libavc1394/avc1394.h> 
    2323#include <libavc1394/avc1394_vcr.h> 
     24#include <libiec61883/iec61883.h> 
     25 
     26 
    2427#include "ieee1394service.h" 
    2528#include "debugmodule.h" 
     
    161164                test->Initialize(); 
    162165                if (test->isInitialised()) { 
    163 #if 0   // the commented out code enables some tests of the several decriptor/infoblock classes 
    164                         debugPrint (DEBUG_LEVEL_INFO, "   Init successfull...\n"); 
    165                         debugPrint (DEBUG_LEVEL_INFO, "   Trying to create an AvDescriptor...\n"); 
    166                         AvDescriptor *testdesc=new AvDescriptor(test,AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x00); 
    167                         debugPrint (DEBUG_LEVEL_INFO, "    Created...\n"); 
    168                         debugPrint (DEBUG_LEVEL_INFO, "    Opening...\n"); 
    169                         testdesc->OpenReadOnly(); 
    170                          
    171                         debugPrint (DEBUG_LEVEL_INFO, "    Loading...\n"); 
    172  
    173                         testdesc->Load(); 
    174                                                  
    175                         debugPrint (DEBUG_LEVEL_INFO, "   Trying to create another AvDescriptor...\n"); 
    176                         AvDescriptor *testdesc2=new AvDescriptor(test,AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x80); 
    177                         debugPrint (DEBUG_LEVEL_INFO, "    Created...\n"); 
    178                         debugPrint (DEBUG_LEVEL_INFO, "    Opening...\n"); 
    179                         testdesc2->OpenReadOnly(); 
    180                          
    181                         debugPrint (DEBUG_LEVEL_INFO, "    Loading...\n"); 
    182  
    183                         testdesc2->Load(); 
    184                          
    185                         unsigned char *buff=new unsigned char[testdesc->getLength()]; 
    186                          
    187                         testdesc->readBuffer(0,testdesc->getLength(),buff); 
    188                         debugPrint (DEBUG_LEVEL_INFO, "    AvDescriptor 1 Contents:\n"); 
    189                          
    190                         hexDump(buff,testdesc->getLength()); 
    191                          
    192                         delete buff; 
    193                          
    194                         buff=new unsigned char[testdesc2->getLength()]; 
    195                          
    196                         testdesc2->readBuffer(0,testdesc2->getLength(),buff); 
    197                          
    198                         debugPrint (DEBUG_LEVEL_INFO, "    AvDescriptor 2 Contents:\n"); 
    199                         hexDump(buff,testdesc2->getLength()); 
    200                         delete buff; 
    201                          
    202                          
    203                         debugPrint (DEBUG_LEVEL_INFO, "    Closing AvDescriptors...\n"); 
    204  
    205                         testdesc->Close(); 
    206                         testdesc2->Close(); 
    207                          
    208                         debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvDescriptors...\n"); 
    209  
    210                         delete testdesc; 
    211                         delete testdesc2; 
    212                          
    213                         // test the AvMusicIdentifierDescriptor 
    214                         debugPrint (DEBUG_LEVEL_INFO, "   Trying to create an AvMusicIdentifierDescriptor...\n"); 
    215                         AvMusicIdentifierDescriptor *testdesc_mid=new AvMusicIdentifierDescriptor(test,0x00); 
    216                         debugPrint (DEBUG_LEVEL_INFO, "    Created...\n"); 
    217                         testdesc_mid->printCapabilities(); 
    218                         debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvMusicIdentifierDescriptor...\n"); 
    219                         delete testdesc_mid; 
    220 #endif 
    221                          
    222                         // test the AvMusicStatusDescriptor 
    223                         debugPrint (DEBUG_LEVEL_INFO, "   Trying to create an AvMusicStatusDescriptor...\n"); 
    224                         AvMusicStatusDescriptor *testdesc_mid2=new AvMusicStatusDescriptor(test,0x00); 
    225                         debugPrint (DEBUG_LEVEL_INFO, "    Created...\n"); 
    226                         testdesc_mid2->printCapabilities(); 
    227 #if 0    
    228                         // test the AvInfoBlock 
    229                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvInfoBlock...\n"); 
    230                          
    231                         AvInfoBlock *testblock1=new AvInfoBlock(testdesc_mid2,0); 
    232                         debugPrint (DEBUG_LEVEL_INFO, "      Length: 0x%04X (%d)  Type: 0x%04X\n",testblock1->getLength(),testblock1->getLength(),testblock1->getType()); 
    233                          
    234                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to fetch next block...\n"); 
    235                         // PP: might be better to have something like AvInfoBlock::moveToNextBlock(); 
    236                         AvInfoBlock *testblock2=new AvInfoBlock(testdesc_mid2,2+testblock1->getLength()); 
    237                          
    238                         debugPrint (DEBUG_LEVEL_INFO, "      Length: 0x%04X (%d)  Type: 0x%04X\n",testblock2->getLength(),testblock2->getLength(),testblock2->getType()); 
     166                        unsigned char fmt; 
     167                        quadlet_t fdf; 
     168                        test->getInputPlugSignalFormat(0,&fmt,&fdf); 
     169                        debugPrint (DEBUG_LEVEL_INFO, "   fmt=%02X fdf=%08X\n",fmt,fdf); 
     170                        test->getInputPlugSignalFormat(1,&fmt,&fdf); 
     171                        debugPrint (DEBUG_LEVEL_INFO, "   fmt=%02X fdf=%08X\n",fmt,fdf); 
     172                        test->getOutputPlugSignalFormat(0,&fmt,&fdf); 
     173                        debugPrint (DEBUG_LEVEL_INFO, "   fmt=%02X fdf=%08X\n",fmt,fdf); 
     174                        test->getOutputPlugSignalFormat(1,&fmt,&fdf); 
     175                        debugPrint (DEBUG_LEVEL_INFO, "   fmt=%02X fdf=%08X\n",fmt,fdf); 
     176                        test->printConnections(); 
     177                } 
    239178                 
    240                         // test the general status info block 
    241                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvGeneralMusicStatusInfoBlock...\n"); 
    242                         AvGeneralMusicInfoBlock *testblock3=new AvGeneralMusicInfoBlock(testdesc_mid2,0); 
    243                          
    244                         // PP: the next tests could fail because of the difference in hardware. 
    245                         // these classes are intended to be used in the parser. I use hardcoded addresses in the test code, 
    246                         // instead of derived addresses based on the parent descriptors. 
    247                         // this is only intended to debug the base classes before using them in the parser. 
    248                          
    249                          
    250                         // this one should be valid (on my config) 
    251                         debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock3->isValid()?"yes":"no")); 
    252                         debugPrint (DEBUG_LEVEL_INFO, "      canTransmitBlocking? %s\n",(testblock3->canTransmitBlocking()?"yes":"no")); 
    253                         debugPrint (DEBUG_LEVEL_INFO, "      canTransmitNonblocking? %s\n",(testblock3->canTransmitNonblocking()?"yes":"no")); 
    254                         debugPrint (DEBUG_LEVEL_INFO, "      canReceiveBlocking? %s\n",(testblock3->canReceiveBlocking()?"yes":"no")); 
    255                         debugPrint (DEBUG_LEVEL_INFO, "      canReceiveNonblocking? %s\n",(testblock3->canReceiveNonblocking()?"yes":"no")); 
    256                          
    257                         delete testblock3; 
    258                         // this one shouldn't be valid 
    259                         testblock3=new AvGeneralMusicInfoBlock(testdesc_mid2,2+testblock1->getLength()); 
    260                         debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock3->isValid()?"yes":"no")); 
    261                         debugPrint (DEBUG_LEVEL_INFO, "      canTransmitBlocking? %s\n",(testblock3->canTransmitBlocking()?"yes":"no")); 
    262                         debugPrint (DEBUG_LEVEL_INFO, "      canTransmitNonblocking? %s\n",(testblock3->canTransmitNonblocking()?"yes":"no")); 
    263                         debugPrint (DEBUG_LEVEL_INFO, "      canReceiveBlocking? %s\n",(testblock3->canReceiveBlocking()?"yes":"no")); 
    264                         debugPrint (DEBUG_LEVEL_INFO, "      canReceiveNonblocking? %s\n",(testblock3->canReceiveNonblocking()?"yes":"no")); 
    265                          
    266                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvAudioInfoBlock...\n"); 
    267                          
    268                         AvAudioInfoBlock *testblock4=new AvAudioInfoBlock(testdesc_mid2,0x01A); 
    269                         debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock4->isValid()?"yes":"no")); 
    270                         debugPrint (DEBUG_LEVEL_INFO, "      Length? 0x%04X (%d)\n",testblock4->getLength(),testblock4->getLength()); 
    271                         debugPrint (DEBUG_LEVEL_INFO, "      streams: %d\n",testblock4->getNbStreams()); 
    272                         debugPrint (DEBUG_LEVEL_INFO, "      Name: %s\n",testblock4->getName()); 
    273                          
    274                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvMidiInfoBlock...\n"); 
    275  
    276                         AvMidiInfoBlock *testblock5=new AvMidiInfoBlock(testdesc_mid2,0x099); 
    277                         debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock5->isValid()?"yes":"no")); 
    278                         debugPrint (DEBUG_LEVEL_INFO, "      Length? 0x%04X (%d)\n",testblock5->getLength(),testblock5->getLength()); 
    279                         unsigned int nb_midi_streams=testblock5->getNbStreams(); 
    280                         debugPrint (DEBUG_LEVEL_INFO, "      streams: %d\n",nb_midi_streams); 
    281                         for (unsigned int i=0;i<nb_midi_streams;i++) { 
    282                                 debugPrint (DEBUG_LEVEL_INFO, "       stream %d name: %s\n",i,testblock5->getName(i)); 
    283                         } 
    284                          
    285                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvAudioSyncInfoBlock...\n"); 
    286                         AvAudioSyncInfoBlock *testblock6=new AvAudioSyncInfoBlock(testdesc_mid2,0x0262); 
    287                         debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock6->isValid()?"yes":"no")); 
    288                         debugPrint (DEBUG_LEVEL_INFO, "      canSyncBus? %s\n",(testblock6->canSyncBus()?"yes":"no")); 
    289                         debugPrint (DEBUG_LEVEL_INFO, "      canSyncExternal? %s\n",(testblock6->canSyncExternal()?"yes":"no")); 
    290                          
    291                          
    292                         debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvInfoBlocks...\n"); 
    293                          
    294                         delete testblock1; 
    295                         delete testblock2; 
    296                         delete testblock3; 
    297                         delete testblock4; 
    298                         delete testblock5; 
    299                         delete testblock6; 
    300                          
    301                         // now try to parse a full source plug entry 
    302                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvSourcePlugInfoBlock...\n"); 
    303                         AvSourcePlugInfoBlock *testblock7=new AvSourcePlugInfoBlock(testdesc_mid2,0x13); 
    304                          
    305                         debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvSourcePlugInfoBlock...\n"); 
    306                          
    307                         delete testblock7; 
    308                          
    309                         // now try to parse the full music output plug status infoblock 
    310                         debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvOutputPlugStatusInfoBlock...\n"); 
    311                         AvOutputPlugStatusInfoBlock *testblock8=new AvOutputPlugStatusInfoBlock(testdesc_mid2,0x0C); 
    312                          
    313                         debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvOutputPlugStatusInfoBlock...\n"); 
    314                          
    315                         delete testblock8; 
    316                         debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvMusicStatusDescriptor...\n"); 
    317 #endif                   
    318                         delete testdesc_mid2;                    
    319                 } 
    320                 debugPrint (DEBUG_LEVEL_INFO, "   Deleting AvDevice...\n"); 
     179                debugPrint (DEBUG_LEVEL_INFO, "   Deleting AvDevice...\n"); 
    321180                delete test; 
    322181