1 /* |
|
2 * Copyright (c) 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: ECOM plugin for serial communication over USB port |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <badesca.h> |
|
21 #include <f32file.h> |
|
22 |
|
23 #include "HtiUsbSerialCommEcomPlugin.h" |
|
24 #include <HtiCfg.h> |
|
25 #include <HtiLogging.h> |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 |
|
31 // CONSTANTS |
|
32 _LIT( KHtiUsbSerialError, "HtiUsbSerialError" ); |
|
33 _LIT( KHtiOkButton, "OK" ); |
|
34 |
|
35 _LIT( KHtiCfgPath, "\\" ); // root of drive |
|
36 _LIT( KHtiUsbSerialCommCfg, "HTIUsbSerialComm.cfg" ); |
|
37 _LIT8( KUsbPortNumber, "PortNumber" ); |
|
38 _LIT8( KUsbDataRate, "DataRate" ); |
|
39 _LIT8( KUsbRetryTimes, "RetryTimes" ); |
|
40 _LIT8( KUsbRetryInterval, "RetryInterval" ); |
|
41 |
|
42 // _LIT( KUsbPddName, "" ); |
|
43 _LIT( KUsbLddName, "EUSBC" ); |
|
44 _LIT( KUsbCsyName, "ECACM"); |
|
45 |
|
46 const TInt KDefaultUsbPort = 1; |
|
47 |
|
48 const static TUint KReceiveBufferLength = 4 * 1024; |
|
49 const static TUint KSendBufferLength = 4 * 1024; |
|
50 |
|
51 const static TInt KMaxHtiNotifierLength = 128; |
|
52 |
|
53 // MACROS |
|
54 |
|
55 // MODULE DATA STRUCTURES |
|
56 |
|
57 // LOCAL FUNCTION PROTOTYPES |
|
58 |
|
59 // FORWARD DECLARATIONS |
|
60 |
|
61 // ============================ MEMBER FUNCTIONS =============================== |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CHtiUsbSerialCommEcomPlugin::NewL |
|
65 // Two-phased constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 CHtiUsbSerialCommEcomPlugin* CHtiUsbSerialCommEcomPlugin::NewL() |
|
68 { |
|
69 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::NewL" ); |
|
70 CHtiUsbSerialCommEcomPlugin* plugin = |
|
71 new ( ELeave ) CHtiUsbSerialCommEcomPlugin(); |
|
72 CleanupStack::PushL( plugin ); |
|
73 plugin->ConstructL(); |
|
74 CleanupStack::Pop( plugin ); |
|
75 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::NewL" ); |
|
76 return plugin; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin |
|
81 // Destructor. |
|
82 // ----------------------------------------------------------------------------- |
|
83 CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin() |
|
84 { |
|
85 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin" ); |
|
86 iCommPort.Close(); |
|
87 iCommServ.Close(); |
|
88 delete iCfg; |
|
89 User::FreeLogicalDevice( KUsbLddName() ); |
|
90 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::~CHtiUsbSerialCommEcomPlugin" ); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CHtiUsbSerialCommEcomPlugin::CHtiUsbSerialCommEcomPlugin |
|
95 // C++ default constructor can NOT contain any code, that might leave. |
|
96 // ----------------------------------------------------------------------------- |
|
97 CHtiUsbSerialCommEcomPlugin::CHtiUsbSerialCommEcomPlugin() |
|
98 { |
|
99 // default port settings |
|
100 iPortNumber = KDefaultUsbPort; |
|
101 iDataRate = EBps115200; |
|
102 iParity = EParityNone; |
|
103 iDataBits = EData8; |
|
104 iStopBits = EStop1; |
|
105 iHandshake = 0; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CHtiUsbSerialCommEcomPlugin::ConstructL |
|
110 // Symbian 2nd phase constructor - can leave. |
|
111 // ----------------------------------------------------------------------------- |
|
112 void CHtiUsbSerialCommEcomPlugin::ConstructL() |
|
113 { |
|
114 TRAPD( err, LoadConfigL() ); |
|
115 if ( err == KErrNone ) |
|
116 { |
|
117 ReadConfig(); |
|
118 } |
|
119 InitCommServerL(); |
|
120 InitCommPortL(); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CHtiUsbSerialCommEcomPlugin::LoadConfigL |
|
125 // Loads the plugin configuration file from disk to iCfg. |
|
126 // ----------------------------------------------------------------------------- |
|
127 void CHtiUsbSerialCommEcomPlugin::LoadConfigL() |
|
128 { |
|
129 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::LoadConfigL" ); |
|
130 iCfg = CHtiCfg::NewL(); |
|
131 HTI_LOG_TEXT( "CHtiCfg constructed - loading cfg file" ); |
|
132 iCfg->LoadCfgL( KHtiCfgPath, KHtiUsbSerialCommCfg ); |
|
133 HTI_LOG_TEXT( "Cfg file loaded" ); |
|
134 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::LoadConfigL" ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CHtiUsbSerialCommEcomPlugin::ReadConfig |
|
139 // Reads the parameters from loaded configuration file. |
|
140 // ----------------------------------------------------------------------------- |
|
141 void CHtiUsbSerialCommEcomPlugin::ReadConfig() |
|
142 { |
|
143 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::ReadConfig" ); |
|
144 |
|
145 TInt portNumberCfg = 0; |
|
146 TRAPD( paramErr, |
|
147 portNumberCfg = iCfg->GetParameterIntL( KUsbPortNumber ) ); |
|
148 if ( paramErr != KErrNone ) |
|
149 { |
|
150 HTI_LOG_FORMAT( |
|
151 "PortNumber not defined in cfg, using default value %d", |
|
152 iPortNumber ); |
|
153 portNumberCfg = iPortNumber; |
|
154 } |
|
155 iPortNumber = portNumberCfg; |
|
156 |
|
157 TInt dataRateCfg = 0; |
|
158 TRAP( paramErr, dataRateCfg = iCfg->GetParameterIntL( KUsbDataRate ) ); |
|
159 if ( paramErr != KErrNone ) |
|
160 { |
|
161 HTI_LOG_TEXT( "DataRate not defined in cfg, using default" ); |
|
162 } |
|
163 else |
|
164 { |
|
165 switch ( dataRateCfg ) |
|
166 { |
|
167 case 2400: iDataRate = EBps2400; break; |
|
168 case 4800: iDataRate = EBps4800; break; |
|
169 case 9600: iDataRate = EBps9600; break; |
|
170 case 19200: iDataRate = EBps19200; break; |
|
171 case 38400: iDataRate = EBps38400; break; |
|
172 case 57600: iDataRate = EBps57600; break; |
|
173 case 115200: iDataRate = EBps115200; break; |
|
174 case 576000: iDataRate = EBps576000; break; |
|
175 case 1152000: iDataRate = EBps1152000; break; |
|
176 case 4000000: iDataRate = EBps4000000; break; |
|
177 default: |
|
178 HTI_LOG_FORMAT( |
|
179 "Unsupported DataRate %d defined - using default", |
|
180 dataRateCfg ); |
|
181 break; |
|
182 } |
|
183 } |
|
184 |
|
185 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::ReadConfig" ); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CHtiUsbSerialCommEcomPlugin::InitCommServerL |
|
190 // Starts the comm server, loads comms module and device drivers. |
|
191 // ----------------------------------------------------------------------------- |
|
192 void CHtiUsbSerialCommEcomPlugin::InitCommServerL() |
|
193 { |
|
194 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::InitCommServerL" ); |
|
195 |
|
196 TInt err = KErrNone; |
|
197 |
|
198 // start the comm server |
|
199 err = StartC32(); |
|
200 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
201 { |
|
202 ShowErrorNotifierL( _L( "Failed to start comm server" ), err ); |
|
203 User::Leave( err ); |
|
204 } |
|
205 |
|
206 // connect to RCommServ |
|
207 err = iCommServ.Connect(); |
|
208 if ( err != KErrNone ) |
|
209 { |
|
210 ShowErrorNotifierL( _L( "Failed to connect to comm server" ), err ); |
|
211 User::Leave( err ); |
|
212 } |
|
213 |
|
214 // load comms module (CSY file) |
|
215 err = iCommServ.LoadCommModule( KUsbCsyName() ); |
|
216 if ( err != KErrNone ) |
|
217 { |
|
218 ShowErrorNotifierL( _L( "Failed to load comms module" ), err ); |
|
219 User::Leave( err ); |
|
220 } |
|
221 |
|
222 /* USB PDD is usually a kernel extension so no need to load separately. |
|
223 // load physical device driver |
|
224 TInt err = User::LoadPhysicalDevice( KUsbPddName ); |
|
225 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
226 { |
|
227 ShowErrorNotifierL( _L( "Failed to load USB PDD" ), err ); |
|
228 User::Leave( err ); |
|
229 } |
|
230 */ |
|
231 |
|
232 // load logical device driver |
|
233 err = User::LoadLogicalDevice( KUsbLddName() ); |
|
234 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
235 { |
|
236 ShowErrorNotifierL( _L( "Failed to load USB LDD" ), err ); |
|
237 User::Leave( err ); |
|
238 } |
|
239 |
|
240 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::InitCommServerL" ); |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CHtiUsbSerialCommEcomPlugin::InitCommPortL |
|
245 // Checks that the comms module is valid and opens the port. |
|
246 // ----------------------------------------------------------------------------- |
|
247 void CHtiUsbSerialCommEcomPlugin::InitCommPortL() |
|
248 { |
|
249 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::InitCommPortL" ); |
|
250 |
|
251 TInt err = KErrNone; |
|
252 // check the number of loaded comms modules |
|
253 TInt commsCount = 0; |
|
254 err = iCommServ.NumPorts( commsCount ); |
|
255 if ( err != KErrNone || commsCount < 1 ) |
|
256 { |
|
257 if ( err != KErrNone ) |
|
258 { |
|
259 ShowErrorNotifierL( _L( "Failed to get comms module count" ), err ); |
|
260 User::Leave( err ); |
|
261 } |
|
262 else |
|
263 { |
|
264 ShowErrorNotifierL( _L( "No comms module loaded" ), KErrNotFound ); |
|
265 User::Leave( KErrNotFound ); |
|
266 } |
|
267 } |
|
268 |
|
269 HTI_LOG_FORMAT( "Found %d loaded comms modules", commsCount ); |
|
270 |
|
271 // get info about our loaded comms module |
|
272 TSerialInfo serialInfo; |
|
273 TBool found = EFalse; |
|
274 for ( TInt i = 0; i < commsCount && !found; i++ ) |
|
275 { |
|
276 TBuf<32> moduleName; |
|
277 err = iCommServ.GetPortInfo( i, moduleName, serialInfo ); |
|
278 if ( err != KErrNone ) |
|
279 { |
|
280 ShowErrorNotifierL( _L( "Failed to get port info" ), err ); |
|
281 User::Leave( err ); |
|
282 } |
|
283 HTI_LOG_FORMAT( "Found comms module %S", &moduleName ); |
|
284 HTI_LOG_FORMAT( "Comms module description: %S", |
|
285 &( serialInfo.iDescription ) ); |
|
286 if ( moduleName.CompareF( KUsbCsyName ) == 0 ) |
|
287 { |
|
288 found = ETrue; |
|
289 HTI_LOG_FORMAT( "Lowest port num = %d", serialInfo.iLowUnit ); |
|
290 HTI_LOG_FORMAT( "Highest port num = %d", serialInfo.iHighUnit ); |
|
291 } |
|
292 } |
|
293 |
|
294 if ( !found ) |
|
295 { |
|
296 ShowErrorNotifierL( _L( "Failed to get port info" ), KErrNotFound ); |
|
297 User::Leave( KErrNotFound ); |
|
298 } |
|
299 |
|
300 // create port name |
|
301 TBuf<KMaxPortName + 4> commPort; |
|
302 commPort.Append( serialInfo.iName ); |
|
303 commPort.AppendFill( ':', 2 ); |
|
304 commPort.AppendNum( iPortNumber ); |
|
305 HTI_LOG_FORMAT( "Opening port %S", &commPort ); |
|
306 |
|
307 // try to open the port |
|
308 err = iCommPort.Open( iCommServ, commPort, ECommExclusive, ECommRoleDTE ); |
|
309 if ( err ) |
|
310 { |
|
311 //read retry parameters from cfg |
|
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 } |
|
346 } |
|
347 User::LeaveIfError( err ); |
|
348 HTI_LOG_TEXT( "Port open - checking port capabilities" ); |
|
349 |
|
350 // check port data rate capability |
|
351 TCommCaps portCaps; |
|
352 iCommPort.Caps( portCaps ); |
|
353 HTI_LOG_TEXT( "Port capabilities:" ); |
|
354 HTI_LOG_FORMAT( " DataRate = %d", portCaps().iRate ); |
|
355 HTI_LOG_FORMAT( " Parity = %d", portCaps().iParity ); |
|
356 HTI_LOG_FORMAT( " DataBits = %d", portCaps().iDataBits ); |
|
357 HTI_LOG_FORMAT( " StopBits = %d", portCaps().iStopBits ); |
|
358 HTI_LOG_FORMAT( " Handshake = %d", portCaps().iHandshake ); |
|
359 HTI_LOG_FORMAT( " Signals = %d", portCaps().iSignals ); |
|
360 HTI_LOG_FORMAT( " Fifo = %d", portCaps().iFifo ); |
|
361 HTI_LOG_FORMAT( " SIR = %d", portCaps().iSIR ); |
|
362 |
|
363 TUint reqRateCapsBitmask = RateCapsBitmaskFromRate( iDataRate ); |
|
364 HTI_LOG_FORMAT( "Required data rate capability bitmask %d", |
|
365 reqRateCapsBitmask ); |
|
366 |
|
367 if ( reqRateCapsBitmask == 0 || |
|
368 ( reqRateCapsBitmask & portCaps().iRate ) == 0 ) |
|
369 { |
|
370 ShowErrorNotifierL( _L( "Unsupported data rate configured" ), |
|
371 KErrNotSupported ); |
|
372 User::Leave( KErrNotSupported ); |
|
373 } |
|
374 HTI_LOG_TEXT( "Data rate supported - setting port configuration" ); |
|
375 |
|
376 // set port configuration |
|
377 TCommConfig portSettings; |
|
378 iCommPort.Config( portSettings ); |
|
379 portSettings().iRate = iDataRate; |
|
380 portSettings().iParity = iParity; |
|
381 portSettings().iDataBits = iDataBits; |
|
382 portSettings().iStopBits = iStopBits; |
|
383 portSettings().iFifo = EFifoEnable; |
|
384 portSettings().iHandshake = iHandshake; |
|
385 |
|
386 err = iCommPort.SetConfig( portSettings ); |
|
387 if ( err ) |
|
388 { |
|
389 HTI_LOG_FORMAT( "Failed to set port settings %d", err ); |
|
390 ShowErrorNotifierL( _L( "Failed to set port settings" ), err ); |
|
391 User::Leave( err ); |
|
392 } |
|
393 |
|
394 iCommPort.SetReceiveBufferLength( KReceiveBufferLength ); |
|
395 |
|
396 HTI_LOG_TEXT( "Port open and configured" ); |
|
397 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::InitCommPortL" ); |
|
398 } |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // CHtiUsbSerialCommEcomPlugin::Receive |
|
402 // Receive data from comm port. |
|
403 // ----------------------------------------------------------------------------- |
|
404 void CHtiUsbSerialCommEcomPlugin::Receive( TDes8& aRawdataBuf, |
|
405 TRequestStatus& aStatus ) |
|
406 { |
|
407 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::Receive" ); |
|
408 HTI_LOG_FORMAT( "Buf max len: %d", aRawdataBuf.MaxLength() ); |
|
409 iCommPort.ReadOneOrMore( aStatus, aRawdataBuf ); |
|
410 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::Receive" ); |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CHtiUsbSerialCommEcomPlugin::Send |
|
415 // Write data to comm port. |
|
416 // ----------------------------------------------------------------------------- |
|
417 void CHtiUsbSerialCommEcomPlugin::Send( const TDesC8& aRawdataBuf, |
|
418 TRequestStatus& aStatus ) |
|
419 { |
|
420 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::Send" ); |
|
421 iCommPort.Write( aStatus, aRawdataBuf ); |
|
422 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::Send" ); |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CHtiUsbSerialCommEcomPlugin::CancelReceive |
|
427 // Cancel a pending read. |
|
428 // ----------------------------------------------------------------------------- |
|
429 void CHtiUsbSerialCommEcomPlugin::CancelReceive() |
|
430 { |
|
431 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::CancelReceive" ); |
|
432 iCommPort.ReadCancel(); |
|
433 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::CancelReceive" ); |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CHtiUsbSerialCommEcomPlugin::CancelSend |
|
438 // Cancel a pending write. |
|
439 // ----------------------------------------------------------------------------- |
|
440 void CHtiUsbSerialCommEcomPlugin::CancelSend() |
|
441 { |
|
442 HTI_LOG_FUNC_IN( "CHtiUsbSerialCommEcomPlugin::CancelSend" ); |
|
443 iCommPort.WriteCancel(); |
|
444 HTI_LOG_FUNC_OUT( "CHtiUsbSerialCommEcomPlugin::CancelSend" ); |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // CHtiUsbSerialCommEcomPlugin::GetSendBufferSize |
|
449 // ----------------------------------------------------------------------------- |
|
450 TInt CHtiUsbSerialCommEcomPlugin::GetSendBufferSize() |
|
451 { |
|
452 return KSendBufferLength; |
|
453 } |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // CHtiUsbSerialCommEcomPlugin::GetReceiveBufferSize |
|
457 // ----------------------------------------------------------------------------- |
|
458 TInt CHtiUsbSerialCommEcomPlugin::GetReceiveBufferSize() |
|
459 { |
|
460 return KReceiveBufferLength; |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CHtiUsbSerialCommEcomPlugin::RateCapsBitmaskFromRate |
|
465 // Converts a TBps enumeration value to a corresponding bitmask. |
|
466 // ----------------------------------------------------------------------------- |
|
467 TUint CHtiUsbSerialCommEcomPlugin::RateCapsBitmaskFromRate( TBps aDataRate ) |
|
468 { |
|
469 switch ( aDataRate ) |
|
470 { |
|
471 case EBps50: return KCapsBps50; |
|
472 case EBps75: return KCapsBps75; |
|
473 case EBps110: return KCapsBps110; |
|
474 case EBps134: return KCapsBps134; |
|
475 case EBps150: return KCapsBps150; |
|
476 case EBps300: return KCapsBps300; |
|
477 case EBps600: return KCapsBps600; |
|
478 case EBps1200: return KCapsBps1200; |
|
479 case EBps1800: return KCapsBps1800; |
|
480 case EBps2000: return KCapsBps2000; |
|
481 case EBps2400: return KCapsBps2400; |
|
482 case EBps3600: return KCapsBps3600; |
|
483 case EBps4800: return KCapsBps4800; |
|
484 case EBps7200: return KCapsBps7200; |
|
485 case EBps9600: return KCapsBps9600; |
|
486 case EBps19200: return KCapsBps19200; |
|
487 case EBps38400: return KCapsBps38400; |
|
488 case EBps57600: return KCapsBps57600; |
|
489 case EBps115200: return KCapsBps115200; |
|
490 case EBps230400: return KCapsBps230400; |
|
491 case EBps460800: return KCapsBps460800; |
|
492 case EBps576000: return KCapsBps576000; |
|
493 case EBps1152000: return KCapsBps1152000; |
|
494 case EBps4000000: return KCapsBps4000000; |
|
495 default: return 0; |
|
496 } |
|
497 } |
|
498 |
|
499 // ----------------------------------------------------------------------------- |
|
500 // CHtiUsbSerialCommEcomPlugin::ShowErrorNotifierL |
|
501 // Shows an error notifier dialog with text and error code. |
|
502 // ----------------------------------------------------------------------------- |
|
503 void CHtiUsbSerialCommEcomPlugin::ShowErrorNotifierL( const TDesC& aText, |
|
504 TInt aErr ) |
|
505 { |
|
506 RNotifier notifier; |
|
507 User::LeaveIfError( notifier.Connect() ); |
|
508 |
|
509 TBuf<KMaxHtiNotifierLength> errorMsg; |
|
510 // aText is cut if it's too long - leaving some space also for error code |
|
511 errorMsg.Append( aText.Left( errorMsg.MaxLength() - 10 ) ); |
|
512 errorMsg.Append( _L("\n") ); |
|
513 errorMsg.AppendNum( aErr ); |
|
514 |
|
515 TRequestStatus status; |
|
516 TInt button; |
|
517 notifier.Notify( KHtiUsbSerialError, errorMsg, |
|
518 KHtiOkButton, KNullDesC, button, status ); |
|
519 User::WaitForRequest( status ); |
|
520 notifier.Close(); |
|
521 } |
|
522 |
|
523 |
|
524 // End of file |
|