158 * |
162 * |
159 * @param aStatus The caller's request status, filled in with an error code |
163 * @param aStatus The caller's request status, filled in with an error code |
160 */ |
164 */ |
161 void CUsbstub1ClassController::Start(TRequestStatus& aStatus) |
165 void CUsbstub1ClassController::Start(TRequestStatus& aStatus) |
162 { |
166 { |
163 LOG_FUNC |
167 OstTraceFunctionEntry0( CUSBSTUB1CLASSCONTROLLER_START_ENTRY ); |
164 |
168 |
165 aStatus = KRequestPending; |
169 aStatus = KRequestPending; |
166 iReportStatus = &aStatus; |
170 iReportStatus = &aStatus; |
167 //If we are already started then just complete the request. |
171 //If we are already started then just complete the request. |
168 if (iState == EUsbServiceStarted) |
172 if (iState == EUsbServiceStarted) |
169 { |
173 { |
170 User::RequestComplete(iReportStatus, KErrNone); |
174 User::RequestComplete(iReportStatus, KErrNone); |
|
175 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_START_EXIT ); |
171 return; |
176 return; |
172 } |
177 } |
173 |
178 |
174 if (iFailToStart) |
179 if (iFailToStart) |
175 { |
180 { |
176 User::RequestComplete(iReportStatus, KErrGeneral); |
181 User::RequestComplete(iReportStatus, KErrGeneral); |
|
182 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_START_EXIT_DUP1 ); |
177 return; |
183 return; |
178 } |
184 } |
179 |
185 |
180 iState = EUsbServiceStarting; |
186 iState = EUsbServiceStarting; |
181 #ifndef __WINS__ |
187 #ifndef __WINS__ |
182 TInt ret = iLdd.Open(0); |
188 TInt ret = iLdd.Open(0); |
183 LOGTEXT2(_L8("Open LDD, ret=%d"), ret); |
189 OstTrace1( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_START, _L8("Open LDD, ret=%d"), ret ); |
|
190 |
184 ret = SetUpInterface(); |
191 ret = SetUpInterface(); |
185 LOGTEXT2(_L8("SetUpInterface(), ret=%d"), ret); |
192 OstTrace1( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_START_DUP1, _L8("SetUpInterface(), ret=%d"), ret ); |
|
193 |
186 #endif |
194 #endif |
187 iTimer.After(iStatus, iStartDelay*1000); //convert from usec to msec |
195 iTimer.After(iStatus, iStartDelay*1000); //convert from usec to msec |
188 SetActive(); |
196 SetActive(); |
|
197 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_START_EXIT_DUP2 ); |
189 } |
198 } |
190 |
199 |
191 /** |
200 /** |
192 * Called by UsbMan when it wants to stop the USB stub1 class. |
201 * Called by UsbMan when it wants to stop the USB stub1 class. |
193 * |
202 * |
194 * @param aStatus The caller's request status: always set to KErrNone |
203 * @param aStatus The caller's request status: always set to KErrNone |
195 */ |
204 */ |
196 void CUsbstub1ClassController::Stop(TRequestStatus& aStatus) |
205 void CUsbstub1ClassController::Stop(TRequestStatus& aStatus) |
197 { |
206 { |
198 LOG_FUNC |
207 OstTraceFunctionEntry0( CUSBSTUB1CLASSCONTROLLER_STOP_ENTRY ); |
199 |
208 |
200 aStatus = KRequestPending; |
209 aStatus = KRequestPending; |
201 iReportStatus = &aStatus; |
210 iReportStatus = &aStatus; |
202 //If we are already idle then just complete the request. |
211 //If we are already idle then just complete the request. |
203 if (iState == EUsbServiceIdle) |
212 if (iState == EUsbServiceIdle) |
204 { |
213 { |
205 User::RequestComplete(iReportStatus, KErrNone); |
214 User::RequestComplete(iReportStatus, KErrNone); |
|
215 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_STOP_EXIT ); |
206 return; |
216 return; |
207 } |
217 } |
208 |
218 |
209 if (iFailToStop) |
219 if (iFailToStop) |
210 { |
220 { |
211 User::RequestComplete(iReportStatus, KErrGeneral); |
221 User::RequestComplete(iReportStatus, KErrGeneral); |
|
222 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_STOP_EXIT_DUP1 ); |
212 return; |
223 return; |
213 } |
224 } |
214 |
225 |
215 iState = EUsbServiceStopping; |
226 iState = EUsbServiceStopping; |
216 |
227 |
218 iLdd.Close(); |
229 iLdd.Close(); |
219 #endif |
230 #endif |
220 |
231 |
221 iTimer.After(iStatus, iStopDelay*1000); //convert from usec to msec |
232 iTimer.After(iStatus, iStopDelay*1000); //convert from usec to msec |
222 SetActive(); |
233 SetActive(); |
|
234 OstTraceFunctionExit0( DUP2_CUSBSTUB1CLASSCONTROLLER_STOP_EXIT ); |
223 } |
235 } |
224 |
236 |
225 /** |
237 /** |
226 * Gets information about the descriptor which this class provides. |
238 * Gets information about the descriptor which this class provides. |
227 * |
239 * |
228 * @param aDescriptorInfo Descriptor info structure filled in by this function |
240 * @param aDescriptorInfo Descriptor info structure filled in by this function |
229 */ |
241 */ |
230 void CUsbstub1ClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const |
242 void CUsbstub1ClassController::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const |
231 { |
243 { |
232 LOG_FUNC |
244 OstTraceFunctionEntry0( CUSBSTUB1CLASSCONTROLLER_GETDESCRIPTORINFO_ENTRY ); |
233 |
245 |
234 aDescriptorInfo.iLength = Kstub1DescriptorLength; |
246 aDescriptorInfo.iLength = Kstub1DescriptorLength; |
235 aDescriptorInfo.iNumInterfaces = Kstub1NumberOfInterfacesPerstub1Function; |
247 aDescriptorInfo.iNumInterfaces = Kstub1NumberOfInterfacesPerstub1Function; |
|
248 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_GETDESCRIPTORINFO_EXIT ); |
236 } |
249 } |
237 |
250 |
238 |
251 |
239 /** |
252 /** |
240 * Standard active object RunL. |
253 * Standard active object RunL. |
241 */ |
254 */ |
242 void CUsbstub1ClassController::RunL() |
255 void CUsbstub1ClassController::RunL() |
243 { |
256 { |
244 LOG_FUNC |
257 OstTraceFunctionEntry0( CUSBSTUB1CLASSCONTROLLER_RUNL_ENTRY ); |
245 |
258 |
246 __ASSERT_DEBUG( iStatus == KErrNone, _USB_PANIC(Kstub1CcPanicCategory, EPanicUnexpectedStatus) ); |
259 if(iStatus != KErrNone) |
|
260 { |
|
261 OstTrace1( TRACE_FATAL, CUSBSTUB1CLASSCONTROLLER_RUNL, |
|
262 "CUsbstub1ClassController::RunL panic with error %d", |
|
263 EPanicUnexpectedState); |
|
264 __ASSERT_DEBUG(EFalse,User::Panic(Kstub1CcPanicCategory,EPanicUnexpectedStatus)); |
|
265 } |
247 switch (iState) |
266 switch (iState) |
248 { |
267 { |
249 case EUsbServiceStarting: |
268 case EUsbServiceStarting: |
250 iState = EUsbServiceStarted; |
269 iState = EUsbServiceStarted; |
251 break; |
270 break; |
252 case EUsbServiceStopping: |
271 case EUsbServiceStopping: |
253 iState = EUsbServiceIdle; |
272 iState = EUsbServiceIdle; |
254 break; |
273 break; |
255 default: |
274 default: |
256 _USB_PANIC(Kstub1CcPanicCategory, EPanicUnexpectedState); |
275 OstTrace1( TRACE_FATAL, CUSBSTUB1CLASSCONTROLLER_RUNL_DUP1, |
|
276 "CUsbstub1ClassController::RunL panic with error %d", |
|
277 EPanicUnexpectedState); |
|
278 User::Panic(Kstub1CcPanicCategory,EPanicUnexpectedStatus); |
257 } |
279 } |
258 *iReportStatus = KErrNone; |
280 *iReportStatus = KErrNone; |
259 User::RequestComplete(iReportStatus, iStatus.Int()); |
281 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
282 OstTraceFunctionExit0( CUSBSTUB1CLASSCONTROLLER_RUNL_EXIT ); |
260 } |
283 } |
261 |
284 |
262 /** |
285 /** |
263 * Standard active object cancellation function. Never called because this |
286 * Standard active object cancellation function. Never called because this |
264 * class has no asynchronous requests. |
287 * class has no asynchronous requests. |
292 * @param aError The error code (unused) |
317 * @param aError The error code (unused) |
293 * @return Always KErrNone to avoid an active scheduler panic |
318 * @return Always KErrNone to avoid an active scheduler panic |
294 */ |
319 */ |
295 TInt CUsbstub1ClassController::RunError(TInt /*aError*/) |
320 TInt CUsbstub1ClassController::RunError(TInt /*aError*/) |
296 { |
321 { |
297 __ASSERT_DEBUG( EFalse, _USB_PANIC(Kstub1CcPanicCategory, EUnusedFunction) ); |
322 OstTrace1( TRACE_FATAL, CUSBSTUB1CLASSCONTROLLER_RUNERROR, |
|
323 "CUsbstub1ClassController::RunError panic with error %d", EUnusedFunction); |
|
324 __ASSERT_DEBUG(EFalse,User::Panic(Kstub1CcPanicCategory,EPanicUnexpectedStatus)); |
298 return KErrNone; |
325 return KErrNone; |
299 } |
326 } |
300 |
327 |
301 TInt CUsbstub1ClassController::SetUpInterface() |
328 TInt CUsbstub1ClassController::SetUpInterface() |
302 /** |
329 /** |
303 * Set up the interface for use. This involves finding a "Interrupt IN" |
330 * Set up the interface for use. This involves finding a "Interrupt IN" |
304 * endpoint and, if found, configuring the interface. |
331 * endpoint and, if found, configuring the interface. |
305 */ |
332 */ |
306 { |
333 { |
307 LOGTEXT(_L8(">>CCdcControlInterface::SetUpInterface")); |
334 OstTrace0( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE, |
308 |
335 _L8(">>CCdcControlInterface::SetUpInterface")); |
|
336 |
309 TUsbDeviceCaps dCaps; |
337 TUsbDeviceCaps dCaps; |
310 TInt ret = iLdd.DeviceCaps(dCaps); |
338 TInt ret = iLdd.DeviceCaps(dCaps); |
311 LOGTEXT(_L8("\tchecking result of DeviceCaps")); |
339 OstTrace0( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP1, |
|
340 _L8("\tchecking result of DeviceCaps")); |
|
341 |
312 if ( ret ) |
342 if ( ret ) |
313 { |
343 { |
314 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret); |
344 OstTrace1( TRACE_ERROR, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP2, |
|
345 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret ); |
|
346 |
315 return ret; |
347 return ret; |
316 } |
348 } |
317 |
349 |
318 const TUint KRequiredNumberOfEndpoints = 1; // in addition to endpoint 0. |
350 const TUint KRequiredNumberOfEndpoints = 1; // in addition to endpoint 0. |
319 |
351 |
320 const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints); |
352 const TUint totalEndpoints = static_cast<TUint>(dCaps().iTotalEndpoints); |
321 LOGTEXT2(_L8("\tiTotalEndpoints = %d"), totalEndpoints); |
353 OstTrace1( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP3, |
|
354 _L8("\tiTotalEndpoints = %d"), totalEndpoints); |
|
355 |
322 if ( totalEndpoints < KRequiredNumberOfEndpoints ) |
356 if ( totalEndpoints < KRequiredNumberOfEndpoints ) |
323 { |
357 { |
324 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), |
358 OstTrace1( TRACE_ERROR, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP4, |
325 KErrGeneral); |
359 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), KErrGeneral ); |
|
360 |
326 return KErrGeneral; |
361 return KErrGeneral; |
327 } |
362 } |
328 |
363 |
329 // Endpoints |
364 // Endpoints |
330 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
365 TUsbcEndpointData data[KUsbcMaxEndpoints]; |
331 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
366 TPtr8 dataptr(reinterpret_cast<TUint8*>(data), sizeof(data), sizeof(data)); |
332 ret = iLdd.EndpointCaps(dataptr); |
367 ret = iLdd.EndpointCaps(dataptr); |
333 LOGTEXT(_L8("\tchecking result of EndpointCaps")); |
368 OstTrace0( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP5, |
|
369 _L8("\tchecking result of EndpointCaps")); |
|
370 |
334 if ( ret ) |
371 if ( ret ) |
335 { |
372 { |
336 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret); |
373 OstTrace1( TRACE_ERROR, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP6, |
|
374 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret ); |
|
375 |
337 return ret; |
376 return ret; |
338 } |
377 } |
339 |
378 |
340 // Set the active interface |
379 // Set the active interface |
341 TUsbcInterfaceInfoBuf ifc; |
380 TUsbcInterfaceInfoBuf ifc; |
342 TBool epFound = EFalse; |
381 TBool epFound = EFalse; |
343 for ( TUint i = 0 ; i < totalEndpoints ; i++ ) |
382 for ( TUint i = 0 ; i < totalEndpoints ; i++ ) |
344 { |
383 { |
345 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
384 const TUsbcEndpointCaps* caps = &data[i].iCaps; |
346 __ASSERT_DEBUG(caps,_USB_PANIC(Kstub1CcPanicCategory, EPanicUnexpectedStatus)); |
385 if(!caps) |
|
386 { |
|
387 OstTrace1( TRACE_FATAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP7, |
|
388 "CUsbstub1ClassController::SetUpInterface panic with error %d", EPanicUnexpectedStatus); |
|
389 __ASSERT_DEBUG(EFalse,User::Panic(Kstub1CcPanicCategory,EPanicUnexpectedStatus)); |
|
390 } |
347 |
391 |
348 if (data[i].iInUse) |
392 if (data[i].iInUse) |
349 { |
393 { |
350 continue; |
394 continue; |
351 } |
395 } |
383 // Codes taken from USBCDC 1.1. |
430 // Codes taken from USBCDC 1.1. |
384 ifc().iClass.iClassNum = 0x02; // Table 15- Communication Interface Class |
431 ifc().iClass.iClassNum = 0x02; // Table 15- Communication Interface Class |
385 ifc().iClass.iSubClassNum = 0x02; // Table 16- Abstract Control Model |
432 ifc().iClass.iSubClassNum = 0x02; // Table 16- Abstract Control Model |
386 ifc().iClass.iProtocolNum = 0x01; // Table 17- Hayes compatible |
433 ifc().iClass.iProtocolNum = 0x01; // Table 17- Hayes compatible |
387 |
434 |
388 LOGTEXT(_L8("\tabout to call SetInterface")); |
435 OstTrace0( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP10, |
|
436 _L8("\tabout to call SetInterface")); |
|
437 |
389 // Zero effectively indicates that alternate interfaces are not used. |
438 // Zero effectively indicates that alternate interfaces are not used. |
390 ret = iLdd.SetInterface(0, ifc); |
439 ret = iLdd.SetInterface(0, ifc); |
391 |
440 |
392 LOGTEXT2(_L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret); |
441 OstTrace1( TRACE_NORMAL, CUSBSTUB1CLASSCONTROLLER_SETUPINTERFACE_DUP11, |
|
442 _L8("<<CCdcControlInterface::SetUpInterface ret=%d"), ret ); |
|
443 |
393 return ret; |
444 return ret; |
394 } |
445 } |
395 |
446 |
396 // |
447 // |
397 // End of file |
448 // End of file |