root/trunk/freebob/src/busmgr.cpp

Revision 4, 3.6 kB (checked in by wagi, 20 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* busmgr.cpp
2    Copyright (C) 2004 by Daniel Wagner
3
4    This file is part of FreeBob.
5
6    FreeBob is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    FreeBob is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with FreeBob; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18    MA 02111-1307 USA.  */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22
23 #include "ieee1394io.h"
24 #include "busmgr.h"
25
26
27 BusMgr::BusMgr (Ieee1394Io& ieee1394Io)
28   : m_ieee1394Io(ieee1394Io)
29 {
30 }
31
32 BusMgr::~BusMgr ()
33 {
34 }
35
36 EReturnCodes
37 BusMgr::initialize ()
38 {
39   EReturnCodes eRC;
40
41   m_ieee1394Io.sigGeneration.connect(sigc::mem_fun(this,
42                                                    &BusMgr::slotGeneration));
43
44
45   printf ("asdf");
46   eRC = scanBus ();
47   if (eRC != eRC_Success) {
48     fprintf (stderr, "Error scanning 1394 bus for cards\n");
49     return  eRC_Scaning1394BusFailed;
50   }
51
52   return eRC_Success;
53 }
54
55 void
56 BusMgr::slotGeneration (GenerationT generation)
57 {
58   printf ("BusMgr received a generation update (%d)\n", generation);
59   printf ("Rescan bus\n");
60
61   EReturnCodes eRC;
62
63   eRC = scanBus ();
64   if (eRC != eRC_Success) {
65     fprintf (stderr, "Error scanning 1394 bus for cards\n");
66   } 
67 }
68
69 EReturnCodes
70 BusMgr::scanBus ()
71 {
72   EReturnCodes eRC;
73   int iNodeCount;
74   rom1394_directory romDir;
75  
76   eRC = m_ieee1394Io.getNodeCount (&iNodeCount);
77
78   for (int nodeId = 0; nodeId < iNodeCount; nodeId++) {
79     eRC = m_ieee1394Io.getRomDirectory (nodeId, &romDir);
80     if (eRC != eRC_Success) {
81       fprintf (stderr, "Error reading config rom directory for node %d\n",
82                nodeId);
83       continue;
84     }
85    
86     printRomDirectory (nodeId, &romDir);
87   }
88
89   return eRC_Success;
90 }
91
92 EReturnCodes
93 BusMgr::printRomDirectory (int nodeId,
94                            rom1394_directory* romDir)
95 {
96   int length;
97   octlet_t guid;
98   int busId;
99
100   rom1394_bus_options busOptions;
101
102   printf ( "\nNode %d: \n", nodeId);
103   printf ( "-------------------------------------------------\n");
104   m_ieee1394Io.getBusInfoBlockLength (nodeId, &length);
105   printf ("bus info block length = %d\n", length);
106   m_ieee1394Io.getBusId (nodeId, &busId);
107   printf ("bus id = 0x%08x\n", busId);
108   m_ieee1394Io.getBusOptions (nodeId, &busOptions);
109   printf ("bus options:\n");
110   printf ("    isochronous resource manager capable: %d\n", busOptions.irmc);
111   printf ("    cycle master capable                : %d\n", busOptions.cmc);
112   printf ("    isochronous capable                 : %d\n", busOptions.isc);
113   printf ("    bus manager capable                 : %d\n", busOptions.bmc);
114   printf ("    cycle master clock accuracy         : %d ppm\n", busOptions.cyc_clk_acc);
115   printf ("    maximum asynchronous record size    : %d bytes\n", busOptions.max_rec);
116   m_ieee1394Io.getGuid (nodeId, &guid);
117   printf ("GUID: 0x%08x%08x\n", (quadlet_t) (guid>>32),
118           (quadlet_t) (guid & 0xffffffff));
119   printf ("directory:\n");
120   printf ("    node capabilities    : 0x%08x\n", romDir->node_capabilities);
121   printf ("    vendor id            : 0x%08x\n", romDir->vendor_id);
122   printf ("    unit spec id         : 0x%08x\n", romDir->unit_spec_id);
123   printf ("    unit software version: 0x%08x\n", romDir->unit_sw_version);
124   printf ("    model id             : 0x%08x\n", romDir->model_id);
125   printf ("    textual leaves       : %s\n", romDir->label);
126  
127   return eRC_Success;
128 }
Note: See TracBrowser for help on using the browser.