root/trunk/libffado/src/libavc/general/avc_unit_info.cpp

Revision 618, 2.3 kB (checked in by ppalmers, 17 years ago)

move serialization routines to libutil such that they can be used for non-AVC stuff too (fireworks EFC)

  • 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  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "avc_unit_info.h"
25 #include "libutil/cmd_serialize.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include <netinet/in.h>
29 #include <iostream>
30
31 using namespace std;
32
33 namespace AVC {
34
35
36 UnitInfoCmd::UnitInfoCmd( Ieee1394Service& ieee1349service )
37     : AVCCommand( ieee1349service, AVC1394_CMD_UNIT_INFO )
38     , m_reserved( 0xff )
39     , m_unit_type( 0xff )
40     , m_unit( 0xff )
41     , m_company_id( 0xffffffff )
42 {
43 }
44
45 UnitInfoCmd::~UnitInfoCmd()
46 {
47 }
48
49 bool
50 UnitInfoCmd::serialize( Util::IOSSerialize& se )
51 {
52     AVCCommand::serialize( se );
53
54     se.write( m_reserved, "UnitInfoCmd reserved" );
55     byte_t operand = ( m_unit_type << 3 ) | ( m_unit & 0x7 );
56     se.write( operand, "UnitInfoCmd unit_type and unit" );
57     operand = ( m_company_id >> 16 ) & 0xff;
58     se.write( operand, "UnitInfoCmd company_ID (2)" );
59     operand = ( m_company_id >> 8 ) & 0xff;
60     se.write( operand, "UnitInfoCmd company_ID (1)" );
61     operand = ( m_company_id >> 0 ) & 0xff;
62     se.write( operand, "UnitInfoCmd company_ID (0)" );
63
64     return true;
65 }
66
67 bool
68 UnitInfoCmd::deserialize( Util::IISDeserialize& de )
69 {
70     AVCCommand::deserialize( de );
71
72     de.read( &m_reserved );
73
74     byte_t operand;
75     de.read( &operand );
76     m_unit_type = ( operand >> 3 );
77     m_unit = ( operand & 0x7 );
78
79     de.read( &operand );
80     m_company_id = 0;
81     m_company_id |= operand << 16;
82     de.read( &operand );
83     m_company_id |= operand << 8;
84     de.read( &operand );
85     m_company_id |= operand;
86
87     return true;
88 }
89
90 }
Note: See TracBrowser for help on using the browser.