65 _LIT(KPdd, "euart"); |
67 _LIT(KPdd, "euart"); |
66 #endif |
68 #endif |
67 _LIT(KLdd, "ecomm"); |
69 _LIT(KLdd, "ecomm"); |
68 |
70 |
69 TPortConfig::TPortConfig() |
71 TPortConfig::TPortConfig() |
70 :iPdd(KNullDesC), iLdd(KNullDesC), iPort(-1), iRate(EBpsAutobaud) |
72 :iPdd(KNullDesC), iLdd(KNullDesC), iPort(-1), iRate(EBpsAutobaud), iDebug(EFalse) |
71 { |
73 { |
72 } |
74 } |
73 |
75 |
74 TInt CVtcBusDevCommConsole::ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig) |
76 TInt CVtcBusDevCommConsole::ReadConfig(const TDesC& aConfigDes, TPortConfig& aConfig) |
75 { |
77 { |
76 _LIT(KKeywordPdd, "pdd"); |
78 _LIT(KKeywordPdd, "pdd"); |
77 _LIT(KKeywordLdd, "ldd"); |
79 _LIT(KKeywordLdd, "ldd"); |
78 _LIT(KKeywordPort, "port"); |
80 _LIT(KKeywordPort, "port"); |
79 _LIT(KKeywordRate, "rate"); |
81 _LIT(KKeywordRate, "rate"); |
|
82 _LIT(KKeywordDebug, "debug"); |
80 |
83 |
81 TBool keywordFound(EFalse); |
84 TBool keywordFound(EFalse); |
82 TLex lex(aConfigDes); |
85 TLex lex(aConfigDes); |
83 while (!lex.Eos()) |
86 while (!lex.Eos()) |
84 { |
87 { |
143 void CVtcBusDevCommConsole::ConstructL(const TDesC& aTitle) |
151 void CVtcBusDevCommConsole::ConstructL(const TDesC& aTitle) |
144 { |
152 { |
145 TPortConfig portConfig; |
153 TPortConfig portConfig; |
146 User::LeaveIfError(ReadConfig(aTitle, portConfig)); |
154 User::LeaveIfError(ReadConfig(aTitle, portConfig)); |
147 if (portConfig.iPort < 0) User::Leave(KErrArgument); |
155 if (portConfig.iPort < 0) User::Leave(KErrArgument); |
|
156 |
|
157 if (portConfig.iDebug) SetDebug(ETrue); |
148 |
158 |
149 TPtrC pdd(portConfig.iPdd); |
159 TPtrC pdd(portConfig.iPdd); |
150 if (pdd.Length() == 0) pdd.Set(KPdd()); |
160 if (pdd.Length() == 0) pdd.Set(KPdd()); |
151 TPtrC ldd(portConfig.iLdd); |
161 TPtrC ldd(portConfig.iLdd); |
152 if (ldd.Length() == 0) ldd.Set(KLdd()); |
162 if (ldd.Length() == 0) ldd.Set(KLdd()); |
153 |
163 |
154 TInt err = User::LoadPhysicalDevice(pdd); |
164 TInt err = User::LoadPhysicalDevice(pdd); |
155 Message(EDebug, _L("Loading %S returned %d"), &pdd, err); |
165 Message(ErrOrDebug(err), _L("Loading PDD %S returned %d"), &pdd, err); |
156 if (err != KErrAlreadyExists && portConfig.iPdd.Length()) User::LeaveIfError(err); // Don't error if we failed to load the default PDD |
166 if (err != KErrAlreadyExists && portConfig.iPdd.Length()) User::LeaveIfError(err); // Don't error if we failed to load the default PDD |
157 |
167 |
158 err = User::LoadLogicalDevice(ldd); |
168 err = User::LoadLogicalDevice(ldd); |
159 Message(EDebug, _L("Loading %S returned %d"), &ldd, err); |
169 Message(ErrOrDebug(err), _L("Loading LDD %S returned %d"), &ldd, err); |
160 if (err != KErrAlreadyExists && portConfig.iLdd.Length()) User::LeaveIfError(err); // Don't error if we failed to load the default LDD |
170 if (err != KErrAlreadyExists && portConfig.iLdd.Length()) User::LeaveIfError(err); // Don't error if we failed to load the default LDD |
161 err = iComm.Open(portConfig.iPort); |
171 err = iComm.Open(portConfig.iPort); |
162 Message(EDebug, _L("Opening port %d returned %d"), portConfig.iPort, err); |
172 Message(ErrOrDebug(err), _L("Opening port %d returned %d"), portConfig.iPort, err); |
163 User::LeaveIfError(err); |
173 User::LeaveIfError(err); |
164 |
174 |
165 if (portConfig.iRate != EBpsAutobaud) |
175 if (portConfig.iRate != EBpsAutobaud) |
166 { |
176 { |
167 TCommConfig cfg; |
177 TCommConfig cfg; |
174 cfg().iFifo = EFifoEnable; |
184 cfg().iFifo = EFifoEnable; |
175 cfg().iSpecialRate = 0; |
185 cfg().iSpecialRate = 0; |
176 cfg().iTerminatorCount = 0; |
186 cfg().iTerminatorCount = 0; |
177 cfg().iSIREnable = ESIRDisable; |
187 cfg().iSIREnable = ESIRDisable; |
178 err = iComm.SetConfig(cfg); |
188 err = iComm.SetConfig(cfg); |
179 Message(EDebug, _L("RBusDevComm::SetConfig returned %d"), err); |
189 Message(ErrOrDebug(err), _L("RBusDevComm::SetConfig returned %d"), err); |
180 User::LeaveIfError(err); |
190 User::LeaveIfError(err); |
181 } |
191 } |
182 iComm.ResetBuffers(); |
192 iComm.ResetBuffers(); |
183 CVtcConsoleBase::ConstructL(aTitle); |
193 CVtcConsoleBase::ConstructL(aTitle); |
184 } |
194 } |