|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "RegistrationPort.h" |
|
19 #include "AcmConstants.h" |
|
20 #include "AcmUtils.h" |
|
21 #include <usb/acmserver.h> |
|
22 #include "acmcontroller.h" |
|
23 #include <usb/usblogger.h> |
|
24 #include "acmserverconsts.h" |
|
25 |
|
26 #ifdef __FLOG_ACTIVE |
|
27 _LIT8(KLogComponent, "ECACM"); |
|
28 #endif |
|
29 |
|
30 CRegistrationPort* CRegistrationPort::NewL(MAcmController& aAcmController, |
|
31 TUint aUnit) |
|
32 /** |
|
33 * Factory function. |
|
34 * |
|
35 * @param aOwner Observer (the port factory). |
|
36 * @param aUnit The port number. |
|
37 * @return Ownership of a newly created CRegistrationPort object |
|
38 */ |
|
39 { |
|
40 LOG_STATIC_FUNC_ENTRY |
|
41 |
|
42 CRegistrationPort* self = new(ELeave) CRegistrationPort(aAcmController); |
|
43 CleanupClosePushL(*self); |
|
44 self->ConstructL(aUnit); |
|
45 CleanupStack::Pop(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 void CRegistrationPort::ConstructL(TUint aUnit) |
|
50 /** |
|
51 * 2nd-phase constructor. |
|
52 * |
|
53 * @param aUnit The port number. |
|
54 */ |
|
55 { |
|
56 LOG_FUNC |
|
57 |
|
58 TName name; |
|
59 name.Num(aUnit); |
|
60 LEAVEIFERRORL(SetName(&name)); |
|
61 } |
|
62 |
|
63 CRegistrationPort::CRegistrationPort(MAcmController& aAcmController) |
|
64 /** |
|
65 * Constructor. |
|
66 * |
|
67 * @param aAcmController To use when creating and destroying ACM functions. |
|
68 */ |
|
69 : iAcmController(aAcmController) |
|
70 { |
|
71 } |
|
72 |
|
73 void CRegistrationPort::StartRead(const TAny* /*aClientBuffer*/, |
|
74 TInt /*aLength*/) |
|
75 /** |
|
76 * Queue a read |
|
77 * |
|
78 * @param aClientBuffer pointer to the Client's buffer |
|
79 * @param aLength number of bytes to read |
|
80 */ |
|
81 { |
|
82 LOG_FUNC |
|
83 |
|
84 ReadCompleted(KErrNotSupported); |
|
85 } |
|
86 |
|
87 void CRegistrationPort::ReadCancel() |
|
88 /** |
|
89 * Cancel a read |
|
90 */ |
|
91 { |
|
92 LOG_FUNC |
|
93 |
|
94 ReadCompleted(KErrNotSupported); |
|
95 } |
|
96 |
|
97 |
|
98 TInt CRegistrationPort::QueryReceiveBuffer(TInt& /*aLength*/) const |
|
99 /** |
|
100 * Get the size of the receive buffer |
|
101 * |
|
102 * @param aLength reference to where the size will be written to |
|
103 * @return KErrNotSupported always. |
|
104 */ |
|
105 { |
|
106 LOG_FUNC |
|
107 |
|
108 return KErrNotSupported; |
|
109 } |
|
110 |
|
111 void CRegistrationPort::ResetBuffers(TUint) |
|
112 /** |
|
113 * Reset Tx and Rx buffers. |
|
114 * Not supported. |
|
115 */ |
|
116 { |
|
117 LOG_FUNC |
|
118 } |
|
119 |
|
120 void CRegistrationPort::StartWrite(const TAny* /*aClientBuffer*/, |
|
121 TInt /*aLength*/) |
|
122 /** |
|
123 * Queue a write |
|
124 * |
|
125 * @param aClientBuffer pointer to the Client's buffer |
|
126 * @param aLength number of bytes to write |
|
127 */ |
|
128 { |
|
129 LOG_FUNC |
|
130 |
|
131 WriteCompleted(KErrNotSupported); |
|
132 } |
|
133 |
|
134 void CRegistrationPort::WriteCancel() |
|
135 /** |
|
136 * Cancel a pending write |
|
137 */ |
|
138 { |
|
139 LOG_FUNC |
|
140 |
|
141 WriteCompleted(KErrNotSupported); |
|
142 } |
|
143 |
|
144 void CRegistrationPort::Break(TInt /*aTime*/) |
|
145 /** |
|
146 * Send a break signal to the host. |
|
147 * |
|
148 * @param aTime Length of break in microseconds |
|
149 */ |
|
150 { |
|
151 LOG_FUNC |
|
152 |
|
153 BreakCompleted(KErrNotSupported); |
|
154 } |
|
155 |
|
156 void CRegistrationPort::BreakCancel() |
|
157 /** |
|
158 * Cancel a pending break. |
|
159 */ |
|
160 { |
|
161 LOG_FUNC |
|
162 } |
|
163 |
|
164 TInt CRegistrationPort::GetConfig(TDes8& /*aDes*/) const |
|
165 /** |
|
166 * Pass a config request |
|
167 * |
|
168 * @param aDes config will be written to this descriptor |
|
169 * @return Error |
|
170 */ |
|
171 { |
|
172 LOG_FUNC |
|
173 |
|
174 return KErrNotSupported; |
|
175 } |
|
176 |
|
177 TInt CRegistrationPort::SetConfig(const TDesC8& /*aDes*/) |
|
178 /** |
|
179 * Set up the comm port. |
|
180 * |
|
181 * @param aDes descriptor containing the new config |
|
182 * @return Error |
|
183 */ |
|
184 { |
|
185 LOG_FUNC |
|
186 |
|
187 return KErrNotSupported; |
|
188 } |
|
189 |
|
190 TInt CRegistrationPort::SetServerConfig(const TDesC8& /*aDes*/) |
|
191 /** |
|
192 * Set the server config. |
|
193 * |
|
194 * @param aDes package with new server configurations |
|
195 * @return Error |
|
196 */ |
|
197 { |
|
198 LOG_FUNC |
|
199 |
|
200 return KErrNotSupported; |
|
201 } |
|
202 |
|
203 TInt CRegistrationPort::GetServerConfig(TDes8& /*aDes*/) |
|
204 /** |
|
205 * Get the server configs |
|
206 * |
|
207 * @param aDes server configs will be written to this descriptor |
|
208 * @return Error |
|
209 */ |
|
210 { |
|
211 LOG_FUNC |
|
212 |
|
213 return KErrNotSupported; |
|
214 } |
|
215 |
|
216 TInt CRegistrationPort::GetCaps(TDes8& /*aDes*/) |
|
217 /** |
|
218 * Read capabilities from the driver |
|
219 * |
|
220 * @param aDes caps will be written to this descriptor |
|
221 * @return Error |
|
222 */ |
|
223 { |
|
224 LOG_FUNC |
|
225 |
|
226 return KErrNotSupported; |
|
227 } |
|
228 |
|
229 TInt CRegistrationPort::GetSignals(TUint& /*aSignals*/) |
|
230 /** |
|
231 * Get the status of the signal pins |
|
232 * |
|
233 * @param aSignals signals will be written to this descriptor |
|
234 * @return Error |
|
235 */ |
|
236 { |
|
237 LOG_FUNC |
|
238 |
|
239 return KErrNotSupported; |
|
240 } |
|
241 |
|
242 TInt CRegistrationPort::SetSignalsToMark(TUint aAcmField) |
|
243 /** |
|
244 * Set selected signals to high (logical 1). |
|
245 * |
|
246 * Used in the registration port as an API to create aNoAcms ACM interfaces. |
|
247 * This method of creating interfaces is deprecated, use the ACM Server instead. |
|
248 * |
|
249 * @param aAcmField Low 2 bytes- number of ACM interfaces to create. High 2 |
|
250 * bytes- protocol number (from USBCDC 1.1 Table 17). |
|
251 * @return Error |
|
252 */ |
|
253 { |
|
254 LOGTEXT2(_L8(">>CRegistrationPort::SetSignalsToMark aAcmField = 0x%x"), aAcmField); |
|
255 |
|
256 // Extract number of interfaces and protocol number |
|
257 // low 2 bytes represent the number of ACMs |
|
258 // high 2 bytes represent the protocol number to use |
|
259 TUint interfaces = aAcmField & 0x0000FFFF; |
|
260 TUint8 protocolNumber = (aAcmField & 0xFFFF0000) >> 16; |
|
261 |
|
262 // If there is no protocol number, assume the default |
|
263 // i.e. the client is not using this interface to set the protocol number |
|
264 // NOTE: This means you cannot set a protocol number of 0 - to do this use the ACM Server. |
|
265 protocolNumber = protocolNumber ? protocolNumber : KDefaultAcmProtocolNum; |
|
266 |
|
267 TInt ret = iAcmController.CreateFunctions(interfaces, protocolNumber, KControlIfcName, KDataIfcName); |
|
268 |
|
269 LOGTEXT2(_L8("<<CRegistrationPort::SetSignalsToMark ret = %d"), ret); |
|
270 return ret; |
|
271 } |
|
272 |
|
273 TInt CRegistrationPort::SetSignalsToSpace(TUint aNoAcms) |
|
274 /** |
|
275 * Set selected signals to low (logical 0) |
|
276 * |
|
277 * Used in the registration port as an API to destroy aNoAcms ACM interfaces. |
|
278 * This method of destroying interfaces is depricated, use the ACM Server instead. |
|
279 * |
|
280 * @param aNoAcms Number of ACM interfaces to destroy. |
|
281 * @return Error |
|
282 */ |
|
283 { |
|
284 LOGTEXT2(_L8(">>CRegistrationPort::SetSignalsToSpace aNoAcms = %d"), aNoAcms); |
|
285 |
|
286 iAcmController.DestroyFunctions(aNoAcms); |
|
287 |
|
288 LOGTEXT(_L8("<<CRegistrationPort::SetSignalsToSpace ret = KErrNone")); |
|
289 return KErrNone; |
|
290 } |
|
291 |
|
292 TInt CRegistrationPort::GetReceiveBufferLength(TInt& /*aLength*/) const |
|
293 /** |
|
294 * Get size of Tx and Rx buffer |
|
295 * |
|
296 * @param aLength reference to where the length will be written to |
|
297 * @return Error |
|
298 */ |
|
299 { |
|
300 LOG_FUNC |
|
301 |
|
302 return KErrNotSupported; |
|
303 } |
|
304 |
|
305 TInt CRegistrationPort::SetReceiveBufferLength(TInt /*aLength*/) |
|
306 /** |
|
307 * Set the size of Tx and Rx buffer |
|
308 * |
|
309 * @param aLength new length of Tx and Rx buffer |
|
310 * @return Error |
|
311 */ |
|
312 { |
|
313 LOG_FUNC |
|
314 |
|
315 return KErrNotSupported; |
|
316 } |
|
317 |
|
318 void CRegistrationPort::Destruct() |
|
319 /** |
|
320 * Destruct - we must (eventually) call delete this |
|
321 */ |
|
322 { |
|
323 LOG_FUNC |
|
324 |
|
325 delete this; |
|
326 } |
|
327 |
|
328 void CRegistrationPort::FreeMemory() |
|
329 /** |
|
330 * Attempt to reduce our memory foot print. |
|
331 */ |
|
332 { |
|
333 LOG_FUNC |
|
334 } |
|
335 |
|
336 void CRegistrationPort::NotifyDataAvailable() |
|
337 /** |
|
338 * Notify client when data is available |
|
339 */ |
|
340 { |
|
341 LOG_FUNC |
|
342 |
|
343 NotifyDataAvailableCompleted(KErrNotSupported); |
|
344 } |
|
345 |
|
346 void CRegistrationPort::NotifyDataAvailableCancel() |
|
347 /** |
|
348 * Cancel an outstanding data availalbe notification |
|
349 */ |
|
350 { |
|
351 LOG_FUNC |
|
352 |
|
353 NotifyDataAvailableCompleted(KErrNotSupported); |
|
354 } |
|
355 |
|
356 TInt CRegistrationPort::GetFlowControlStatus(TFlowControl& /*aFlowControl*/) |
|
357 /** |
|
358 * Get the flow control status |
|
359 * |
|
360 * @param aFlowControl flow control status will be written to this descriptor |
|
361 * @return Error |
|
362 */ |
|
363 { |
|
364 LOG_FUNC |
|
365 |
|
366 return KErrNotSupported; |
|
367 } |
|
368 |
|
369 void CRegistrationPort::NotifyOutputEmpty() |
|
370 /** |
|
371 * Notify the client when the output buffer is empty. |
|
372 */ |
|
373 { |
|
374 LOG_FUNC |
|
375 |
|
376 NotifyOutputEmptyCompleted(KErrNotSupported); |
|
377 } |
|
378 |
|
379 void CRegistrationPort::NotifyOutputEmptyCancel() |
|
380 /** |
|
381 * Cancel a pending request to be notified when the output buffer is empty. |
|
382 */ |
|
383 { |
|
384 LOG_FUNC |
|
385 |
|
386 NotifyOutputEmptyCompleted(KErrNotSupported); |
|
387 } |
|
388 |
|
389 void CRegistrationPort::NotifyBreak() |
|
390 /** |
|
391 * Notify a client of a break on the serial line. |
|
392 */ |
|
393 { |
|
394 LOG_FUNC |
|
395 |
|
396 BreakNotifyCompleted(KErrNotSupported); |
|
397 } |
|
398 |
|
399 void CRegistrationPort::NotifyBreakCancel() |
|
400 /** |
|
401 * Cancel a pending notification of a serial line break. |
|
402 */ |
|
403 { |
|
404 LOG_FUNC |
|
405 |
|
406 BreakNotifyCompleted(KErrNotSupported); |
|
407 } |
|
408 |
|
409 void CRegistrationPort::NotifyFlowControlChange() |
|
410 /** |
|
411 * Notify a client of a change in the flow control state. |
|
412 */ |
|
413 { |
|
414 LOG_FUNC |
|
415 |
|
416 FlowControlChangeCompleted(EFlowControlOn,KErrNotSupported); |
|
417 } |
|
418 |
|
419 void CRegistrationPort::NotifyFlowControlChangeCancel() |
|
420 /** |
|
421 * Cancel a pending request to be notified when the flow control state changes. |
|
422 */ |
|
423 { |
|
424 LOG_FUNC |
|
425 |
|
426 FlowControlChangeCompleted(EFlowControlOn,KErrNotSupported); |
|
427 } |
|
428 |
|
429 void CRegistrationPort::NotifyConfigChange() |
|
430 /** |
|
431 * Notify a client of a change to the serial port configuration. |
|
432 */ |
|
433 { |
|
434 LOG_FUNC |
|
435 |
|
436 ConfigChangeCompleted(KNullDesC8, KErrNotSupported); |
|
437 } |
|
438 |
|
439 void CRegistrationPort::NotifyConfigChangeCancel() |
|
440 /** |
|
441 * Cancel a pending request to be notified of a change to the serial port |
|
442 * configuration. |
|
443 */ |
|
444 { |
|
445 LOG_FUNC |
|
446 |
|
447 ConfigChangeCompleted(KNullDesC8, KErrNotSupported); |
|
448 } |
|
449 |
|
450 void CRegistrationPort::NotifySignalChange(TUint /*aSignalMask*/) |
|
451 /** |
|
452 * Notify a client of a change to the signal lines. |
|
453 */ |
|
454 { |
|
455 LOG_FUNC |
|
456 |
|
457 SignalChangeCompleted(0, KErrNotSupported); |
|
458 } |
|
459 |
|
460 void CRegistrationPort::NotifySignalChangeCancel() |
|
461 /** |
|
462 * Cancel a pending client request to be notified about a change to the signal |
|
463 * lines. |
|
464 */ |
|
465 { |
|
466 LOG_FUNC |
|
467 |
|
468 SignalChangeCompleted(0, KErrNotSupported); |
|
469 } |
|
470 |
|
471 TInt CRegistrationPort::GetRole(TCommRole& aRole) |
|
472 /** |
|
473 * Get the role of this port unit |
|
474 * |
|
475 * @param aRole reference to where the role will be written to |
|
476 * @return Error |
|
477 */ |
|
478 { |
|
479 LOG_FUNC |
|
480 aRole = iRole; |
|
481 LOGTEXT2(_L8("\trole=%d"), aRole); |
|
482 return KErrNone; |
|
483 } |
|
484 |
|
485 TInt CRegistrationPort::SetRole(TCommRole aRole) |
|
486 /** |
|
487 * Set the role of this port unit |
|
488 * |
|
489 * @param aRole the new role |
|
490 * @return Error |
|
491 */ |
|
492 { |
|
493 LOG_FUNC |
|
494 |
|
495 // This is required to keep C32 happy while opening the port. |
|
496 // All we do is store the role and return it if asked. |
|
497 // Note that this is needed for multiple ACM ports because C32 doesn't |
|
498 // check the return value for multiple ports so opening registration port |
|
499 // more than once will fail. |
|
500 iRole = aRole; |
|
501 return KErrNone; |
|
502 } |
|
503 |
|
504 CRegistrationPort::~CRegistrationPort() |
|
505 /** |
|
506 * Destructor. |
|
507 */ |
|
508 { |
|
509 LOG_FUNC |
|
510 } |
|
511 |
|
512 // |
|
513 // End of file |