author | Tom Sutcliffe <thomas.sutcliffe@accenture.com> |
Mon, 20 Sep 2010 15:37:51 +0100 | |
changeset 62 | 60f47003f4b1 |
parent 0 | 7f656887cf89 |
child 63 | 6a2083f7eeb8 |
permissions | -rw-r--r-- |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
1 |
// vtc_usb.cpp |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
2 |
// |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
3 |
// Copyright (c) 2008 - 2010 Accenture. All rights reserved. |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
4 |
// This component and the accompanying materials are made available |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
5 |
// under the terms of the "Eclipse Public License v1.0" |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
6 |
// which accompanies this distribution, and is available |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
7 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
8 |
// |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
9 |
// Initial Contributors: |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
10 |
// Accenture - Initial contribution |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
11 |
// |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
12 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
13 |
#include <e32std.h> |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
14 |
#include <fshell/consoleextensions.h> |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
15 |
#include "vtc_usb.h" |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
16 |
#include <usbclassuids.h> |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
17 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
18 |
EXPORT_C TAny* NewConsole() |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
19 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
20 |
return new CUsbConsole; |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
21 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
22 |
|
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
23 |
TUsbPortConfig::TUsbPortConfig() |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
24 |
:iPort(KNullDesC), iPersonality(-1) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
25 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
26 |
} |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
27 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
28 |
#define ErrOrDebug(err) (((err) < 0 && (err) != KErrAlreadyExists) ? EError : EDebug) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
29 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
30 |
|
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
31 |
//______________________________________________________________________________ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
32 |
// CUsbConsole |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
33 |
CUsbConsole::CUsbConsole() |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
34 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
35 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
36 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
37 |
CUsbConsole::~CUsbConsole() |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
38 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
39 |
iUsb.Close(); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
40 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
41 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
42 |
void CUsbConsole::ConstructL(const TDesC& aTitle) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
43 |
{ |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
44 |
TUsbPortConfig portConfig; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
45 |
User::LeaveIfError(ReadConfig(aTitle, portConfig)); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
46 |
|
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
47 |
User::LeaveIfError(iUsb.Connect()); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
48 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
49 |
TRequestStatus stat; |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
50 |
if (portConfig.iPersonality >= 0) |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
51 |
{ |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
52 |
iUsb.TryStart(portConfig.iPersonality, stat); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
53 |
User::WaitForRequest(stat); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
54 |
Message(ErrOrDebug(stat.Int()), _L("Starting USB personality %d returned %d"), portConfig.iPersonality, stat.Int()); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
55 |
} |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
56 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
57 |
// Wait for an enumeration that supports ACM (this is so that if the device defaulted to say mass storage and was then reconfigured to a personality with ACM, we wait for the ACM reconfiguration |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
58 |
TBool gotAcm = EFalse; |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
59 |
while (!gotAcm) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
60 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
61 |
TUsbDeviceState usbState; |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
62 |
User::LeaveIfError(iUsb.GetDeviceState(usbState)); |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
63 |
if (usbState & (EUsbDeviceStateConfigured|EUsbDeviceStatePowered)) // We should only need to check for EUsbDeviceStateConfigured, but some HW doesn't go to configured state if the cable is inserted before USB is started |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
64 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
65 |
// Check if we have ACM |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
66 |
TInt currentPersonality; |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
67 |
TInt err = iUsb.GetCurrentPersonalityId(currentPersonality); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
68 |
if (!err) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
69 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
70 |
err = iUsb.ClassSupported(currentPersonality, KECACMUid, gotAcm); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
71 |
} |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
72 |
_LIT(KGotIt, "Current USB personality has ACM, proceeding"); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
73 |
_LIT(KNotGotIt, "Current USB personality doesn't have ACM, waiting for re-enumeration"); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
74 |
if (gotAcm) Message(EInformation, KGotIt); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
75 |
else Message(EInformation, KNotGotIt); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
76 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
77 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
78 |
if (!gotAcm) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
79 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
80 |
// We're not enumerated, or we are but don't have ACM. So wait for a (re-)enumeration |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
81 |
_LIT(KWaitingForEnumeration, "Waiting for USB enumeration (please connect USB cable)"); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
82 |
Message(EInformation, KWaitingForEnumeration); |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
83 |
iUsb.DeviceStateNotification(EUsbDeviceStateConfigured|EUsbDeviceStatePowered, usbState, stat); |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
84 |
User::WaitForRequest(stat); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
85 |
if (stat.Int() != KErrNone) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
86 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
87 |
_LIT(KUsbError, "Error configuring USB: %d"); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
88 |
Message(EError, KUsbError, stat.Int()); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
89 |
User::Leave(stat.Int()); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
90 |
} |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
91 |
_LIT(KUsbEnumerated, "USB state changed to %d."); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
92 |
Message(EInformation, KUsbEnumerated, usbState); |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
93 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
94 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
95 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
96 |
// Run the preamble script, if we have one. Because iosrv is multithreaded this shouldn't cause a deadlock so long as we use a different console (in this case, nullcons) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
97 |
_LIT(KPreamble, "--console nullcons vt100usbcons_preamble"); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
98 |
RProcess preamble; |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
99 |
TInt err = preamble.Create(_L("fshell.exe"), KPreamble); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
100 |
if (err == KErrNone) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
101 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
102 |
preamble.Logon(stat); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
103 |
if (stat == KRequestPending) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
104 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
105 |
preamble.Resume(); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
106 |
User::WaitForRequest(stat); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
107 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
108 |
err = stat.Int(); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
109 |
preamble.Close(); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
110 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
111 |
|
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
112 |
if (err == KErrNone) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
113 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
114 |
Message(EInformation, _L("Preamble script ran ok")); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
115 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
116 |
else if (err != KErrNotFound) |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
117 |
{ |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
118 |
Message(EInformation, _L("Preamble script failed with %d"), err); |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
119 |
} |
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
120 |
|
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
121 |
Message(EInformation, _L("Opening %S"), &portConfig.iPort); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
122 |
CVtcSerialConsole::ConstructL(portConfig.iPort); |
0
7f656887cf89
First submission to Symbian Foundation staging server.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff
changeset
|
123 |
} |
62
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
124 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
125 |
TInt CUsbConsole::ReadConfig(const TDesC& aConfigDes, TUsbPortConfig& aConfig) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
126 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
127 |
_LIT(KKeywordPort, "port"); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
128 |
_LIT(KKeywordPersonality, "personality"); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
129 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
130 |
TBool keywordFound(EFalse); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
131 |
TLex lex(aConfigDes); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
132 |
while (!lex.Eos()) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
133 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
134 |
TPtrC keyword; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
135 |
TPtrC value; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
136 |
TInt err = ReadKeywordValuePair(lex, keyword, value); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
137 |
if (err != KErrNone) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
138 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
139 |
break; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
140 |
} |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
141 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
142 |
if (keyword == KKeywordPort) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
143 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
144 |
aConfig.iPort.Set(value); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
145 |
keywordFound = ETrue; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
146 |
} |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
147 |
else if (keyword == KKeywordPersonality) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
148 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
149 |
TLex lex(value); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
150 |
TInt err = lex.Val(aConfig.iPersonality); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
151 |
if (err) return err; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
152 |
keywordFound = ETrue; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
153 |
} |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
154 |
} |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
155 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
156 |
if (!keywordFound) |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
157 |
{ |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
158 |
// Treat unrecognised string as a port (to preserve backwards compatibility with earlier releases). |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
159 |
aConfig.iPort.Set(aConfigDes); |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
160 |
} |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
161 |
|
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
162 |
return KErrNone; |
60f47003f4b1
Fixed bridge USB config.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
0
diff
changeset
|
163 |
} |