root/trunk/libfreebob/src/libfreebobavc/ieee1394service.cpp

Revision 125, 2.4 kB (checked in by wagi, 18 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* tempate.cpp
2  * Copyright (C) 2005 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 "ieee1394service.h"
21
22 #include <libavc1394/avc1394.h>
23
24 #include <errno.h>
25
26 #include <iostream>
27
28 using namespace std;
29
30 Ieee1394Service::Ieee1394Service()
31     : m_handle( 0 )
32     , m_port( -1 )
33 {
34 }
35
36 Ieee1394Service::~Ieee1394Service()
37 {
38 }
39
40 bool
41 Ieee1394Service::initialize( int port )
42 {
43     m_handle = raw1394_new_handle();
44     if ( !m_handle ) {
45         if ( !errno ) {
46             cerr << "libraw1394 not compatible" << endl;
47         } else {
48             perror( "Could not get 1394 handle" );
49             cerr << "Is ieee1394 and raw1394 driver loaded?" << endl;
50         }
51         return false;
52     }
53
54     if ( raw1394_set_port( m_handle,  port ) < 0 ) {
55         perror( "Could not set port" );
56         return false;
57     }
58
59     m_port = port;
60     return true;
61 }
62
63 int
64 Ieee1394Service::getNodeCount()
65 {
66     return raw1394_get_nodecount( m_handle );
67 }
68
69 bool
70 Ieee1394Service::read( fb_nodeid_t nodeId,
71                        fb_nodeaddr_t addr,
72                        size_t size,
73                        fb_quadlet_t* buffer )
74 {
75     return raw1394_read( m_handle, nodeId, addr,  size,  buffer ) != 0;
76 }
77
78 bool
79 Ieee1394Service::write( fb_nodeid_t   nodeId,
80                         fb_nodeaddr_t addr,
81                         size_t        length,
82                         fb_quadlet_t  *data )
83 {
84     return raw1394_write( m_handle, nodeId, addr, length, data ) != 0;
85 }
86
87 fb_quadlet_t*
88 Ieee1394Service::transactionBlock( fb_nodeid_t nodeId,
89                                    fb_quadlet_t* buf,
90                                    int len )
91 {
92     return avc1394_transaction_block( m_handle, nodeId, buf, len,  1 );
93 }
Note: See TracBrowser for help on using the browser.