| 1 |
/* avc_subunit_info.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 |
|
| 21 |
#include "avc_subunit_info.h"
|
| 22 |
#include "serialize.h"
|
| 23 |
#include "ieee1394service.h"
|
| 24 |
|
| 25 |
#include <netinet/in.h>
|
| 26 |
#include <iostream>
|
| 27 |
|
| 28 |
using namespace std;
|
| 29 |
|
| 30 |
SubUnitInfoCmd::SubUnitInfoCmd( Ieee1394Service* ieee1349service )
|
| 31 |
: AVCCommand( ieee1349service, AVC1394_CMD_SUBUNIT_INFO )
|
| 32 |
{
|
| 33 |
clear();
|
| 34 |
}
|
| 35 |
|
| 36 |
bool
|
| 37 |
SubUnitInfoCmd::clear()
|
| 38 |
{
|
| 39 |
m_page = 0xff;
|
| 40 |
m_extension_code = 0x7;
|
| 41 |
for ( int i = 0; i < eMaxSubunitsPerPage; ++i ) {
|
| 42 |
m_table[i].m_subunit_type = 0xff;
|
| 43 |
m_table[i].m_max_subunit_id = 0xff;
|
| 44 |
}
|
| 45 |
m_nrOfValidEntries = 0;
|
| 46 |
return true;
|
| 47 |
}
|
| 48 |
|
| 49 |
|
| 50 |
SubUnitInfoCmd::~SubUnitInfoCmd()
|
| 51 |
{
|
| 52 |
}
|
| 53 |
|
| 54 |
bool
|
| 55 |
SubUnitInfoCmd::serialize( IOSSerialize& se )
|
| 56 |
{
|
| 57 |
AVCCommand::serialize( se );
|
| 58 |
|
| 59 |
byte_t operand = 0;
|
| 60 |
operand = (( m_page & 0x7 ) << 4 ) | ( m_extension_code & 0x7 );
|
| 61 |
se.write( operand, "SubUnitInfoCmd page and extension_code" );
|
| 62 |
|
| 63 |
for ( int i = 0; i < eMaxSubunitsPerPage; ++i ) {
|
| 64 |
operand = ( m_table[i].m_subunit_type << 3 )
|
| 65 |
| ( m_table[i].m_max_subunit_id & 0x7 );
|
| 66 |
se.write( operand, "SubUnitInfoCmd subunit_type and max_subunit_ID" );
|
| 67 |
}
|
| 68 |
|
| 69 |
return true;
|
| 70 |
}
|
| 71 |
|
| 72 |
bool
|
| 73 |
SubUnitInfoCmd::deserialize( IISDeserialize& de )
|
| 74 |
{
|
| 75 |
AVCCommand::deserialize( de );
|
| 76 |
|
| 77 |
byte_t operand;
|
| 78 |
de.read( &operand );
|
| 79 |
m_page = ( operand >> 4 ) & 0x7;
|
| 80 |
m_extension_code = operand & 0x7;
|
| 81 |
|
| 82 |
m_nrOfValidEntries = 0;
|
| 83 |
for ( int i = 0; i < eMaxSubunitsPerPage; ++i ) {
|
| 84 |
de.read( &operand );
|
| 85 |
m_table[i].m_subunit_type = operand >> 3;
|
| 86 |
m_table[i].m_max_subunit_id = operand & 0x7;
|
| 87 |
|
| 88 |
if ( operand != 0xff ) {
|
| 89 |
m_nrOfValidEntries++;
|
| 90 |
}
|
| 91 |
}
|
| 92 |
|
| 93 |
return true;
|
| 94 |
}
|