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

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

- introduce support framework for DICE and Metric Halo
- change probe/discovery code to make adding devices easier
- made conditional compilation effectively work.

./configure now has the following switches:

--enable-bebob build BeBoB support (default=yes)
--enable-motu build Motu support (default=no)
--enable-dice build DICE support (default=no)
--enable-metric-halo build Metric Halo support (note: completely useless)

(default=no)

--enable-rme build RME support (note: completely useless)

(default=no)

--enable-bounce build Bounce device support (default=no)
--enable-all-devices build support for all supported devices (default=no)

these now turn on/off compilation effectively.

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