Changeset 18

Show
Ignore:
Timestamp:
11/22/04 13:06:38 (19 years ago)
Author:
pieterpalmers
Message:

- Placed some extra debug functions in a new file debugmodule.cpp
- Added AvDescriptor? class as a generic AVC descriptor handler class
- Added the new files to the makefile

REMARK: The new code is still quite messy and undebugged. This commit is mainly to expose my current work, to make sure no work is duplicated.

Files:

Legend:

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

    r16 r18  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
     20#include <errno.h> 
     21#include <libavc1394/avc1394.h> 
     22#include <libavc1394/avc1394_vcr.h> 
     23#include "debugmodule.h" 
    2124#include "avdevice.h" 
    2225 
    23 AvDevice::AvDevice(
     26AvDevice::AvDevice(int port, int node
    2427{ 
     28        iNodeId=node; 
     29        m_iPort=port; 
     30 
     31        // check to see if a device is really present? 
     32} 
     33 
     34FBReturnCodes 
     35AvDevice::Initialize() { 
     36   if (!m_bInitialised) { 
     37 
     38        m_handle = raw1394_new_handle(); 
     39        if ( !m_handle ) { 
     40            if ( !errno ) { 
     41                fprintf( stderr,  "libraw1394 not compatible.\n" ); 
     42            } else { 
     43                perror ("Could not get 1394 handle"); 
     44                fprintf (stderr, "Is ieee1394 and raw1394 driver loaded?\n"); 
     45            } 
     46            return eFBRC_Creating1394HandleFailed; 
     47        } 
     48         
     49        raw1394_set_userdata( m_handle, this ); 
     50         
     51        if ( raw1394_set_port( m_handle,  m_iPort ) < 0 ) { 
     52            perror( "Could not set port" ); 
     53            return eFBRC_Setting1394PortFailed; 
     54        } 
     55   } 
     56    
     57   m_bInitialised = true; 
     58   return eFBRC_Success; 
     59         
     60} 
     61 
     62bool AvDevice::isInitialised() { 
     63        return m_bInitialised; 
    2564} 
    2665 
    2766AvDevice::~AvDevice() 
    2867{ 
     68    if ( m_handle ) { 
     69        raw1394_destroy_handle( m_handle ); 
     70        m_handle = 0; 
     71    } 
    2972} 
     73 
     74/* Function to execute an AVC transaction, i.e. send command/status and get response 
     75 * main purpose is wrapping the avc1394 function call to output some debugging comments. 
     76 */ 
     77quadlet_t * AvDevice::avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len) { 
     78        quadlet_t *response; 
     79        unsigned char *request_pos; 
     80        unsigned int i; 
     81        response = avc1394_transaction_block(m_handle, iNodeId, request, request_len, 2); 
     82        if (request != NULL) { 
     83                fprintf(stderr,"  REQUEST:     "); 
     84                /* request is in machine byte order. this function is for intel architecure */ 
     85                for (i=0;i<request_len;i++) { 
     86                        request_pos=(unsigned char *)(request+i); 
     87                        fprintf(stderr, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3)); 
     88                } 
     89                fprintf(stderr,"\n"); 
     90                fprintf(stderr,"      => "); 
     91                fprintf(stderr,"                     "); 
     92                request_pos=(unsigned char *)(request); 
     93                fprintf(stderr, "subunit_type=%02X  subunit_id=%02X  opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF); 
     94                fprintf(stderr,"\n"); 
     95        }        
     96        if (response != NULL) { 
     97                /* response is in order of receiving, i.e. msb first */ 
     98                fprintf(stderr,"  -> RESPONSE: "); 
     99                for (i=0;i<response_len;i++) { 
     100                        fprintf(stderr, "0x%08X ", response[i]); 
     101                } 
     102                fprintf(stderr,"\n"); 
     103                fprintf(stderr,"      => "); 
     104                switch (response[0]&0xFF000000) { 
     105                        case AVC1394_RESPONSE_NOT_IMPLEMENTED: 
     106                                fprintf(stderr,"Not Implemented      "); 
     107                        break; 
     108                        case AVC1394_RESPONSE_ACCEPTED: 
     109                                fprintf(stderr,"Accepted             "); 
     110                        break; 
     111                        case AVC1394_RESPONSE_REJECTED: 
     112                                fprintf(stderr,"Rejected             "); 
     113                        break; 
     114                        case AVC1394_RESPONSE_IN_TRANSITION: 
     115                                fprintf(stderr,"In Transition        "); 
     116                        break; 
     117                        case AVC1394_RESPONSE_IMPLEMENTED: 
     118                                fprintf(stderr,"Implemented / Stable "); 
     119                        break; 
     120                        case AVC1394_RESPONSE_CHANGED: 
     121                                fprintf(stderr,"Changed              "); 
     122                        break; 
     123                        case AVC1394_RESPONSE_INTERIM:           
     124                                fprintf(stderr,"Interim              "); 
     125                        break; 
     126                        default: 
     127                                fprintf(stderr,"Unknown response     "); 
     128                        break; 
     129                } 
     130                fprintf(stderr, "subunit_type=%02X  subunit_id=%02X  opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF); 
     131                fprintf(stderr,"\n"); 
     132        } 
     133        return response; 
     134 
     135} 
  • trunk/freebob/src/avdevice.h

    r16 r18  
    2222#define AVDEVICE_H 
    2323 
     24#include "ieee1394service.h" 
     25 
    2426class AvDevice { 
    2527 public: 
    26     AvDevice(); 
     28    AvDevice(int node,int port); 
    2729    virtual ~AvDevice(); 
     30     
     31    quadlet_t * avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len); 
     32     
     33    FBReturnCodes AvDevice::Initialize(); 
     34     
     35    bool AvDevice::isInitialised(); 
     36     
     37 private: 
     38        int iNodeId; 
     39        raw1394handle_t m_handle; 
     40        int m_iPort; 
     41        bool m_bInitialised; 
    2842}; 
    2943 
  • trunk/freebob/src/debugmodule.h

    r14 r18  
    2323 
    2424#include <stdio.h> 
     25#include "ieee1394service.h" 
    2526 
    2627#define DEBUG_LEVEL_INFO     5 
  • trunk/freebob/src/ieee1394service.cpp

    r17 r18  
    2525#include "debugmodule.h" 
    2626 
     27#include "avdevice.h" 
     28#include "avdescriptor.h" 
     29 
    2730Ieee1394Service* Ieee1394Service::m_pInstance = 0; 
    2831 
     
    138141                // XXX 
    139142                // create avcDevice which discovers itself :) 
     143                 
     144                // PP: just a static try, don't want to mess with the device manager yet... 
     145                // Remark: the AvDevice and AvDescriptor aren't debugged thouroughly yet! 
     146                //         the following code is the only debug I had time for... to be continued! (later this week) 
     147                 
     148                debugPrint (DEBUG_LEVEL_INFO, "  Trying to create an AvDevice...\n",""); 
     149                AvDevice *test=new AvDevice(m_iPort, iNodeId); 
     150                debugPrint (DEBUG_LEVEL_INFO, "   Created...\n",""); 
     151                test->Initialize(); 
     152                if (test->isInitialised()) { 
     153                        debugPrint (DEBUG_LEVEL_INFO, "   Init successfull...\n",""); 
     154                        debugPrint (DEBUG_LEVEL_INFO, "   Trying to create an AvDescriptor...\n",""); 
     155                        AvDescriptor *testdesc=new AvDescriptor(test,AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x00); 
     156                        debugPrint (DEBUG_LEVEL_INFO, "    Created...\n",""); 
     157                        debugPrint (DEBUG_LEVEL_INFO, "    Opening...\n",""); 
     158                        testdesc->OpenReadOnly(); 
     159 
     160                                                 
     161                        debugPrint (DEBUG_LEVEL_INFO, "    Closing...\n",""); 
     162                        testdesc->Close(); 
     163                         
     164                        debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvDescriptor...\n",""); 
     165                        delete testdesc; 
     166                         
     167                } 
     168                debugPrint (DEBUG_LEVEL_INFO, "   Deleting AvDevice...\n",""); 
     169                delete test; 
     170                 
    140171            } 
    141172            break; 
  • trunk/freebob/src/Makefile.am

    r16 r18  
    3434        avdevicepool.h \ 
    3535        avdevicepool.cpp \ 
     36        avdescriptor.h \ 
     37        avdescriptor.cpp \ 
     38        debugmodule.cpp \ 
    3639        main.cpp  
    3740