root/branches/streaming-rework/src/bebob/bebob_dl_codes.cpp

Revision 407, 9.1 kB (checked in by pieterpalmers, 16 years ago)

- Changed the way the device class configure options are handled. Now they are handled in the makefiles instead of the source files. The only source file that still contains the #ifdef's is devicemanager.cpp, to conditionally include the device class include files and to conditionally probe the classes that might be supported.
- added a configure option to disable the compilation of the test programs in tests/
- cleaned up the ADMTP transmit streamprocessor. Now it sends silenced packets when in the disabled state, instead of no-data packets
- added a getNodeID() to ieee1394service
- made comments in ieee1394service.h doxygen compliant

Line 
1 /* bebob_dl_codes.cpp
2  * Copyright (C) 2006 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 "bebob/bebob_dl_codes.h"
21 #include "bebob/bebob_dl_bcd.h"
22
23 unsigned short BeBoB::CommandCodes::m_gCommandId = 0;
24
25 BeBoB::CommandCodes::CommandCodes( fb_quadlet_t protocolVersion,
26                                    fb_byte_t commandCode,
27                                    size_t     msgSize,
28                                    fb_byte_t operandSizeRequest,
29                                    fb_byte_t operandSizeRespone )
30     : m_commandId( m_gCommandId++ )
31     , m_protocolVersion( protocolVersion )
32     , m_commandCode( commandCode )
33     , m_msgSize( msgSize )
34     , m_operandSizeRequest( operandSizeRequest )
35     , m_operandSizeResponse( operandSizeRespone )
36     , m_resp_protocolVersion( 0 )
37     , m_resp_commandId( 0 )
38     , m_resp_commandCode( 0 )
39     , m_resp_operandSize( 0 )
40 {
41 }
42
43 BeBoB::CommandCodes::~CommandCodes()
44 {
45 }
46
47 bool
48 BeBoB::CommandCodes::serialize( IOSSerialize& se )
49 {
50     byte_t tmp;
51
52     bool result = se.write( m_protocolVersion, "CommandCodes: protocol version" );
53     tmp = m_commandId & 0xff;
54     result &= se.write( tmp, "CommandCodes: command id low" );
55     tmp = m_commandId >> 8;
56     result &= se.write( tmp, "CommandCodes: command id high" );
57     result &= se.write( m_commandCode, "CommandCodes: command code" );
58     result &= se.write( m_operandSizeRequest, "CommandCodes: request operand size" );
59
60     return result;
61 }
62
63 bool
64 BeBoB::CommandCodes::deserialize( IISDeserialize& de )
65 {
66     bool result = de.read( &m_resp_protocolVersion );
67     fb_byte_t tmp;
68     result &= de.read( &tmp );
69     m_resp_commandId = tmp;
70     result &= de.read( &tmp );
71     m_resp_commandId |= tmp << 8;
72     result &= de.read( &m_resp_commandCode );
73     result &= de.read( &m_resp_operandSize );
74
75     return result;
76 }
77
78 size_t
79 BeBoB::CommandCodes::getMaxSize()
80 {
81     return 2 * sizeof( fb_quadlet_t ) + m_msgSize;
82 }
83
84
85 ////////////////////////////////
86
87 BeBoB::CommandCodesReset::CommandCodesReset( fb_quadlet_t protocolVersion,
88                                              EStartMode startMode )
89     : CommandCodes( protocolVersion, eCmdC_Reset, sizeof( m_startMode ), 1, 0 )
90     , m_startMode( startMode )
91 {
92 }
93
94 BeBoB::CommandCodesReset::~CommandCodesReset()
95 {
96 }
97
98 bool
99 BeBoB::CommandCodesReset::serialize( IOSSerialize& se )
100 {
101     bool result = CommandCodes::serialize( se );
102     result &= se.write( m_startMode, "CommandCodesReset: boot mode" );
103
104     return result;
105 }
106
107 bool
108 BeBoB::CommandCodesReset::deserialize( IISDeserialize& de )
109 {
110     return CommandCodes::deserialize( de );
111 }
112
113 ////////////////////////////////
114
115 BeBoB::CommandCodesProgramGUID::CommandCodesProgramGUID(
116     fb_quadlet_t protocolVersion,
117     fb_octlet_t guid )
118     : CommandCodes( protocolVersion, eCmdC_ProgramGUID, sizeof( m_guid ), 2, 0 )
119     , m_guid( guid )
120 {
121 }
122
123 BeBoB::CommandCodesProgramGUID::~CommandCodesProgramGUID()
124 {
125 }
126
127 bool
128 BeBoB::CommandCodesProgramGUID::serialize( IOSSerialize& se )
129 {
130     bool result = CommandCodes::serialize( se );
131     fb_quadlet_t tmp = m_guid >> 32;
132     result &= se.write( tmp, "CommandCodesProgramGUID: GUID (high)" );
133     tmp = m_guid & 0xffffffff;
134     result &= se.write( tmp, "CommandCodesProgramGUID: GUID (low)" );
135
136     return result;
137 }
138
139 bool
140 BeBoB::CommandCodesProgramGUID::deserialize( IISDeserialize& de )
141 {
142     return CommandCodes::deserialize( de );
143 }
144
145 ////////////////////////////////
146
147 BeBoB::CommandCodesDownloadStart::CommandCodesDownloadStart(
148     fb_quadlet_t protocolVersion,
149     EObject object )
150     : CommandCodes( protocolVersion, eCmdC_DownloadStart, 10*4, 10, 1 )
151     , m_object( object )
152     , m_date( 0 )
153     , m_time( 0 )
154     , m_id( 0 )
155     , m_version( 0 )
156     , m_address( 0 )
157     , m_length( 0 )
158     , m_crc( 0 )
159 {
160 }
161
162 BeBoB::CommandCodesDownloadStart::~CommandCodesDownloadStart()
163 {
164 }
165
166 bool
167 BeBoB::CommandCodesDownloadStart::serialize( IOSSerialize& se )
168 {
169     bool result = CommandCodes::serialize( se );
170
171     result &= se.write( m_object,  "CommandCodesDownloadStart: object" );
172     for (  unsigned int i = 0; i < sizeof( m_date ); ++i ) {
173         fb_byte_t* tmp = ( fb_byte_t* )( &m_date );
174         result &= se.write( tmp[i], "CommandCodesDownloadStart: date" );
175     }
176     for (  unsigned int i = 0; i < sizeof( m_date ); ++i ) {
177         fb_byte_t* tmp = ( fb_byte_t* )( &m_time );
178         result &= se.write( tmp[i], "CommandCodesDownloadStart: time" );
179     }
180     result &= se.write( m_id,      "CommandCodesDownloadStart: id" );
181     result &= se.write( m_version, "CommandCodesDownloadStart: version" );
182     result &= se.write( m_address, "CommandCodesDownloadStart: address" );
183     result &= se.write( m_length,  "CommandCodesDownloadStart: length" );
184     result &= se.write( m_crc,     "CommandCodesDownloadStart: crc" );
185
186     return result;
187 }
188
189 bool
190 BeBoB::CommandCodesDownloadStart::deserialize( IISDeserialize& de )
191 {
192     bool result = CommandCodes::deserialize( de );
193     result &= de.read( reinterpret_cast<fb_quadlet_t*>( &m_resp_max_block_size ) );
194
195     return result;
196 }
197
198 ////////////////////////////////
199
200 BeBoB::CommandCodesDownloadBlock::CommandCodesDownloadBlock(
201     fb_quadlet_t protocolVersion )
202     : CommandCodes( protocolVersion,
203                     eCmdC_DownloadBlock,
204                     12,
205                     3,
206                     2 )
207     , m_seqNumber( 0 )
208     , m_address ( 0 )
209     , m_resp_seqNumber( 0 )
210     , m_resp_errorCode( 0 )
211 {
212 }
213
214 BeBoB::CommandCodesDownloadBlock::~CommandCodesDownloadBlock()
215 {
216 }
217
218 bool
219 BeBoB::CommandCodesDownloadBlock::serialize( IOSSerialize& se )
220 {
221     bool result = CommandCodes::serialize( se );
222     result &= se.write( m_seqNumber, "CommandCodesDownloadBlock: sequence number" );
223     result &= se.write( m_address, "CommandCodesDownloadBlock: address" );
224     result &= se.write( m_numBytes, "CommandCodesDownloadBlock: number of bytes" );
225     return result;
226 }
227
228 bool
229 BeBoB::CommandCodesDownloadBlock::deserialize( IISDeserialize& de )
230 {
231     bool result = CommandCodes::deserialize( de );
232     result &= de.read( &m_resp_seqNumber );
233     result &= de.read( &m_resp_errorCode );
234
235     return result;
236 }
237
238 ////////////////////////////////
239
240 BeBoB::CommandCodesDownloadEnd::CommandCodesDownloadEnd(
241     fb_quadlet_t protocolVersion )
242     : CommandCodes( protocolVersion, eCmdC_DownloadEnd, 2, 0, 2 )
243 {
244 }
245
246 BeBoB::CommandCodesDownloadEnd::~CommandCodesDownloadEnd()
247 {
248 }
249
250 bool
251 BeBoB::CommandCodesDownloadEnd::serialize( IOSSerialize& se )
252 {
253     return CommandCodes::serialize( se );
254 }
255
256 bool
257 BeBoB::CommandCodesDownloadEnd::deserialize( IISDeserialize& de )
258 {
259     bool result = CommandCodes::deserialize( de );
260     result &= de.read( &m_resp_crc32 );
261     result &= de.read( &m_resp_valid );
262
263     return result;
264 }
265
266
267 ////////////////////////////////
268
269 BeBoB::CommandCodesInitializePersParam::CommandCodesInitializePersParam(
270     fb_quadlet_t protocolVersion )
271     : CommandCodes( protocolVersion, eCmdC_InitPersParams, 0, 0, 0 )
272 {
273 }
274
275 BeBoB::CommandCodesInitializePersParam::~CommandCodesInitializePersParam()
276 {
277 }
278
279 bool
280 BeBoB::CommandCodesInitializePersParam::serialize( IOSSerialize& se )
281 {
282     return CommandCodes::serialize( se );
283 }
284
285 bool
286 BeBoB::CommandCodesInitializePersParam::deserialize( IISDeserialize& de )
287 {
288     return CommandCodes::deserialize( de );
289 }
290
291 ////////////////////////////////
292
293 BeBoB::CommandCodesInitializeConfigToFactorySetting::CommandCodesInitializeConfigToFactorySetting(
294     fb_quadlet_t protocolVersion )
295     : CommandCodes( protocolVersion, eCmdC_InitConfigToFactorySetting, 0, 0, 0 )
296 {
297 }
298
299 BeBoB::CommandCodesInitializeConfigToFactorySetting::~CommandCodesInitializeConfigToFactorySetting()
300 {
301 }
302
303 bool
304 BeBoB::CommandCodesInitializeConfigToFactorySetting::serialize( IOSSerialize& se )
305 {
306     return CommandCodes::serialize( se );
307 }
308
309 bool
310 BeBoB::CommandCodesInitializeConfigToFactorySetting::deserialize( IISDeserialize& de )
311 {
312     return CommandCodes::deserialize( de );
313 }
314
315 ////////////////////////////////
316
317 BeBoB::CommandCodesGo::CommandCodesGo( fb_quadlet_t protocolVersion,
318                                              EStartMode startMode )
319     : CommandCodes( protocolVersion, eCmdC_Go, sizeof( m_startMode ), 1, 1 )
320     , m_startMode( startMode )
321 {
322 }
323
324 BeBoB::CommandCodesGo::~CommandCodesGo()
325 {
326 }
327
328 bool
329 BeBoB::CommandCodesGo::serialize( IOSSerialize& se )
330 {
331     bool result = CommandCodes::serialize( se );
332     result &= se.write( m_startMode, "CommandCodesGo: start mode" );
333
334     return result;
335 }
336
337 bool
338 BeBoB::CommandCodesGo::deserialize( IISDeserialize& de )
339 {
340     bool result = CommandCodes::deserialize( de );
341     result &= de.read( &m_resp_validCRC );
342
343     return result;
344 }
Note: See TracBrowser for help on using the browser.