34 |
34 |
35 _LIT( KHtiCfgPath, "\\" ); // root of drive |
35 _LIT( KHtiCfgPath, "\\" ); // root of drive |
36 _LIT( KHtiUsbSerialCommCfg, "HTIUsbSerialComm.cfg" ); |
36 _LIT( KHtiUsbSerialCommCfg, "HTIUsbSerialComm.cfg" ); |
37 _LIT8( KUsbPortNumber, "PortNumber" ); |
37 _LIT8( KUsbPortNumber, "PortNumber" ); |
38 _LIT8( KUsbDataRate, "DataRate" ); |
38 _LIT8( KUsbDataRate, "DataRate" ); |
|
39 _LIT8( KUsbRetryTimes, "RetryTimes" ); |
|
40 _LIT8( KUsbRetryInterval, "RetryInterval" ); |
39 |
41 |
40 // _LIT( KUsbPddName, "" ); |
42 // _LIT( KUsbPddName, "" ); |
41 _LIT( KUsbLddName, "EUSBC" ); |
43 _LIT( KUsbLddName, "EUSBC" ); |
42 _LIT( KUsbCsyName, "ECACM"); |
44 _LIT( KUsbCsyName, "ECACM"); |
43 |
45 |
304 |
306 |
305 // try to open the port |
307 // try to open the port |
306 err = iCommPort.Open( iCommServ, commPort, ECommExclusive, ECommRoleDTE ); |
308 err = iCommPort.Open( iCommServ, commPort, ECommExclusive, ECommRoleDTE ); |
307 if ( err ) |
309 if ( err ) |
308 { |
310 { |
309 HTI_LOG_FORMAT( "Failed to open port %d", err ); |
311 //read retry parameters from cfg |
310 ShowErrorNotifierL( _L( "Failed to open port" ), err ); |
312 TInt retryTimes = 10; |
|
313 TRAPD( paramRetryTimesErr, |
|
314 retryTimes = iCfg->GetParameterIntL( KUsbRetryTimes ) ); |
|
315 if ( paramRetryTimesErr != KErrNone ) |
|
316 { |
|
317 HTI_LOG_TEXT( "RetryTimes is not defined in cfg, using default" ); |
|
318 } |
|
319 HTI_LOG_FORMAT( " RetryTimes = %d", retryTimes ); |
|
320 |
|
321 TInt retryInterval = 10; |
|
322 TRAPD( paramRetryIntervalErr, |
|
323 retryInterval = iCfg->GetParameterIntL( KUsbRetryInterval ) ); |
|
324 if ( paramRetryIntervalErr != KErrNone ) |
|
325 { |
|
326 HTI_LOG_TEXT( "RetryInterval is not defined in cfg, using default" ); |
|
327 } |
|
328 HTI_LOG_FORMAT( " RetryInterval = %d(s)", retryInterval ); |
|
329 |
|
330 // retry to open the port |
|
331 for( TInt i=0; i<retryTimes; i++ ) |
|
332 { |
|
333 User::After( retryInterval * 1000000 ); |
|
334 err = iCommPort.Open( iCommServ, commPort, ECommExclusive, ECommRoleDTE ); |
|
335 if( !err ) |
|
336 { |
|
337 break; |
|
338 } |
|
339 } |
|
340 |
|
341 if( err ) |
|
342 { |
|
343 HTI_LOG_FORMAT( "Failed to open port %d", err ); |
|
344 ShowErrorNotifierL( _L( "Failed to open port" ), err ); |
|
345 } |
311 } |
346 } |
312 User::LeaveIfError( err ); |
347 User::LeaveIfError( err ); |
313 HTI_LOG_TEXT( "Port open - checking port capabilities" ); |
348 HTI_LOG_TEXT( "Port open - checking port capabilities" ); |
314 |
349 |
315 // check port data rate capability |
350 // check port data rate capability |