0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 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 the License "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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "dpdef.h" // dataport definitions
|
|
22 |
#include <e32svr.h>
|
|
23 |
#include <e32std.h>
|
|
24 |
#include <e32uid.h> // epoc32 uids
|
|
25 |
|
|
26 |
#include <iscapi.h>
|
|
27 |
#include <iscnokiadefinitions.h>
|
|
28 |
|
|
29 |
#include "dpdataport.h" // dataport main and c32 interface
|
|
30 |
#include "dpstd.h" // fault codes etc.
|
|
31 |
#include "dpdatabuffer.h" // base class for rx and tx buffers
|
|
32 |
#include "dpdataconfig.h" // port configuration store
|
|
33 |
#include "dpflowctrl.h" // flow control handling
|
|
34 |
#include "dpmif.h" // message interface mif
|
|
35 |
#include "dpdte2tx.h" // moves data from client to tx buffer
|
|
36 |
#include "dptx2pn.h" // moves data from tx buffer to isaapi
|
|
37 |
#include "dppn2rx.h" // moves data from isaapi to rx buffer
|
|
38 |
#include "dprx2dte.h" // moves data from rx buffer to client
|
|
39 |
#include "dpcommpep.h" // comm pep interface. interaction with mif
|
|
40 |
#include "dpescdetect.h" // escape sequence detection
|
|
41 |
#include "dpbreak.h" // break signal handling
|
|
42 |
#include "dpparityhandler.h" // parity bit handling in 7-bit data mode
|
|
43 |
#include "dppif.h" // pipe interface pif
|
|
44 |
#include "dptermdetect.h" // terminal bytes detection
|
|
45 |
#include "pep_comm_types.h" // structures for isi-message interface
|
|
46 |
#include "dplog.h" // dataport logging
|
|
47 |
#include "osttracedefinitions.h"
|
|
48 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
49 |
#include "dpdataporttraces.h"
|
|
50 |
#endif
|
|
51 |
|
|
52 |
// LOCAL FUNCTION PROTOTYPES
|
|
53 |
static void CloseObject( TAny* aObject );
|
|
54 |
|
|
55 |
// ==================== LOCAL FUNCTIONS ====================
|
|
56 |
|
|
57 |
// ---------------------------------------------------------
|
|
58 |
// CloseObject Close an object from the cleanup stack
|
|
59 |
// Status : Proposal
|
|
60 |
// ---------------------------------------------------------
|
|
61 |
//
|
|
62 |
void CloseObject(
|
|
63 |
TAny* aObject )
|
|
64 |
{
|
|
65 |
OstTrace0( TRACE_NORMAL, LOCAL_CLOSEOBJECT, "CloseObject" );
|
|
66 |
( ( CObject* ) aObject )->Close();
|
|
67 |
}
|
|
68 |
|
|
69 |
// ================= MEMBER FUNCTIONS =======================
|
|
70 |
|
|
71 |
// ---------------------------------------------------------
|
|
72 |
// CDpDataPortFactory::CDpDataPortFactory
|
|
73 |
// C++ default constructor
|
|
74 |
// ---------------------------------------------------------
|
|
75 |
CDpDataPortFactory::CDpDataPortFactory()
|
|
76 |
{
|
|
77 |
OstTrace0( TRACE_NORMAL, CDPDATAPORTFACTORY_CDPDATAPORTFACTORY, "CDpDataPortFactory::CDpDataPortFactory" );
|
|
78 |
LOGM(" CDpDataPortFactory::CDpDataPortFactory");
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------
|
|
82 |
// CDpDataPortFactory::ConstructL
|
|
83 |
// Symbian 2nd phase constructor
|
|
84 |
// ---------------------------------------------------------
|
|
85 |
void CDpDataPortFactory::ConstructL()
|
|
86 |
{
|
|
87 |
OstTrace0( TRACE_NORMAL, CDPDATAPORTFACTORY_CONSTRUCTL, "CDpDataPortFactory::ConstructL" );
|
|
88 |
LOGM(" CDpDataPortFactory::ConstructL");
|
|
89 |
|
|
90 |
TName name( KDataPortModule ); // Used in RComm::Open()
|
|
91 |
SetNameL( &name );
|
|
92 |
|
|
93 |
//A version is defined by a set of three numbers
|
|
94 |
iVersion = TVersion( EMajorVersion, EMinorVersion, EBuild );
|
|
95 |
|
|
96 |
//Create a parity handler object
|
|
97 |
iParityHandler = new( ELeave ) CDpParityHandler();
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------
|
|
101 |
// CDpDataPortFactory::NewL
|
|
102 |
// Static constructor
|
|
103 |
// ---------------------------------------------------------
|
|
104 |
CDpDataPortFactory* CDpDataPortFactory::NewL()
|
|
105 |
{
|
|
106 |
OstTrace0( TRACE_NORMAL, CDPDATAPORTFACTORY_NEWL, "CDpDataPortFactory::NewL" );
|
|
107 |
LOGM("CDpDataPortFactory::NewL");
|
|
108 |
|
|
109 |
CDpDataPortFactory* self = new( ELeave ) CDpDataPortFactory;
|
|
110 |
|
|
111 |
TCleanupItem closePort( CloseObject, self );
|
|
112 |
CleanupStack::PushL( closePort );
|
|
113 |
self->ConstructL();
|
|
114 |
CleanupStack::Pop(); //closePort
|
|
115 |
|
|
116 |
return self;
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------
|
|
120 |
// CDpDataPortFactory::~CDpDataPortFactory
|
|
121 |
// Destructor
|
|
122 |
// ---------------------------------------------------------
|
|
123 |
CDpDataPortFactory::~CDpDataPortFactory()
|
|
124 |
{
|
|
125 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORTFACTORY_CDPDATAPORTFACTORY, "CDpDataPortFactory::~CDpDataPortFactory" );
|
|
126 |
LOGM(" CDpDataPortFactory::~CDpDataPortFactory");
|
|
127 |
|
|
128 |
if ( iParityHandler )
|
|
129 |
{
|
|
130 |
delete iParityHandler;
|
|
131 |
}
|
|
132 |
// no else
|
|
133 |
}
|
|
134 |
|
|
135 |
// ---------------------------------------------------------
|
|
136 |
// CDpDataPortFactory::NewPortL
|
|
137 |
// This method creates a new port. This function leaves with
|
|
138 |
// KErrNotSupported, if unit number is not between
|
|
139 |
// KDataPortCommLowUnit and KDataPortCommHighUnit.
|
|
140 |
// ---------------------------------------------------------
|
|
141 |
//
|
|
142 |
CPort* CDpDataPortFactory::NewPortL(
|
|
143 |
const TUint aUnit )
|
|
144 |
{
|
|
145 |
OstTrace0( TRACE_NORMAL, CDPDATAPORTFACTORY_NEWPORTL, "CDpDataPortFactory::NewPortL" );
|
|
146 |
OstTrace1( TRACE_NORMAL, DUP1_CDPDATAPORTFACTORY_NEWPORTL, "CDpDataPortFactory:: aUnit: %u", aUnit );
|
|
147 |
|
|
148 |
LOGM1("CDpDataPortFactory::NewPortL, unit: %d", aUnit );
|
|
149 |
|
|
150 |
__ASSERT_ALWAYS( KDataPortCommHighUnit >= aUnit,
|
|
151 |
User::Leave( KErrNotSupported ) );
|
|
152 |
|
|
153 |
//Create a CDpDataPort object
|
|
154 |
return reinterpret_cast<CPort *>(
|
|
155 |
CDpDataPort::NewL( aUnit, iParityHandler ) );
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------
|
|
159 |
// CDpDataPortFactory::Info
|
|
160 |
// This method fills in the supplied serial info structure.
|
|
161 |
// ---------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CDpDataPortFactory::Info(
|
|
164 |
TSerialInfo &aSerialInfo )
|
|
165 |
{
|
|
166 |
OstTrace0( TRACE_NORMAL, CDPDATAPORTFACTORY_INFO, "CDpDataPortFactory::Info" );
|
|
167 |
LOGM("CDpDataPortFactory::Info");
|
|
168 |
|
|
169 |
aSerialInfo.iDescription = KDataPortDescription;
|
|
170 |
aSerialInfo.iName = KDataPortModule;
|
|
171 |
aSerialInfo.iLowUnit = KDataPortCommLowUnit;
|
|
172 |
aSerialInfo.iHighUnit = KDataPortCommHighUnit;
|
|
173 |
}
|
|
174 |
|
|
175 |
// ---------------------------------------------------------
|
|
176 |
// CDpDataPortFactory::PortPlatSecCapability
|
|
177 |
// This method returns capabilities for requested port.
|
|
178 |
// ---------------------------------------------------------
|
|
179 |
//
|
|
180 |
TSecurityPolicy CDpDataPortFactory::PortPlatSecCapability(
|
|
181 |
TUint aPort ) const
|
|
182 |
{
|
|
183 |
OstTrace0( TRACE_NORMAL, CDPDATAPORTFACTORY_PORTPLATSECCAPABILITY, "CDpDataPortFactory::PortPlatSecCapability" );
|
|
184 |
OstTrace1( TRACE_NORMAL, DUP1_CDPDATAPORTFACTORY_PORTPLATSECCAPABILITY, "CDpDataPortFactory:: aPort: %u", aPort );
|
|
185 |
|
|
186 |
LOGM1("CDpDataPortFactory::PortPlatSecCapability - port %d",
|
|
187 |
aPort );
|
|
188 |
|
|
189 |
TSecurityPolicy csySecurityPolicy;
|
|
190 |
|
|
191 |
// Support for ports 0, 1, (2, 3,) 4, 5 & 6
|
|
192 |
switch ( aPort )
|
|
193 |
{
|
|
194 |
case KDpCsdPort:
|
|
195 |
{
|
|
196 |
csySecurityPolicy = TSecurityPolicy(
|
|
197 |
ECapabilityNetworkServices,
|
|
198 |
ECapabilityNetworkControl,
|
|
199 |
ECapabilityCommDD );
|
|
200 |
break;
|
|
201 |
}
|
|
202 |
case KDpDialUpPort:
|
|
203 |
{
|
|
204 |
csySecurityPolicy = TSecurityPolicy(
|
|
205 |
ECapabilityNetworkServices,
|
|
206 |
ECapabilityNetworkControl,
|
|
207 |
ECapabilityCommDD );
|
|
208 |
break;
|
|
209 |
}
|
|
210 |
case KDpPort4:
|
|
211 |
case KDpPort5:
|
|
212 |
case KDpPort6:
|
|
213 |
{
|
|
214 |
csySecurityPolicy = TSecurityPolicy(
|
|
215 |
ECapabilityNetworkServices,
|
|
216 |
ECapabilityNetworkControl,
|
|
217 |
ECapabilityCommDD );
|
|
218 |
break;
|
|
219 |
}
|
|
220 |
case KDpBtAccHfPort:
|
|
221 |
case KDpBtAccHsPort:
|
|
222 |
// These ports 2 and 3 are implemented in Dataport and ISA for BT
|
|
223 |
// handsfree and headset but they are in fact not used in S60 3.X ->
|
|
224 |
default:
|
|
225 |
{
|
|
226 |
csySecurityPolicy = TSecurityPolicy(
|
|
227 |
TSecurityPolicy::EAlwaysFail );
|
|
228 |
break;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
return csySecurityPolicy;
|
|
233 |
}
|
|
234 |
|
|
235 |
//===========================================================
|
|
236 |
|
|
237 |
// ================= MEMBER FUNCTIONS =======================
|
|
238 |
|
|
239 |
// ---------------------------------------------------------
|
|
240 |
// CDpDataPort::CDpDataPort
|
|
241 |
// C++ default constructor
|
|
242 |
// ---------------------------------------------------------
|
|
243 |
CDpDataPort::CDpDataPort(
|
|
244 |
CDpParityHandler* aParityHandler,
|
|
245 |
const TInt aUnit ) :
|
|
246 |
iRole( ECommRoleDTE ),
|
|
247 |
iUnit( aUnit ),
|
|
248 |
iParityHandler( aParityHandler )
|
|
249 |
{
|
|
250 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_CDPDATAPORT, "CDpDataPort::CDpDataPort" );
|
|
251 |
LOGM(" CDpDataPort::CDpDataPort");
|
|
252 |
}
|
|
253 |
|
|
254 |
// ---------------------------------------------------------
|
|
255 |
// CDpDataPort::NewL
|
|
256 |
// Static constructor
|
|
257 |
// ---------------------------------------------------------
|
|
258 |
CDpDataPort* CDpDataPort::NewL(
|
|
259 |
const TUint aUnit,
|
|
260 |
CDpParityHandler* aParityHandler )
|
|
261 |
{
|
|
262 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NEWL, "CDpDataPort::NewL" );
|
|
263 |
LOGM("CDpDataPort::NewL");
|
|
264 |
|
|
265 |
CDpDataPort *self = new( ELeave ) CDpDataPort( aParityHandler, aUnit );
|
|
266 |
TCleanupItem closePort( CloseObject, self );
|
|
267 |
CleanupStack::PushL( closePort );
|
|
268 |
|
|
269 |
// closePort is enough for cleaning purposes,
|
|
270 |
// because CPort::Close() calls Destruct()
|
|
271 |
self->InitL();
|
|
272 |
|
|
273 |
TName name;
|
|
274 |
_LIT( KUnitFormat, "%d" );
|
|
275 |
name.Format( KUnitFormat, aUnit );
|
|
276 |
self->SetName( &name );
|
|
277 |
|
|
278 |
CleanupStack::Pop(); //closePort
|
|
279 |
|
|
280 |
return self;
|
|
281 |
}
|
|
282 |
|
|
283 |
// ---------------------------------------------------------
|
|
284 |
// CDpDataPort::~CDpDataPort
|
|
285 |
// Destructor
|
|
286 |
// ---------------------------------------------------------
|
|
287 |
CDpDataPort::~CDpDataPort()
|
|
288 |
{
|
|
289 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_CDPDATAPORT, "CDpDataPort::~CDpDataPort" );
|
|
290 |
OstTrace1( TRACE_NORMAL, DUP2_CDPDATAPORT_CDPDATAPORT, "CDpDataPort:: Port: %u", iUnit );
|
|
291 |
|
|
292 |
LOGM1(" CDpDataPort::~CDpDataPort - Port %d", iUnit );
|
|
293 |
|
|
294 |
DeleteCommonObjects();
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------
|
|
298 |
// CDpDataPort::DeleteDataPort
|
|
299 |
// This method deletes DataPort
|
|
300 |
// ---------------------------------------------------------
|
|
301 |
//
|
|
302 |
void CDpDataPort::DeleteDataPort()
|
|
303 |
{
|
|
304 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DELETEDATAPORT, "CDpDataPort::DeleteDataPort" );
|
|
305 |
if ( this )
|
|
306 |
{
|
|
307 |
delete this;
|
|
308 |
}
|
|
309 |
//no else
|
|
310 |
}
|
|
311 |
|
|
312 |
// ---------------------------------------------------------
|
|
313 |
// CDpDataPort::IsReadyToDestruct
|
|
314 |
// This method finds out, whether DataPort is ready to be destructed.
|
|
315 |
// ---------------------------------------------------------
|
|
316 |
//
|
|
317 |
TBool CDpDataPort::IsReadyToDestruct()
|
|
318 |
{
|
|
319 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_ISREADYTODESTRUCT, "CDpDataPort::IsReadyToDestruct" );
|
|
320 |
return iReadyToDestruct;
|
|
321 |
}
|
|
322 |
|
|
323 |
// ---------------------------------------------------------
|
|
324 |
// CDpDataPort::DeleteCommonObjects
|
|
325 |
// This method deletes other objects and starts pipe
|
|
326 |
// termination. All operations are cancelled before
|
|
327 |
// deletion.
|
|
328 |
// ---------------------------------------------------------
|
|
329 |
//
|
|
330 |
void CDpDataPort::DeleteCommonObjects()
|
|
331 |
{
|
|
332 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DELETECOMMONOBJECTS, "CDpDataPort::DeleteCommonObjects" );
|
|
333 |
LOGM(" CDpDataPort::DeleteCommonObjects");
|
|
334 |
|
|
335 |
// Close the pipe only if it has not been closed before
|
|
336 |
if ( iPifDcs && !iReadyToDestruct )
|
|
337 |
{
|
|
338 |
TRAP_IGNORE( iPifDcs->ClosePipeL( iUnit ) );
|
|
339 |
}
|
|
340 |
//no else
|
|
341 |
|
|
342 |
// Cancel all operations
|
|
343 |
if ( iTx2Pn )
|
|
344 |
{
|
|
345 |
iTx2Pn->Cancel();
|
|
346 |
}
|
|
347 |
//no else
|
|
348 |
|
|
349 |
if ( iPn2Rx )
|
|
350 |
{
|
|
351 |
iPn2Rx->Cancel();
|
|
352 |
}
|
|
353 |
//no else
|
|
354 |
|
|
355 |
if ( iRx2Dte )
|
|
356 |
{
|
|
357 |
iRx2Dte->Cancel();
|
|
358 |
}
|
|
359 |
//no else
|
|
360 |
|
|
361 |
if ( iDte2Tx )
|
|
362 |
{
|
|
363 |
iDte2Tx->Cancel();
|
|
364 |
}
|
|
365 |
//no else
|
|
366 |
|
|
367 |
if ( iPifDcs )
|
|
368 |
{
|
|
369 |
iPifDcs->Cancel();
|
|
370 |
}
|
|
371 |
//no else
|
|
372 |
|
|
373 |
if ( iMif )
|
|
374 |
{
|
|
375 |
iMif->Cancel();
|
|
376 |
}
|
|
377 |
//no else
|
|
378 |
|
|
379 |
if ( iEscDetect )
|
|
380 |
{
|
|
381 |
iEscDetect->Cancel();
|
|
382 |
}
|
|
383 |
//no else
|
|
384 |
|
|
385 |
if ( iFlowCtrl )
|
|
386 |
{
|
|
387 |
iFlowCtrl->Cancel();
|
|
388 |
}
|
|
389 |
//no else
|
|
390 |
|
|
391 |
// Deallocate subjects before observers
|
|
392 |
|
|
393 |
if ( iISAHandle )
|
|
394 |
{
|
|
395 |
iISAHandle->Close();
|
|
396 |
}
|
|
397 |
//no else
|
|
398 |
|
|
399 |
if ( iDte2Tx )
|
|
400 |
{
|
|
401 |
delete iDte2Tx;
|
|
402 |
iDte2Tx = NULL;
|
|
403 |
}
|
|
404 |
//no else
|
|
405 |
|
|
406 |
if ( iTx2Pn )
|
|
407 |
{
|
|
408 |
delete iTx2Pn;
|
|
409 |
iTx2Pn = NULL;
|
|
410 |
}
|
|
411 |
//no else
|
|
412 |
|
|
413 |
if ( iPn2Rx )
|
|
414 |
{
|
|
415 |
delete iPn2Rx;
|
|
416 |
iPn2Rx = NULL;
|
|
417 |
}
|
|
418 |
//no else
|
|
419 |
|
|
420 |
if ( iPifDcs )
|
|
421 |
{
|
|
422 |
delete iPifDcs;
|
|
423 |
iPifDcs =NULL;
|
|
424 |
}
|
|
425 |
//no else
|
|
426 |
|
|
427 |
if ( iFlowCtrl )
|
|
428 |
{
|
|
429 |
delete iFlowCtrl;
|
|
430 |
iFlowCtrl = NULL;
|
|
431 |
}
|
|
432 |
//no else
|
|
433 |
|
|
434 |
if ( iMif )
|
|
435 |
{
|
|
436 |
delete iMif;
|
|
437 |
iMif = NULL;
|
|
438 |
}
|
|
439 |
//no else
|
|
440 |
|
|
441 |
if ( iRx2Dte )
|
|
442 |
{
|
|
443 |
delete iRx2Dte;
|
|
444 |
iRx2Dte = NULL;
|
|
445 |
}
|
|
446 |
//no else
|
|
447 |
|
|
448 |
if ( iDataConfig )
|
|
449 |
{
|
|
450 |
delete iDataConfig;
|
|
451 |
iDataConfig = NULL;
|
|
452 |
}
|
|
453 |
//no else
|
|
454 |
|
|
455 |
if ( iCommPep )
|
|
456 |
{
|
|
457 |
delete iCommPep;
|
|
458 |
iCommPep = NULL;
|
|
459 |
}
|
|
460 |
//no else
|
|
461 |
|
|
462 |
if ( iEscDetect )
|
|
463 |
{
|
|
464 |
delete iEscDetect;
|
|
465 |
iEscDetect = NULL;
|
|
466 |
}
|
|
467 |
//no else
|
|
468 |
|
|
469 |
if ( iTermDetect )
|
|
470 |
{
|
|
471 |
delete iTermDetect;
|
|
472 |
iTermDetect = NULL;
|
|
473 |
}
|
|
474 |
//no else
|
|
475 |
|
|
476 |
if ( iBreak )
|
|
477 |
{
|
|
478 |
delete iBreak;
|
|
479 |
iBreak = NULL;
|
|
480 |
}
|
|
481 |
//no else
|
|
482 |
|
|
483 |
if ( iRx )
|
|
484 |
{
|
|
485 |
delete iRx;
|
|
486 |
iRx = NULL;
|
|
487 |
}
|
|
488 |
//no else
|
|
489 |
|
|
490 |
if ( iTx )
|
|
491 |
{
|
|
492 |
delete iTx;
|
|
493 |
iTx = NULL;
|
|
494 |
}
|
|
495 |
//no else
|
|
496 |
|
|
497 |
if ( iISAHandle )
|
|
498 |
{
|
|
499 |
delete iISAHandle;
|
|
500 |
iISAHandle = NULL;
|
|
501 |
}
|
|
502 |
//no else
|
|
503 |
}
|
|
504 |
|
|
505 |
// ---------------------------------------------------------
|
|
506 |
// CDpDataPort::InitL
|
|
507 |
// This method opens Isc Api handle and creates other objects.
|
|
508 |
// Status : Proposal
|
|
509 |
// ---------------------------------------------------------
|
|
510 |
//
|
|
511 |
void CDpDataPort::InitL()
|
|
512 |
{
|
|
513 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_INITL, "CDpDataPort::InitL" );
|
|
514 |
#ifdef USE_FILE_SERIAL_TRUST_DEBUG // for debugging purposes
|
|
515 |
iDebugBytesFromDte = 0;
|
|
516 |
iDebugBytesToPn = 0;
|
|
517 |
iDebugBytesFromPn = 0;
|
|
518 |
iDebugBytesToDte = 0;
|
|
519 |
iDebugDteWrites = 0;
|
|
520 |
iDebugDteReads = 0;
|
|
521 |
iDebugPnWrites = 0;
|
|
522 |
iDebugPnReads = 0;
|
|
523 |
|
|
524 |
#ifdef USE_FILE_DEBUG
|
|
525 |
User::LeaveIfError( iFileServer.Connect( ) );
|
|
526 |
User::LeaveIfError(
|
|
527 |
iFile.Replace( iFileServer, KDataPortFileName, EFileWrite ) );
|
|
528 |
#endif // USE_FILE_DEBUG
|
|
529 |
#endif // USE_FILE_DEBUG || USE_SERIAL_DEBUG
|
|
530 |
|
|
531 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_INITL, "CDpDataPort:: *" );
|
|
532 |
OstTraceExt2( TRACE_NORMAL, DUP2_CDPDATAPORT_INITL, "CDpDataPort:: ************* New Port %u %x ***********", iUnit, (TUint)this );
|
|
533 |
|
|
534 |
LOGM(" CDpDataPort::InitL");
|
|
535 |
LOG("*");
|
|
536 |
LOG2("************* New Port %d %x ***********", iUnit, this );
|
|
537 |
|
|
538 |
// Pull IscApi Up
|
|
539 |
iISAHandle = new( ELeave ) RIscApi();
|
|
540 |
|
|
541 |
// Set object ID
|
|
542 |
TUint16 obj( 0 );
|
|
543 |
|
|
544 |
switch ( iUnit )
|
|
545 |
{
|
|
546 |
// port number that is opened by dataport
|
|
547 |
case KDpCsdPort:
|
|
548 |
{
|
|
549 |
obj = EIscNokiaDataport1;
|
|
550 |
break;
|
|
551 |
}
|
|
552 |
case KDpDialUpPort:
|
|
553 |
{
|
|
554 |
obj = EIscNokiaDataport2;
|
|
555 |
break;
|
|
556 |
}
|
|
557 |
|
|
558 |
case KDpBtAccHfPort:
|
|
559 |
case KDpBtAccHsPort:
|
|
560 |
{
|
|
561 |
obj = EIscNokiaBtAppl;
|
|
562 |
break;
|
|
563 |
}
|
|
564 |
case KDpPort4:
|
|
565 |
{
|
|
566 |
obj = EIscNokiaDataport3;
|
|
567 |
break;
|
|
568 |
}
|
|
569 |
case KDpPort5:
|
|
570 |
{
|
|
571 |
obj = EIscNokiaDataport4;
|
|
572 |
break;
|
|
573 |
}
|
|
574 |
case KDpPort6:
|
|
575 |
{
|
|
576 |
obj = EIscNokiaDataport5;
|
|
577 |
break;
|
|
578 |
}
|
|
579 |
default:
|
|
580 |
{
|
|
581 |
User::Leave( KErrGeneral );
|
|
582 |
break;
|
|
583 |
}
|
|
584 |
}
|
|
585 |
|
|
586 |
//Initialisation of the AO's status
|
|
587 |
TRequestStatus status( KRequestPending );
|
|
588 |
iISAHandle->Open( obj, status, EOwnerThread, NULL );
|
|
589 |
|
|
590 |
User::WaitForRequest( status );
|
|
591 |
User::LeaveIfError( status.Int() );
|
|
592 |
|
|
593 |
LOG(" CDpDataPort::InitL, iISCHandle opened");
|
|
594 |
OstTrace0( TRACE_NORMAL, DUP3_CDPDATAPORT_INITL, "CDpDataPort:: iISCHandle opened" );
|
|
595 |
|
|
596 |
// Create necessary serial objects.
|
|
597 |
CreateObjectsL();
|
|
598 |
}
|
|
599 |
|
|
600 |
// ---------------------------------------------------------
|
|
601 |
// CDpDataPort::InitializeObjVars()
|
|
602 |
// Initialize internal object variables that are not initialized.
|
|
603 |
// ---------------------------------------------------------
|
|
604 |
//
|
|
605 |
void CDpDataPort::InitializeObjVars()
|
|
606 |
{
|
|
607 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_INITIALIZEOBJVARS, "CDpDataPort::InitializeObjVars" );
|
|
608 |
LOGM(" CDpDataPort::InitializeObjVars, initialize objects variables");
|
|
609 |
|
|
610 |
iBreak->Init();
|
|
611 |
}
|
|
612 |
|
|
613 |
// ---------------------------------------------------------
|
|
614 |
// CDpDataPort::CreateObjectsL
|
|
615 |
// This function creates other objects, starts read from
|
|
616 |
// MIF and starts pipe initiation.
|
|
617 |
// ---------------------------------------------------------
|
|
618 |
//
|
|
619 |
void CDpDataPort::CreateObjectsL()
|
|
620 |
{
|
|
621 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_CREATEOBJECTSL, "CDpDataPort::CreateObjectsL" );
|
|
622 |
LOGM(" CDpDataPort::CreateObjectsL");
|
|
623 |
|
|
624 |
// Get maximum data size from ISC API
|
|
625 |
TInt maxDataSize( iISAHandle->MaximumDataSize() );
|
|
626 |
|
|
627 |
// Create RX buffer
|
|
628 |
iRx = CDpDataBuffer::NewL( maxDataSize, 4 * maxDataSize );
|
|
629 |
|
|
630 |
// Create TX buffer
|
|
631 |
iTx = CDpDataBuffer::NewL( maxDataSize, 4 * maxDataSize );
|
|
632 |
|
|
633 |
if ( KDpMaximumEchoDataSize < maxDataSize )
|
|
634 |
{
|
|
635 |
LOG(" CDpDataPort::CreateObjectsL KDpMaximumEchoDataSize < maxDataSize");
|
|
636 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_CREATEOBJECTSL, "CDpDataPort:: KDpMaximumEchoDataSize < maxDataSize" );
|
|
637 |
}
|
|
638 |
//no else
|
|
639 |
|
|
640 |
// Create Break handler
|
|
641 |
iBreak = new( ELeave ) CDpBreak( *this );
|
|
642 |
|
|
643 |
// Create pipe interface (PIF)
|
|
644 |
iPifDcs = new( ELeave ) CDpPif( *this );
|
|
645 |
|
|
646 |
// Create port configuration handler (DataConfig)
|
|
647 |
iDataConfig = CDpDataConfig::NewL( *this );
|
|
648 |
|
|
649 |
// Create flow control handler (FlowCtrl)
|
|
650 |
iFlowCtrl = new (ELeave) CDpFlowCtrl( *this );
|
|
651 |
|
|
652 |
// Create COMM PEP
|
|
653 |
iCommPep = new (ELeave) CDpCommPep( *this );
|
|
654 |
|
|
655 |
// Create message interface (MIF)
|
|
656 |
iMif = CDpMif::NewL( *this );
|
|
657 |
|
|
658 |
InitializeObjVars();
|
|
659 |
|
|
660 |
// Serious if read fails => leave
|
|
661 |
User::LeaveIfError( iMif->Read() );
|
|
662 |
|
|
663 |
// Start listening ISC Flow Control Changes
|
|
664 |
iFlowCtrl->RequestIscFlowControlNotification();
|
|
665 |
|
|
666 |
// Initiate pipe
|
|
667 |
User::LeaveIfError( iPifDcs->InitiatePipe( iUnit ) );
|
|
668 |
|
|
669 |
// Create escape sequence detector (EscDetect)
|
|
670 |
iEscDetect = new( ELeave ) CDpEscDetect( *this );
|
|
671 |
|
|
672 |
// Create termination characters detector (TermDetect)
|
|
673 |
iTermDetect = new( ELeave ) CDpTermDetect( *iDataConfig );
|
|
674 |
|
|
675 |
// Create Rx2Dte
|
|
676 |
iRx2Dte = CDpRx2Dte::NewL( *this );
|
|
677 |
|
|
678 |
// Create Dte2Tx
|
|
679 |
iDte2Tx = CDpDte2Tx::NewL( *this );
|
|
680 |
|
|
681 |
// Create Tx2Pn
|
|
682 |
iTx2Pn = CDpTx2Pn::NewL( *this );
|
|
683 |
|
|
684 |
// Create Pn2Rx
|
|
685 |
iPn2Rx = CDpPn2Rx::NewL( *this );
|
|
686 |
}
|
|
687 |
|
|
688 |
// ---------------------------------------------------------
|
|
689 |
// CDpDataPort::StartRead
|
|
690 |
// This method requests read.
|
|
691 |
// ---------------------------------------------------------
|
|
692 |
//
|
|
693 |
void CDpDataPort::StartRead(
|
|
694 |
const TAny* aClientBuffer,
|
|
695 |
TInt aLength )
|
|
696 |
{
|
|
697 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_STARTREAD, "CDpDataPort::StartRead" );
|
|
698 |
OstTraceExt2( TRACE_NORMAL, DUP1_CDPDATAPORT_STARTREAD, "CDpDataPort:: Port: %u, aLength: %d", iUnit, aLength );
|
|
699 |
|
|
700 |
LOGM2(" CDpDataPort::StartRead - Port %d, aLength = %d",
|
|
701 |
iUnit, aLength );
|
|
702 |
|
|
703 |
if ( iDataConfig->IsLineFail( iRole ) )
|
|
704 |
{
|
|
705 |
ReadCompleted( KErrCommsLineFail );
|
|
706 |
}
|
|
707 |
//check if there is data
|
|
708 |
else if ( 0 == aLength )
|
|
709 |
{
|
|
710 |
ReadCompleted( KErrNone );
|
|
711 |
}
|
|
712 |
else
|
|
713 |
{
|
|
714 |
TInt ret( iRx2Dte->SetDteRead( aClientBuffer, aLength ) );
|
|
715 |
|
|
716 |
if ( KErrNone != ret )
|
|
717 |
{
|
|
718 |
ReadCompleted( ret );
|
|
719 |
}
|
|
720 |
//no else
|
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
// ---------------------------------------------------------
|
|
725 |
// CDpDataPort::ReadCancel
|
|
726 |
// This method cancels pending read operation.
|
|
727 |
// ---------------------------------------------------------
|
|
728 |
//
|
|
729 |
void CDpDataPort::ReadCancel()
|
|
730 |
{
|
|
731 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_READCANCEL, "CDpDataPort::ReadCancel" );
|
|
732 |
LOGM("CDpDataPort::ReadCancel");
|
|
733 |
|
|
734 |
iRx2Dte->ResetDteRead();
|
|
735 |
}
|
|
736 |
|
|
737 |
// ---------------------------------------------------------
|
|
738 |
// CDpDataPort::QueryReceiveBuffer
|
|
739 |
// This method queries the count of bytes in receive buffer
|
|
740 |
// (RX or echo buffer).
|
|
741 |
// ---------------------------------------------------------
|
|
742 |
//
|
|
743 |
TInt CDpDataPort::QueryReceiveBuffer(
|
|
744 |
TInt& aLength ) const
|
|
745 |
{
|
|
746 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_QUERYRECEIVEBUFFER, "CDpDataPort::QueryReceiveBuffer" );
|
|
747 |
LOGM("CDpDataPort::QueryReceiveBuffer");
|
|
748 |
|
|
749 |
// We have bytes to echo --> set aLength
|
|
750 |
// NOTE: we could also set aLength with echoBytes + usedBytes,
|
|
751 |
// but then we might have problem, because they are
|
|
752 |
// actually two different buffers and we cannot write
|
|
753 |
// them in same operation.
|
|
754 |
if ( 0 < iRx2Dte->EchoBytes() )
|
|
755 |
{
|
|
756 |
aLength = iRx2Dte->EchoBytes();
|
|
757 |
}
|
|
758 |
else
|
|
759 |
{
|
|
760 |
// setaLength with rx buffer count
|
|
761 |
aLength = iRx->UsedBytes();
|
|
762 |
}
|
|
763 |
|
|
764 |
return KErrNone;
|
|
765 |
}
|
|
766 |
|
|
767 |
// ---------------------------------------------------------
|
|
768 |
// CDpDataPort::ResetBuffers
|
|
769 |
// This method resets RX and TX buffers.
|
|
770 |
// ---------------------------------------------------------
|
|
771 |
//
|
|
772 |
void CDpDataPort::ResetBuffers(
|
|
773 |
TUint aFlags ) // Flags describing, which buffers are reseted
|
|
774 |
{
|
|
775 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_RESETBUFFERS, "CDpDataPort::ResetBuffers" );
|
|
776 |
LOGM("CDpDataPort::ResetBuffers");
|
|
777 |
|
|
778 |
//True if Reading is pending
|
|
779 |
TBool readPending( EFalse );
|
|
780 |
|
|
781 |
// Flush RX buffer
|
|
782 |
if ( aFlags & KCommResetRx )
|
|
783 |
{
|
|
784 |
// No pending reads allowed
|
|
785 |
// C32 panics if RComm::ResetBuffers() call made, when another request
|
|
786 |
// already in progress.
|
|
787 |
if ( iRx2Dte->ReadPending() )
|
|
788 |
{
|
|
789 |
readPending = ETrue;
|
|
790 |
}
|
|
791 |
else
|
|
792 |
{
|
|
793 |
// Read / ISC DataReceive is cancelled before setting receive
|
|
794 |
// buffer length, because pointer to write element might be
|
|
795 |
// different after reset.
|
|
796 |
|
|
797 |
// Cancel ISC DataReceive, release write element
|
|
798 |
iPn2Rx->Cancel();
|
|
799 |
// Flush real RX buffer
|
|
800 |
iRx->Flush();
|
|
801 |
// Flush echo data bytes
|
|
802 |
iRx2Dte->ResetEchoBytes();
|
|
803 |
|
|
804 |
// if previous state was high watermark then set back to lowwatermark
|
|
805 |
// to turn flowcontrol off ISC->DP
|
|
806 |
if ( EFlowControlOn == iFlowCtrl->FlowCtrlDcs2Dp() )
|
|
807 |
{
|
|
808 |
LOG("Turn Off Flow Control ISC->DP");
|
|
809 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_RESETBUFFERS, "CDpDataPort:: Turn Off Flow Control ISC->DP" );
|
|
810 |
|
|
811 |
//Set flow control to EFlowControlOff
|
|
812 |
iFlowCtrl->WaterMarkLowReached();
|
|
813 |
}
|
|
814 |
//no else
|
|
815 |
|
|
816 |
// Restart ISC DataReceive
|
|
817 |
iPn2Rx->Read();
|
|
818 |
}
|
|
819 |
}
|
|
820 |
//no else
|
|
821 |
|
|
822 |
// Flush TX buffer
|
|
823 |
if ( ( aFlags & KCommResetTx ) && ( !readPending ) )
|
|
824 |
{
|
|
825 |
iTx->Flush();
|
|
826 |
}
|
|
827 |
//no else
|
|
828 |
}
|
|
829 |
|
|
830 |
// ---------------------------------------------------------
|
|
831 |
// CDpDataPort::StartWrite
|
|
832 |
// This method requests write. We can complete right away, if
|
|
833 |
// we have space in TX buffer. Otherwise we have to put write
|
|
834 |
// pending and complete it later. There can be only one write
|
|
835 |
// pending at time.
|
|
836 |
// ---------------------------------------------------------
|
|
837 |
//
|
|
838 |
void CDpDataPort::StartWrite(
|
|
839 |
const TAny* aClientBuffer,
|
|
840 |
TInt aLength )
|
|
841 |
{
|
|
842 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_STARTWRITE, "CDpDataPort::StartWrite" );
|
|
843 |
OstTraceExt2( TRACE_NORMAL, DUP1_CDPDATAPORT_STARTWRITE, "CDpDataPort:: Port: %u, aLength: %d", iUnit, aLength );
|
|
844 |
|
|
845 |
LOGM2(" CDpDataPort::StartWrite - Port %d, aLength: %d",
|
|
846 |
iUnit, aLength );
|
|
847 |
|
|
848 |
if ( iDataConfig->IsLineFail( iRole ) )
|
|
849 |
{
|
|
850 |
LOG(" ERROR, DataPort::StartWrite, Write completed with LINE FAIL.");
|
|
851 |
OstTrace0( TRACE_NORMAL, DUP2_CDPDATAPORT_STARTWRITE, "ERROR, DataPort::StartWrite, Write completed with LINE FAIL" );
|
|
852 |
|
|
853 |
WriteCompleted( KErrCommsLineFail );
|
|
854 |
}
|
|
855 |
else
|
|
856 |
{
|
|
857 |
TInt ret( iDte2Tx->WriteTx( aClientBuffer, aLength ) );
|
|
858 |
switch ( ret )
|
|
859 |
{
|
|
860 |
case KErrNone:
|
|
861 |
{
|
|
862 |
LOG(" DataPort::StartWrite, Dte write completed.");
|
|
863 |
OstTrace0( TRACE_NORMAL, DUP3_CDPDATAPORT_STARTWRITE, "CDpDataPort:: Dte write completed" );
|
|
864 |
|
|
865 |
WriteCompleted( KErrNone );
|
|
866 |
break;
|
|
867 |
}
|
|
868 |
case KErrNotReady:
|
|
869 |
{
|
|
870 |
// Write is pending, do not complete write
|
|
871 |
break;
|
|
872 |
}
|
|
873 |
default:
|
|
874 |
{
|
|
875 |
// Something has gone wrong in WriteTx() (e.g. element reservation)
|
|
876 |
// and this information is forwarded to the client interface
|
|
877 |
LOG1(" ERROR, DataPort::StartWrite, Write completed with error: %d",
|
|
878 |
ret );
|
|
879 |
OstTrace1( TRACE_NORMAL, DUP4_CDPDATAPORT_STARTWRITE, "ERROR, DataPort::StartWrite, Write completed with error: %d", ret );
|
|
880 |
|
|
881 |
WriteCompleted( ret );
|
|
882 |
break;
|
|
883 |
}
|
|
884 |
}
|
|
885 |
}
|
|
886 |
}
|
|
887 |
|
|
888 |
// ---------------------------------------------------------
|
|
889 |
// CDpDataPort::WriteCancel
|
|
890 |
// This method cancels pending write operation.
|
|
891 |
// ---------------------------------------------------------
|
|
892 |
//
|
|
893 |
void CDpDataPort::WriteCancel()
|
|
894 |
{
|
|
895 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_WRITECANCEL, "CDpDataPort::WriteCancel" );
|
|
896 |
LOGM("CDpDataPort::WriteCancel");
|
|
897 |
|
|
898 |
iDte2Tx->CancelWrite();
|
|
899 |
}
|
|
900 |
|
|
901 |
// ---------------------------------------------------------
|
|
902 |
// CDpDataPort::Break
|
|
903 |
// This method sends break to DCS. DCS has configured type of
|
|
904 |
// break signal. Break time is not used. The implementation
|
|
905 |
// of break sending is in SendBreak() method.
|
|
906 |
// ---------------------------------------------------------
|
|
907 |
//
|
|
908 |
void CDpDataPort::Break(
|
|
909 |
TInt /*aTime*/ )
|
|
910 |
{
|
|
911 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_BREAK, "CDpDataPort::Break" );
|
|
912 |
LOGM("CDpDataPort::Break");
|
|
913 |
|
|
914 |
TInt ret( KErrNone );
|
|
915 |
|
|
916 |
if ( iDataConfig->IsLineFail( iRole ) )
|
|
917 |
{
|
|
918 |
BreakCompleted( KErrCommsLineFail );
|
|
919 |
}
|
|
920 |
else
|
|
921 |
{
|
|
922 |
switch ( iDataConfig->DteTypeOfBreakSignal() )
|
|
923 |
{
|
|
924 |
case PEP_COMM_BREAK_DESTRUCT:
|
|
925 |
{
|
|
926 |
// Send break to DCS.
|
|
927 |
ret = iBreak->SendBreak();
|
|
928 |
// Clear TX buffer.
|
|
929 |
iTx->Flush();
|
|
930 |
BreakCompleted( ret );
|
|
931 |
break;
|
|
932 |
}
|
|
933 |
case PEP_COMM_BREAK_EXPEDITED:
|
|
934 |
{
|
|
935 |
// Send break, then data.
|
|
936 |
ret = iBreak->SendBreak();
|
|
937 |
BreakCompleted( ret );
|
|
938 |
break;
|
|
939 |
}
|
|
940 |
case PEP_COMM_BREAK_NON_EXPEDITED:
|
|
941 |
{
|
|
942 |
// Send TX data, then break.
|
|
943 |
if ( 0 < iTx->UsedBytes() )
|
|
944 |
{
|
|
945 |
// There is data before break, put break pending.
|
|
946 |
iTx2Pn->SetBreakBytes( iTx->UsedBytes() );
|
|
947 |
}
|
|
948 |
else
|
|
949 |
{
|
|
950 |
// Send break right now.
|
|
951 |
ret = iBreak->SendBreak();
|
|
952 |
BreakCompleted( ret );
|
|
953 |
}
|
|
954 |
break;
|
|
955 |
}
|
|
956 |
default:
|
|
957 |
{
|
|
958 |
// Not supported break signal
|
|
959 |
BreakCompleted( KErrNotSupported );
|
|
960 |
break;
|
|
961 |
}
|
|
962 |
}
|
|
963 |
}
|
|
964 |
}
|
|
965 |
|
|
966 |
// ---------------------------------------------------------
|
|
967 |
// CDpDataPort::BreakCancel
|
|
968 |
// This method cancels pending break operation.
|
|
969 |
// ---------------------------------------------------------
|
|
970 |
//
|
|
971 |
void CDpDataPort::BreakCancel()
|
|
972 |
{
|
|
973 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_BREAKCANCEL, "CDpDataPort::BreakCancel" );
|
|
974 |
//ASK ARTO QUESTION
|
|
975 |
LOGM("CDpDataPort::BreakCancel");
|
|
976 |
|
|
977 |
// Simply send message with breaktime 0
|
|
978 |
Break( 0 );
|
|
979 |
|
|
980 |
// Cancel pending break
|
|
981 |
iTx2Pn->CancelBreakBytes();
|
|
982 |
}
|
|
983 |
|
|
984 |
// ---------------------------------------------------------
|
|
985 |
// CDpDataPort::GetConfig
|
|
986 |
// This method gets current port configuration.
|
|
987 |
// ---------------------------------------------------------
|
|
988 |
//
|
|
989 |
TInt CDpDataPort::GetConfig(
|
|
990 |
TDes8& aPackage ) const
|
|
991 |
{
|
|
992 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETCONFIG, "CDpDataPort::GetConfig" );
|
|
993 |
LOGM("CDpDataPort::GetConfig");
|
|
994 |
DEBUG( "CDpDataPort::GetConfig" )
|
|
995 |
|
|
996 |
aPackage.FillZ( aPackage.MaxLength() );
|
|
997 |
TInt len( Min( aPackage.MaxLength(), sizeof( TCommConfigV01 ) ) );
|
|
998 |
aPackage.Copy( reinterpret_cast<TUint8*>(
|
|
999 |
const_cast<TCommConfigV01*>( &iDataConfig->CommConfig() ) ), len );
|
|
1000 |
|
|
1001 |
return KErrNone;
|
|
1002 |
}
|
|
1003 |
|
|
1004 |
// ---------------------------------------------------------
|
|
1005 |
// CDpDataPort::SetConfig
|
|
1006 |
// This method sets current port configuration.
|
|
1007 |
// ---------------------------------------------------------
|
|
1008 |
//
|
|
1009 |
TInt CDpDataPort::SetConfig(
|
|
1010 |
const TDesC8& aPackage )
|
|
1011 |
{
|
|
1012 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETCONFIG, "CDpDataPort::SetConfig" );
|
|
1013 |
LOGM("CDpDataPort::SetConfig");
|
|
1014 |
|
|
1015 |
TCommConfigV01 commConfigV01;
|
|
1016 |
TInt ret(0);
|
|
1017 |
|
|
1018 |
if ( aPackage.Size() == sizeof(TCommConfigV01) )
|
|
1019 |
{
|
|
1020 |
Mem::FillZ( &commConfigV01, sizeof( TCommConfigV01 ) );
|
|
1021 |
TInt len( Min( aPackage.Length(), sizeof( TCommConfigV01 ) ) );
|
|
1022 |
Mem::Copy( &commConfigV01, aPackage.Ptr(), len );
|
|
1023 |
|
|
1024 |
// SetConfig back to sort the comms line out
|
|
1025 |
// once the comms line has failed
|
|
1026 |
|
|
1027 |
TCommConfigV01 origConfig = iDataConfig->CommConfig();
|
|
1028 |
ret = iDataConfig->SetConfig( commConfigV01 );
|
|
1029 |
if ( KErrNone == ret )
|
|
1030 |
{
|
|
1031 |
if ( iDataConfig->IsLineFail( iRole ) )
|
|
1032 |
{
|
|
1033 |
// Set back to what it was
|
|
1034 |
iDataConfig->SetConfig( origConfig );
|
|
1035 |
ret = KErrCommsLineFail;
|
|
1036 |
}
|
|
1037 |
//no else
|
|
1038 |
}
|
|
1039 |
//no else
|
|
1040 |
}
|
|
1041 |
else
|
|
1042 |
{
|
|
1043 |
LOG(" ERROR, CDpDataPort::SetConfig, Wrong SetConfig argument");
|
|
1044 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_SETCONFIG, "ERROR, CDpDataPort::SetConfig, Wrong SetConfig argument" );
|
|
1045 |
|
|
1046 |
ret = KErrArgument;
|
|
1047 |
}
|
|
1048 |
|
|
1049 |
return ret;
|
|
1050 |
}
|
|
1051 |
|
|
1052 |
// ---------------------------------------------------------
|
|
1053 |
// CDpDataPort::SetServerConfig
|
|
1054 |
// NOT supported by DataPort
|
|
1055 |
// ---------------------------------------------------------
|
|
1056 |
//
|
|
1057 |
TInt CDpDataPort::SetServerConfig(
|
|
1058 |
const TDesC8& /*aPackage*/ )
|
|
1059 |
{
|
|
1060 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETSERVERCONFIG, "CDpDataPort::SetServerConfig" );
|
|
1061 |
LOGM("CDpDataPort::SetServerConfig KErrNotSupported");
|
|
1062 |
|
|
1063 |
return KErrNotSupported;
|
|
1064 |
}
|
|
1065 |
|
|
1066 |
// ---------------------------------------------------------
|
|
1067 |
// CDpDataPort::GetServerConfig
|
|
1068 |
// NOT supported by DataPort
|
|
1069 |
// ---------------------------------------------------------
|
|
1070 |
//
|
|
1071 |
TInt CDpDataPort::GetServerConfig(
|
|
1072 |
TDes8& /*aPackage*/ )
|
|
1073 |
{
|
|
1074 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETSERVERCONFIG, "CDpDataPort::GetServerConfig" );
|
|
1075 |
LOGM("CDpDataPort::GetServerConfig KErrNotSupported");
|
|
1076 |
|
|
1077 |
return KErrNotSupported;
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
// ---------------------------------------------------------
|
|
1081 |
// CDpDataPort::GetCaps
|
|
1082 |
// This method gets port capabilities. Capabilities are
|
|
1083 |
// returned on TCommCapsV01 orTCommCapsV02 depending on the
|
|
1084 |
// package size.
|
|
1085 |
// ---------------------------------------------------------
|
|
1086 |
//
|
|
1087 |
TInt CDpDataPort::GetCaps(
|
|
1088 |
TDes8& aPackage )
|
|
1089 |
{
|
|
1090 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETCAPS, "CDpDataPort::GetCaps" );
|
|
1091 |
LOGM("CDpDataPort::GetCaps");
|
|
1092 |
|
|
1093 |
aPackage.FillZ( aPackage.MaxLength() );
|
|
1094 |
|
|
1095 |
if ( aPackage.Size() == sizeof( TCommCapsV02 ) )
|
|
1096 |
{
|
|
1097 |
// Get V02 Capabilities
|
|
1098 |
TCommCapsV02 commCapsV02;
|
|
1099 |
iDataConfig->GetCommCapsV02( commCapsV02 );
|
|
1100 |
|
|
1101 |
TCommCaps2 capsBuf2( commCapsV02 );
|
|
1102 |
aPackage = capsBuf2;
|
|
1103 |
}
|
|
1104 |
else if ( aPackage.Size() == sizeof( TCommCapsV01 ) )
|
|
1105 |
{
|
|
1106 |
// Get V01 Capabilities
|
|
1107 |
TCommCapsV01 commCaps;
|
|
1108 |
iDataConfig->GetCommCaps( commCaps );
|
|
1109 |
TCommCaps capsBuf( commCaps );
|
|
1110 |
aPackage = capsBuf;
|
|
1111 |
}
|
|
1112 |
else
|
|
1113 |
{
|
|
1114 |
LOG(" ERROR, CDpDataPort::GetCaps, Unsupported TCommCaps");
|
|
1115 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_GETCAPS, "ERROR, CDpDataPort::GetCaps, Unsupported TCommCaps" );
|
|
1116 |
}
|
|
1117 |
|
|
1118 |
return KErrNone;
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
// ---------------------------------------------------------
|
|
1122 |
// CDpDataPort::GetSignals
|
|
1123 |
// This methods gets current status of signals.
|
|
1124 |
// ---------------------------------------------------------
|
|
1125 |
//
|
|
1126 |
TInt CDpDataPort::GetSignals(
|
|
1127 |
TUint& aSignals )
|
|
1128 |
{
|
|
1129 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETSIGNALS, "CDpDataPort::GetSignals" );
|
|
1130 |
LOGM("CDpDataPort::GetSignals");
|
|
1131 |
|
|
1132 |
iDataConfig->GetSignals( aSignals );
|
|
1133 |
|
|
1134 |
return KErrNone;
|
|
1135 |
}
|
|
1136 |
|
|
1137 |
// ---------------------------------------------------------
|
|
1138 |
// CDpDataPort::SetSignalsToMark
|
|
1139 |
// This method sets signals to mark i.e. set signals ON.
|
|
1140 |
// This method uses CDpDataConfig::SetSignals2Cmt() method
|
|
1141 |
// to set signals. Updated signals and information about
|
|
1142 |
// changed signals are given to
|
|
1143 |
// CDpDataConfig::SetSignals2Cmt().
|
|
1144 |
// ---------------------------------------------------------
|
|
1145 |
//
|
|
1146 |
TInt CDpDataPort::SetSignalsToMark(
|
|
1147 |
TUint aSignals )
|
|
1148 |
{
|
|
1149 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETSIGNALSTOMARK, "CDpDataPort::SetSignalsToMark" );
|
|
1150 |
LOGM("CDpDataPort::SetSignalsToMark");
|
|
1151 |
DEBUG( "CDpDataPort::SetSignalsToMark" )
|
|
1152 |
|
|
1153 |
TInt ret ( KErrNone );
|
|
1154 |
|
|
1155 |
if ( aSignals )
|
|
1156 |
{
|
|
1157 |
TUint currentSignals;
|
|
1158 |
|
|
1159 |
if ( iRole == ECommRoleDTE )
|
|
1160 |
{
|
|
1161 |
aSignals &= KSignalDTEOutputs;
|
|
1162 |
}
|
|
1163 |
else
|
|
1164 |
{
|
|
1165 |
aSignals &= KSignalDCEOutputs;
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
iDataConfig->GetSignals( currentSignals );
|
|
1169 |
|
|
1170 |
if ( aSignals )
|
|
1171 |
{
|
|
1172 |
// Set signal bit
|
|
1173 |
currentSignals |= aSignals;
|
|
1174 |
// Set changed bit
|
|
1175 |
currentSignals |= aSignals * KSignalChanged;
|
|
1176 |
|
|
1177 |
ret = iDataConfig->SetSignals2Cmt( currentSignals );
|
|
1178 |
}
|
|
1179 |
//no else
|
|
1180 |
}
|
|
1181 |
//no else
|
|
1182 |
|
|
1183 |
return ret;
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
// ---------------------------------------------------------
|
|
1187 |
// CDpDataPort::SetSignalsToSpace
|
|
1188 |
// This method sets signals to space i.e. set signals OFF.
|
|
1189 |
// This method uses CDpDataConfig::SetSignals2Cmt() method
|
|
1190 |
// to set signals. Updated signals and information about
|
|
1191 |
// changed signals are given to
|
|
1192 |
// CDpDataConfig::SetSignals2Cmt().
|
|
1193 |
// ---------------------------------------------------------
|
|
1194 |
//
|
|
1195 |
TInt CDpDataPort::SetSignalsToSpace(
|
|
1196 |
TUint aSignals )
|
|
1197 |
{
|
|
1198 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETSIGNALSTOSPACE, "CDpDataPort::SetSignalsToSpace" );
|
|
1199 |
LOGM("CDpDataPort::SetSignalsToSpace");
|
|
1200 |
|
|
1201 |
TInt ret ( KErrNone );
|
|
1202 |
|
|
1203 |
if ( aSignals )
|
|
1204 |
{
|
|
1205 |
TUint currentSignals( 0 );
|
|
1206 |
|
|
1207 |
if ( ECommRoleDTE == iRole )
|
|
1208 |
{
|
|
1209 |
aSignals &= KSignalDTEOutputs;
|
|
1210 |
}
|
|
1211 |
else
|
|
1212 |
{
|
|
1213 |
aSignals &= KSignalDCEOutputs;
|
|
1214 |
}
|
|
1215 |
|
|
1216 |
iDataConfig->GetSignals( currentSignals );
|
|
1217 |
|
|
1218 |
if ( aSignals )
|
|
1219 |
{
|
|
1220 |
// Clear signal bit
|
|
1221 |
currentSignals &= ~aSignals;
|
|
1222 |
// Set changed bit
|
|
1223 |
currentSignals |= aSignals * KSignalChanged;
|
|
1224 |
ret = iDataConfig->SetSignals2Cmt( currentSignals );
|
|
1225 |
}
|
|
1226 |
//no else
|
|
1227 |
}
|
|
1228 |
//no else
|
|
1229 |
|
|
1230 |
return ret;
|
|
1231 |
}
|
|
1232 |
|
|
1233 |
// ---------------------------------------------------------
|
|
1234 |
// CDpDataPort::GetReceiveBufferLength
|
|
1235 |
// This method gets the size of receive (RX) buffer.
|
|
1236 |
// ---------------------------------------------------------
|
|
1237 |
//
|
|
1238 |
TInt CDpDataPort::GetReceiveBufferLength(
|
|
1239 |
TInt& aLength ) const
|
|
1240 |
{
|
|
1241 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETRECEIVEBUFFERLENGTH, "CDpDataPort::GetReceiveBufferLength" );
|
|
1242 |
LOGM("CDpDataPort::GetReceiveBufferLength");
|
|
1243 |
|
|
1244 |
aLength = iRx->Size();
|
|
1245 |
|
|
1246 |
return KErrNone;
|
|
1247 |
}
|
|
1248 |
|
|
1249 |
// ---------------------------------------------------------
|
|
1250 |
// CDpDataPort::SetReceiveBufferLength
|
|
1251 |
// This method sets the size of receive (RX) buffer.
|
|
1252 |
// ---------------------------------------------------------
|
|
1253 |
//
|
|
1254 |
TInt CDpDataPort::SetReceiveBufferLength(
|
|
1255 |
TInt aLength )
|
|
1256 |
{
|
|
1257 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETRECEIVEBUFFERLENGTH, "CDpDataPort::SetReceiveBufferLength" );
|
|
1258 |
LOGM("CDpDataPort::SetReceiveBufferLength");
|
|
1259 |
|
|
1260 |
TInt ret( KErrNone );
|
|
1261 |
|
|
1262 |
// Read / ISC DataReceive is cancelled before setting receive
|
|
1263 |
// buffer length, because pointer to write element might be
|
|
1264 |
// different after seting length.
|
|
1265 |
|
|
1266 |
// Cancel ISC DataReceive, release write element
|
|
1267 |
iPn2Rx->Cancel();
|
|
1268 |
|
|
1269 |
// Client cannot change RX buffer size smaller than initial size,
|
|
1270 |
// because of slow response to pipe flow control.
|
|
1271 |
if ( KDpRxBufferInitialSize > aLength ||
|
|
1272 |
KDpMaximumSetReceiveBufferLength < aLength )
|
|
1273 |
{
|
|
1274 |
ret = KErrArgument;
|
|
1275 |
}
|
|
1276 |
else
|
|
1277 |
{
|
|
1278 |
ret = iRx->SetLength( aLength );
|
|
1279 |
}
|
|
1280 |
|
|
1281 |
// Restart ISC DataReceive
|
|
1282 |
iPn2Rx->Read();
|
|
1283 |
|
|
1284 |
return ret;
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
// ---------------------------------------------------------
|
|
1288 |
// CDpDataPort::Destruct
|
|
1289 |
// This method deletes CDpDataPort port.
|
|
1290 |
// ---------------------------------------------------------
|
|
1291 |
//
|
|
1292 |
void CDpDataPort::Destruct()
|
|
1293 |
{
|
|
1294 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DESTRUCT, "CDpDataPort::Destruct" );
|
|
1295 |
OstTrace0( TRACE_NORMAL, DUP1_CDPDATAPORT_DESTRUCT, "********** CDpDataPort::Destruct **********" );
|
|
1296 |
|
|
1297 |
LOGM("CDpDataPort::Destruct");
|
|
1298 |
LOG("********** CDpDataPort::Destruct **********");
|
|
1299 |
|
|
1300 |
// Close the pipe and start disconnection sequence
|
|
1301 |
if ( iPifDcs && CDpPif::EDpPifInitial != iPifDcs->PifState() )
|
|
1302 |
{
|
|
1303 |
if ( iPn2Rx->IsHighWaterMarkReached() )
|
|
1304 |
{
|
|
1305 |
ResetBuffers( KCommResetRx | KCommResetTx );
|
|
1306 |
}
|
|
1307 |
//no else
|
|
1308 |
iReadyToDestruct = ETrue;
|
|
1309 |
TRAP_IGNORE( iPifDcs->ClosePipeL( iUnit ) );
|
|
1310 |
}
|
|
1311 |
// Delete DataPort
|
|
1312 |
else
|
|
1313 |
{
|
|
1314 |
delete this;
|
|
1315 |
}
|
|
1316 |
}
|
|
1317 |
|
|
1318 |
// ---------------------------------------------------------
|
|
1319 |
// CDpDataPort::FreeMemory()
|
|
1320 |
// NOT supported by DataPort
|
|
1321 |
// ---------------------------------------------------------
|
|
1322 |
//
|
|
1323 |
void CDpDataPort::FreeMemory()
|
|
1324 |
{
|
|
1325 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_FREEMEMORY, "CDpDataPort::FreeMemory" );
|
|
1326 |
LOGM("CDpDataPort::FreeMemory- Do nothing");
|
|
1327 |
}
|
|
1328 |
|
|
1329 |
// ---------------------------------------------------------
|
|
1330 |
// CDpDataPort::ISAHandle
|
|
1331 |
// This method returns Isc Api handle (RIscApi).
|
|
1332 |
// ---------------------------------------------------------
|
|
1333 |
//
|
|
1334 |
RIscApi& CDpDataPort::ISAHandle()
|
|
1335 |
{
|
|
1336 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_ISAHANDLE, "CDpDataPort::ISAHandle" );
|
|
1337 |
LOGM("CDpDataPort::ISAHandle");
|
|
1338 |
|
|
1339 |
return *iISAHandle;
|
|
1340 |
}
|
|
1341 |
|
|
1342 |
// ---------------------------------------------------------
|
|
1343 |
// CDpDataPort::BreakHandler
|
|
1344 |
// This method returns reference to break signal handler
|
|
1345 |
// (CDpBreak).
|
|
1346 |
// ---------------------------------------------------------
|
|
1347 |
//
|
|
1348 |
CDpBreak& CDpDataPort::BreakHandler()
|
|
1349 |
{
|
|
1350 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_BREAKHANDLER, "CDpDataPort::BreakHandler" );
|
|
1351 |
LOGM(" CDpDataPort::BreakHandler");
|
|
1352 |
|
|
1353 |
return *iBreak;
|
|
1354 |
}
|
|
1355 |
|
|
1356 |
// ---------------------------------------------------------
|
|
1357 |
// CDpDataPort::CommPep
|
|
1358 |
// This method returns reference to COMM PEP
|
|
1359 |
// (CDpCommPep).
|
|
1360 |
// ---------------------------------------------------------
|
|
1361 |
//
|
|
1362 |
CDpCommPep& CDpDataPort::CommPep()
|
|
1363 |
{
|
|
1364 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_COMMPEP, "CDpDataPort::CommPep" );
|
|
1365 |
LOGM(" CDpDataPort::CommPep");
|
|
1366 |
|
|
1367 |
return *iCommPep;
|
|
1368 |
}
|
|
1369 |
|
|
1370 |
// ---------------------------------------------------------
|
|
1371 |
// CDpDataPort::DataConfig
|
|
1372 |
// This method returns reference to data configuration
|
|
1373 |
// (CDpDataConfig).
|
|
1374 |
// ---------------------------------------------------------
|
|
1375 |
//
|
|
1376 |
CDpDataConfig& CDpDataPort::DataConfig()
|
|
1377 |
{
|
|
1378 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DATACONFIG, "CDpDataPort::DataConfig" );
|
|
1379 |
LOGM(" CDpDataPort::DataConfig");
|
|
1380 |
|
|
1381 |
return *iDataConfig;
|
|
1382 |
}
|
|
1383 |
|
|
1384 |
// ---------------------------------------------------------
|
|
1385 |
// CDpDataPort::EscDetect
|
|
1386 |
// This method returns reference to escape sequence
|
|
1387 |
// detector (CDpEscDetect).
|
|
1388 |
// ---------------------------------------------------------
|
|
1389 |
//
|
|
1390 |
CDpEscDetect& CDpDataPort::EscDetect()
|
|
1391 |
{
|
|
1392 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_ESCDETECT, "CDpDataPort::EscDetect" );
|
|
1393 |
LOGM(" CDpDataPort::EscDetect");
|
|
1394 |
|
|
1395 |
return *iEscDetect;
|
|
1396 |
}
|
|
1397 |
|
|
1398 |
// ---------------------------------------------------------
|
|
1399 |
// CDpDataPort::FlowCtrl
|
|
1400 |
// This method returns reference to flow control handler
|
|
1401 |
// (CDpFlowCtrl).
|
|
1402 |
// ---------------------------------------------------------
|
|
1403 |
//
|
|
1404 |
CDpFlowCtrl& CDpDataPort::FlowCtrl()
|
|
1405 |
{
|
|
1406 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_FLOWCTRL, "CDpDataPort::FlowCtrl" );
|
|
1407 |
LOGM(" CDpDataPort::FlowCtrl");
|
|
1408 |
|
|
1409 |
return *iFlowCtrl;
|
|
1410 |
}
|
|
1411 |
|
|
1412 |
// ---------------------------------------------------------
|
|
1413 |
// CDpDataPort::Mif
|
|
1414 |
// This method returns reference to message interface (MIF).
|
|
1415 |
// ---------------------------------------------------------
|
|
1416 |
//
|
|
1417 |
CDpMif& CDpDataPort::Mif()
|
|
1418 |
{
|
|
1419 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_MIF, "CDpDataPort::Mif" );
|
|
1420 |
LOGM(" CDpDataPort::Mif");
|
|
1421 |
|
|
1422 |
return *iMif;
|
|
1423 |
};
|
|
1424 |
|
|
1425 |
// ---------------------------------------------------------
|
|
1426 |
// CDpDataPort::ParityHandler
|
|
1427 |
// This method returns reference to parity handler
|
|
1428 |
// (CDpParityHandler).
|
|
1429 |
// ---------------------------------------------------------
|
|
1430 |
//
|
|
1431 |
CDpParityHandler& CDpDataPort::ParityHandler()
|
|
1432 |
{
|
|
1433 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_PARITYHANDLER, "CDpDataPort::ParityHandler" );
|
|
1434 |
LOGM(" CDpDataPort::ParityHandler");
|
|
1435 |
|
|
1436 |
return *iParityHandler;
|
|
1437 |
}
|
|
1438 |
|
|
1439 |
// ---------------------------------------------------------
|
|
1440 |
// CDpDataPort::Pif
|
|
1441 |
// This method returns reference to pipe interface (PIF).
|
|
1442 |
// ---------------------------------------------------------
|
|
1443 |
//
|
|
1444 |
CDpPif& CDpDataPort::Pif()
|
|
1445 |
{
|
|
1446 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_PIF, "CDpDataPort::Pif" );
|
|
1447 |
LOGM(" CDpDataPort::Pif");
|
|
1448 |
|
|
1449 |
return *iPifDcs;
|
|
1450 |
}
|
|
1451 |
|
|
1452 |
// ---------------------------------------------------------
|
|
1453 |
// CDpDataPort::Rx
|
|
1454 |
// This method returns reference to to RX buffer.
|
|
1455 |
// ---------------------------------------------------------
|
|
1456 |
//
|
|
1457 |
CDpDataBuffer& CDpDataPort::Rx()
|
|
1458 |
{
|
|
1459 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_RX, "CDpDataPort::Rx" );
|
|
1460 |
LOGM(" CDpDataPort::Rx");
|
|
1461 |
|
|
1462 |
return *iRx;
|
|
1463 |
}
|
|
1464 |
|
|
1465 |
// ---------------------------------------------------------
|
|
1466 |
// CDpDataPort::Rx2Dte
|
|
1467 |
// This method returns reference to Rx2Dte.
|
|
1468 |
// ---------------------------------------------------------
|
|
1469 |
//
|
|
1470 |
CDpRx2Dte& CDpDataPort::Rx2Dte()
|
|
1471 |
{
|
|
1472 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_RX2DTE, "CDpDataPort::Rx2Dte" );
|
|
1473 |
LOGM(" CDpDataPort::Rx2Dte");
|
|
1474 |
|
|
1475 |
return *iRx2Dte;
|
|
1476 |
}
|
|
1477 |
|
|
1478 |
// ---------------------------------------------------------
|
|
1479 |
// CDpDataPort::TermDetect
|
|
1480 |
// This method returns reference to terminator characters
|
|
1481 |
// detector (CDpTermDetect).
|
|
1482 |
// ---------------------------------------------------------
|
|
1483 |
//
|
|
1484 |
CDpTermDetect& CDpDataPort::TermDetect()
|
|
1485 |
{
|
|
1486 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_TERMDETECT, "CDpDataPort::TermDetect" );
|
|
1487 |
LOGM(" CDpDataPort::TermDetect");
|
|
1488 |
|
|
1489 |
return *iTermDetect;
|
|
1490 |
}
|
|
1491 |
|
|
1492 |
// ---------------------------------------------------------
|
|
1493 |
// CDpDataPort::Tx
|
|
1494 |
// This method returns reference to to TX buffer.
|
|
1495 |
// ---------------------------------------------------------
|
|
1496 |
//
|
|
1497 |
CDpDataBuffer& CDpDataPort::Tx()
|
|
1498 |
{
|
|
1499 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_TX, "CDpDataPort::Tx" );
|
|
1500 |
LOGM(" CDpDataPort::Tx");
|
|
1501 |
|
|
1502 |
return *iTx;
|
|
1503 |
}
|
|
1504 |
|
|
1505 |
// ---------------------------------------------------------
|
|
1506 |
// CDpDataPort::SignalTx2Pn
|
|
1507 |
// This method signals pipe interface (PIF). PIF is not
|
|
1508 |
// signalled, if the request is pending.
|
|
1509 |
// ---------------------------------------------------------
|
|
1510 |
//
|
|
1511 |
TInt CDpDataPort::SignalTx2Pn()
|
|
1512 |
{
|
|
1513 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SIGNALTX2PN, "CDpDataPort::SignalTx2Pn" );
|
|
1514 |
LOGM(" CDpDataPort::SignalTx2Pn");
|
|
1515 |
DEBUG( "Signal Tx2Pn" )
|
|
1516 |
|
|
1517 |
TInt ret( KErrNone );
|
|
1518 |
|
|
1519 |
if ( iTx2Pn && ( iTx2Pn->iStatus == KRequestPending ) )
|
|
1520 |
{
|
|
1521 |
iTx2Pn->ReleaseNotify();
|
|
1522 |
}
|
|
1523 |
else
|
|
1524 |
{
|
|
1525 |
ret = KErrNotReady;
|
|
1526 |
}
|
|
1527 |
|
|
1528 |
return ret;
|
|
1529 |
}
|
|
1530 |
|
|
1531 |
// ---------------------------------------------------------
|
|
1532 |
// CDpDataPort::SignalPif
|
|
1533 |
// This method signals pipe interface (PIF). PIF is not
|
|
1534 |
// signalled, if the request is pending.
|
|
1535 |
// ---------------------------------------------------------
|
|
1536 |
//
|
|
1537 |
TInt CDpDataPort::SignalPif(
|
|
1538 |
const TInt aError )
|
|
1539 |
{
|
|
1540 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SIGNALPIF, "CDpDataPort::SignalPif" );
|
|
1541 |
LOGM(" CDpDataPort::SignalPif");
|
|
1542 |
DEBUG( "Signal Pif" )
|
|
1543 |
|
|
1544 |
TInt ret( KErrNone );
|
|
1545 |
|
|
1546 |
if ( iPifDcs && ( iPifDcs->iStatus == KRequestPending ) )
|
|
1547 |
{
|
|
1548 |
TRequestStatus* status = &iPifDcs->iStatus;
|
|
1549 |
User::RequestComplete( status, aError );
|
|
1550 |
}
|
|
1551 |
else
|
|
1552 |
{
|
|
1553 |
ret = KErrNotReady;
|
|
1554 |
}
|
|
1555 |
|
|
1556 |
return ret;
|
|
1557 |
}
|
|
1558 |
|
|
1559 |
// ---------------------------------------------------------
|
|
1560 |
// CDpDataPort::SignalDte2Tx
|
|
1561 |
// This method signals Dte2Tx active object (CDte2Tx). Dte2Tx
|
|
1562 |
// is not signalled, if the request is pending.
|
|
1563 |
// ---------------------------------------------------------
|
|
1564 |
//
|
|
1565 |
TInt CDpDataPort::SignalDte2Tx()
|
|
1566 |
{
|
|
1567 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SIGNALDTE2TX, "CDpDataPort::SignalDte2Tx" );
|
|
1568 |
LOGM(" CDpDataPort::SignalDte2Tx");
|
|
1569 |
DEBUG( "Signal Dte2Tx" )
|
|
1570 |
|
|
1571 |
TInt ret( KErrNone );
|
|
1572 |
|
|
1573 |
if ( iDte2Tx && ( iDte2Tx->iStatus == KRequestPending ) )
|
|
1574 |
{
|
|
1575 |
iDte2Tx->ReleaseNotify();
|
|
1576 |
}
|
|
1577 |
else
|
|
1578 |
{
|
|
1579 |
ret = KErrNotReady;
|
|
1580 |
}
|
|
1581 |
|
|
1582 |
return ret;
|
|
1583 |
}
|
|
1584 |
|
|
1585 |
// ---------------------------------------------------------
|
|
1586 |
// CDpDataPort::SignalRx2Dte
|
|
1587 |
// This method signals Rx2Dte active object (CDpRx2Dte).
|
|
1588 |
// Rx2Dte is not signalled, if the request is pending. Rx2Dte
|
|
1589 |
// is also not signalled, if there is not enough bytes to
|
|
1590 |
// write and terminator count is zero. There is not enough
|
|
1591 |
// bytes, when the amount of bytes, which still needs to be
|
|
1592 |
// written to DTE (user length - write offset), is greater
|
|
1593 |
// than amount of bytes in RX buffer (including echo bytes).
|
|
1594 |
// ---------------------------------------------------------
|
|
1595 |
//
|
|
1596 |
TInt CDpDataPort::SignalRx2Dte()
|
|
1597 |
{
|
|
1598 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SIGNALRX2DTE, "CDpDataPort::SignalRx2Dte" );
|
|
1599 |
LOGM(" CDpDataPort::SignalRx2Dte");
|
|
1600 |
DEBUG( "SignalRx2Dte" )
|
|
1601 |
|
|
1602 |
// Optimaze in order to avoid unnecessary signaling.
|
|
1603 |
TInt userLength( iRx2Dte->LengthWanted() );
|
|
1604 |
TInt ret( KErrNone );
|
|
1605 |
TBool notEnoughByte( EFalse );
|
|
1606 |
|
|
1607 |
//user length can be negative
|
|
1608 |
if ( 0 <= userLength )
|
|
1609 |
{
|
|
1610 |
// Client reads with length and timeout.
|
|
1611 |
TInt bytesInRx( iRx->UsedBytes() + iRx2Dte->EchoBytes() );
|
|
1612 |
|
|
1613 |
// Start discharging Rx buffer, if high water mark is reached
|
|
1614 |
if ( ( ( bytesInRx + iRx2Dte->IPCWriteOffset() < userLength ) &&
|
|
1615 |
iDataConfig->TerminatorCount() == 0 ) &&
|
|
1616 |
!( iPn2Rx->IsHighWaterMarkReached() ) )
|
|
1617 |
{
|
|
1618 |
// Not enough bytes
|
|
1619 |
notEnoughByte = ETrue;
|
|
1620 |
}
|
|
1621 |
//no else
|
|
1622 |
}
|
|
1623 |
//no else
|
|
1624 |
|
|
1625 |
// Read one or more' or terminator read
|
|
1626 |
// At this point we know there is enough data in the buffer
|
|
1627 |
// or we are using terminator read.
|
|
1628 |
if ( !notEnoughByte )
|
|
1629 |
{
|
|
1630 |
if ( iRx2Dte && ( iRx2Dte->iStatus == KRequestPending ) )
|
|
1631 |
{
|
|
1632 |
iRx2Dte->ReleaseNotify();
|
|
1633 |
}
|
|
1634 |
else
|
|
1635 |
{
|
|
1636 |
ret = KErrNotReady;
|
|
1637 |
}
|
|
1638 |
}
|
|
1639 |
//no else
|
|
1640 |
|
|
1641 |
return ret;
|
|
1642 |
}
|
|
1643 |
|
|
1644 |
// ---------------------------------------------------------
|
|
1645 |
// CDpDataPort::IsRx2DteReadPending
|
|
1646 |
// This method finds out, whether client's read is pending
|
|
1647 |
// in Rx2Dte (CDpRx2Dte).
|
|
1648 |
// ---------------------------------------------------------
|
|
1649 |
//
|
|
1650 |
TBool CDpDataPort::IsRx2DteReadPending()
|
|
1651 |
{
|
|
1652 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_ISRX2DTEREADPENDING, "CDpDataPort::IsRx2DteReadPending" );
|
|
1653 |
LOGM(" CDpDataPort::IsRx2DteReadPending");
|
|
1654 |
|
|
1655 |
return iRx2Dte->ReadPending();
|
|
1656 |
}
|
|
1657 |
|
|
1658 |
// ---------------------------------------------------------
|
|
1659 |
// CDpDataPort::NotifySignalChange
|
|
1660 |
// This method sets up flag to indicate that we must notify
|
|
1661 |
// C32 about signal changes.
|
|
1662 |
// ---------------------------------------------------------
|
|
1663 |
//
|
|
1664 |
void CDpDataPort::NotifySignalChange(
|
|
1665 |
TUint aSignalMask )
|
|
1666 |
{
|
|
1667 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYSIGNALCHANGE, "CDpDataPort::NotifySignalChange" );
|
|
1668 |
LOGM("CDpDataPort::NotifySignalChange");
|
|
1669 |
|
|
1670 |
iDataConfig->SetSignalNotify( ETrue );
|
|
1671 |
iDataConfig->SetNotifySignalMask( aSignalMask );
|
|
1672 |
}
|
|
1673 |
|
|
1674 |
// ---------------------------------------------------------
|
|
1675 |
// CDpDataPort::NotifySignalChangeCancel
|
|
1676 |
// This method cancels an outstanding NotifySignalChange
|
|
1677 |
// request.
|
|
1678 |
// ---------------------------------------------------------
|
|
1679 |
//
|
|
1680 |
void CDpDataPort::NotifySignalChangeCancel()
|
|
1681 |
{
|
|
1682 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYSIGNALCHANGECANCEL, "CDpDataPort::NotifySignalChangeCancel" );
|
|
1683 |
LOGM("CDpDataPort::NotifySignalChangeCancel");
|
|
1684 |
DEBUG( "CDpDataPort::NotifySignalChangeCancel" )
|
|
1685 |
|
|
1686 |
iDataConfig->SetSignalNotify( EFalse );
|
|
1687 |
}
|
|
1688 |
|
|
1689 |
// ---------------------------------------------------------
|
|
1690 |
// CDpDataPort::NotifyConfigChange
|
|
1691 |
// This method sets up flag to indicate that we must notify
|
|
1692 |
// C32 about port configuration changes of DCS.
|
|
1693 |
// ---------------------------------------------------------
|
|
1694 |
//
|
|
1695 |
void CDpDataPort::NotifyConfigChange()
|
|
1696 |
{
|
|
1697 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYCONFIGCHANGE, "CDpDataPort::NotifyConfigChange" );
|
|
1698 |
LOGM("CDpDataPort::NotifyConfigChange");
|
|
1699 |
DEBUG( "CDpDataPort::NotifyConfigChange" )
|
|
1700 |
|
|
1701 |
iDataConfig->SetConfigNotify( ETrue );
|
|
1702 |
}
|
|
1703 |
|
|
1704 |
// ---------------------------------------------------------
|
|
1705 |
// CDpDataPort::NotifyConfigChangeCancel
|
|
1706 |
// This method cancels an outstanding NotifyConfigChange
|
|
1707 |
// request.
|
|
1708 |
// ---------------------------------------------------------
|
|
1709 |
//
|
|
1710 |
void CDpDataPort::NotifyConfigChangeCancel()
|
|
1711 |
{
|
|
1712 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYCONFIGCHANGECANCEL, "CDpDataPort::NotifyConfigChangeCancel" );
|
|
1713 |
LOGM("CDpDataPort::NotifyConfigChangeCancel");
|
|
1714 |
DEBUG( "CDpDataPort::NotifyConfigChangeCancel" )
|
|
1715 |
|
|
1716 |
iDataConfig->SetConfigNotify( EFalse );
|
|
1717 |
}
|
|
1718 |
|
|
1719 |
// ---------------------------------------------------------
|
|
1720 |
// CDpDataPort::NotifyFlowControlChange
|
|
1721 |
// This method sets up flag to indicate that we must notify
|
|
1722 |
// C32 about flow control changes between DP and DCS.
|
|
1723 |
// ---------------------------------------------------------
|
|
1724 |
//
|
|
1725 |
void CDpDataPort::NotifyFlowControlChange()
|
|
1726 |
{
|
|
1727 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYFLOWCONTROLCHANGE, "CDpDataPort::NotifyFlowControlChange" );
|
|
1728 |
LOGM("CDpDataPort::NotifyFlowControlChange");
|
|
1729 |
DEBUG( "CDpDataPort::NotifyFlowControlChange" )
|
|
1730 |
|
|
1731 |
iFlowCtrl->SetFlowControlNotify( ETrue );
|
|
1732 |
}
|
|
1733 |
|
|
1734 |
// ---------------------------------------------------------
|
|
1735 |
// CDpDataPort::NotifyFlowControlChangeCancel
|
|
1736 |
// This method cancels an outstanding NotifyFlowControlChange
|
|
1737 |
// request.
|
|
1738 |
// ---------------------------------------------------------
|
|
1739 |
//
|
|
1740 |
void CDpDataPort::NotifyFlowControlChangeCancel()
|
|
1741 |
{
|
|
1742 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYFLOWCONTROLCHANGECANCEL, "CDpDataPort::NotifyFlowControlChangeCancel" );
|
|
1743 |
LOGM("CDpDataPort::NotifyFlowControlChangeCancel");
|
|
1744 |
DEBUG( "CDpDataPort::NotifyFlowControlChangeCancel" )
|
|
1745 |
|
|
1746 |
iFlowCtrl->SetFlowControlNotify( EFalse );
|
|
1747 |
}
|
|
1748 |
|
|
1749 |
// ---------------------------------------------------------
|
|
1750 |
// CDpDataPort::NotifyBreak
|
|
1751 |
// This method sets up flag to indicate that we must notify
|
|
1752 |
// C32, when break signal from DCS is detected.
|
|
1753 |
// ---------------------------------------------------------
|
|
1754 |
//
|
|
1755 |
void CDpDataPort::NotifyBreak()
|
|
1756 |
{
|
|
1757 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYBREAK, "CDpDataPort::NotifyBreak" );
|
|
1758 |
LOGM("CDpDataPort::NotifyBreak");
|
|
1759 |
DEBUG( "CDpDataPort::NotifyBreak" )
|
|
1760 |
|
|
1761 |
iBreak->SetBreakNotify( ETrue );
|
|
1762 |
}
|
|
1763 |
|
|
1764 |
// ---------------------------------------------------------
|
|
1765 |
// CDpDataPort::NotifyBreakCancel
|
|
1766 |
// This method cancels an outstanding NotifyBreak request.
|
|
1767 |
// ---------------------------------------------------------
|
|
1768 |
//
|
|
1769 |
void CDpDataPort::NotifyBreakCancel()
|
|
1770 |
{
|
|
1771 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYBREAKCANCEL, "CDpDataPort::NotifyBreakCancel" );
|
|
1772 |
LOGM("CDpDataPort::NotifyBreakCancel");
|
|
1773 |
DEBUG( "CDpDataPort::NotifyBreakCancel" )
|
|
1774 |
|
|
1775 |
iBreak->SetBreakNotify( EFalse );
|
|
1776 |
}
|
|
1777 |
|
|
1778 |
// ---------------------------------------------------------
|
|
1779 |
// CDpDataPort::NotifyDataAvailable
|
|
1780 |
// This method sets up flag to indicate that we must notify
|
|
1781 |
// C32, when there has appeared data into receive (RX)
|
|
1782 |
// buffer.
|
|
1783 |
// ---------------------------------------------------------
|
|
1784 |
//
|
|
1785 |
void CDpDataPort::NotifyDataAvailable()
|
|
1786 |
{
|
|
1787 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYDATAAVAILABLE, "CDpDataPort::NotifyDataAvailable" );
|
|
1788 |
LOGM("CDpDataPort::NotifyDataAvailable");
|
|
1789 |
|
|
1790 |
iPn2Rx->SetDataAvailableNotification( ETrue );
|
|
1791 |
}
|
|
1792 |
|
|
1793 |
// ---------------------------------------------------------
|
|
1794 |
// CDpDataPort::NotifyDataAvailableCancel
|
|
1795 |
// This method cancels an outstanding NotifyDataAvailable
|
|
1796 |
// request.
|
|
1797 |
// ---------------------------------------------------------
|
|
1798 |
//
|
|
1799 |
void CDpDataPort::NotifyDataAvailableCancel()
|
|
1800 |
{
|
|
1801 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYDATAAVAILABLECANCEL, "CDpDataPort::NotifyDataAvailableCancel" );
|
|
1802 |
LOGM("CDpDataPort::NotifyDataAvailableCancel");
|
|
1803 |
|
|
1804 |
iPn2Rx->SetDataAvailableNotification( EFalse );
|
|
1805 |
}
|
|
1806 |
|
|
1807 |
// ---------------------------------------------------------
|
|
1808 |
// CDpDataPort::NotifyOutputEmpty
|
|
1809 |
// This method sets up flag to indicate that we must notify
|
|
1810 |
// C32, when transmit (TX) buffer is emptied.
|
|
1811 |
// ---------------------------------------------------------
|
|
1812 |
//
|
|
1813 |
void CDpDataPort::NotifyOutputEmpty()
|
|
1814 |
{
|
|
1815 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYOUTPUTEMPTY, "CDpDataPort::NotifyOutputEmpty" );
|
|
1816 |
LOGM("CDpDataPort::NotifyOutputEmpty");
|
|
1817 |
DEBUG( "CDpDataPort::NotifyOutputEmpty" )
|
|
1818 |
|
|
1819 |
iTx2Pn->SetOutputBufferEmptyNotification( ETrue );
|
|
1820 |
}
|
|
1821 |
|
|
1822 |
// ---------------------------------------------------------
|
|
1823 |
// CDpDataPort::NotifyOutputEmptyCancel
|
|
1824 |
// This method cancels an outstanding NotifyOutputEmpty
|
|
1825 |
// request.
|
|
1826 |
// ---------------------------------------------------------
|
|
1827 |
//
|
|
1828 |
void CDpDataPort::NotifyOutputEmptyCancel()
|
|
1829 |
{
|
|
1830 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_NOTIFYOUTPUTEMPTYCANCEL, "CDpDataPort::NotifyOutputEmptyCancel" );
|
|
1831 |
LOGM("CDpDataPort::NotifyOutputEmptyCancel");
|
|
1832 |
DEBUG( "CDpDataPort::NotifyOutputEmptyCancel" )
|
|
1833 |
|
|
1834 |
iTx2Pn->SetOutputBufferEmptyNotification( EFalse );
|
|
1835 |
}
|
|
1836 |
|
|
1837 |
// ---------------------------------------------------------
|
|
1838 |
// CDpDataPort::GetFlowControlStatus
|
|
1839 |
// This method gets current DP->DCS flow control status.
|
|
1840 |
// ---------------------------------------------------------
|
|
1841 |
//
|
|
1842 |
TInt CDpDataPort::GetFlowControlStatus(
|
|
1843 |
TFlowControl& aFlowControl)
|
|
1844 |
{
|
|
1845 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETFLOWCONTROLSTATUS, "CDpDataPort::GetFlowControlStatus" );
|
|
1846 |
LOGM("CDpDataPort::GetFlowControlStatus");
|
|
1847 |
|
|
1848 |
iFlowCtrl->GetDp2DcsFlowControlStatus( aFlowControl );
|
|
1849 |
|
|
1850 |
return KErrNone;
|
|
1851 |
}
|
|
1852 |
|
|
1853 |
// ---------------------------------------------------------
|
|
1854 |
// CDpDataPort::SetRole
|
|
1855 |
// This method sets role (DCE/DTE) of DataPort.
|
|
1856 |
// ---------------------------------------------------------
|
|
1857 |
//
|
|
1858 |
TInt CDpDataPort::SetRole(
|
|
1859 |
TCommRole aRole )
|
|
1860 |
{
|
|
1861 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETROLE, "CDpDataPort::SetRole" );
|
|
1862 |
LOGM("CDpDataPort::SetRole");
|
|
1863 |
DEBUG( "CDpDataPort::SetRole" )
|
|
1864 |
|
|
1865 |
TInt result( KErrNone );
|
|
1866 |
|
|
1867 |
switch ( aRole )
|
|
1868 |
{
|
|
1869 |
case ECommRoleDCE: // Fall through
|
|
1870 |
case ECommRoleDTE:
|
|
1871 |
{
|
|
1872 |
// DTE/DCE is supported
|
|
1873 |
iRole = aRole;
|
|
1874 |
// configuring role capabilities
|
|
1875 |
result = iDataConfig->SetRoleCap( aRole );
|
|
1876 |
break;
|
|
1877 |
}
|
|
1878 |
default:
|
|
1879 |
{
|
|
1880 |
result = KErrNotSupported;
|
|
1881 |
}
|
|
1882 |
}
|
|
1883 |
|
|
1884 |
return result;
|
|
1885 |
}
|
|
1886 |
|
|
1887 |
// ---------------------------------------------------------
|
|
1888 |
// CDpDataPort::GetRole
|
|
1889 |
// This method gets role (DTE/DCE) of DataPort.
|
|
1890 |
// ---------------------------------------------------------
|
|
1891 |
//
|
|
1892 |
TInt CDpDataPort::GetRole(
|
|
1893 |
TCommRole& aRole )
|
|
1894 |
{
|
|
1895 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_GETROLE, "CDpDataPort::GetRole" );
|
|
1896 |
LOGM("CDpDataPort::GetRole");
|
|
1897 |
|
|
1898 |
aRole = iRole;
|
|
1899 |
|
|
1900 |
return KErrNone;
|
|
1901 |
}
|
|
1902 |
|
|
1903 |
// ---------------------------------------------------------
|
|
1904 |
// CDpDataPort::ActivePipeHandle
|
|
1905 |
// This method gives pipe handle to enabled or disabled pipe.
|
|
1906 |
// ---------------------------------------------------------
|
|
1907 |
//
|
|
1908 |
TInt CDpDataPort::ActivePipeHandle(
|
|
1909 |
TUint8& aHandle )
|
|
1910 |
{
|
|
1911 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_ACTIVEPIPEHANDLE, "CDpDataPort::ActivePipeHandle" );
|
|
1912 |
LOGM(" CDpDataPort::ActivePipeHandle");
|
|
1913 |
|
|
1914 |
TInt ret( KErrNone );
|
|
1915 |
|
|
1916 |
CDpPif::TDpPipeState pipeState = iPifDcs->PipeState();
|
|
1917 |
if ( CDpPif::EDpPipeEnabled == pipeState ||
|
|
1918 |
CDpPif::EDpPipeDisabled == pipeState )
|
|
1919 |
{
|
|
1920 |
aHandle = iPifDcs->PipeHandle();
|
|
1921 |
}
|
|
1922 |
else
|
|
1923 |
{
|
|
1924 |
aHandle = 0;
|
|
1925 |
|
|
1926 |
LOG1(" ERROR, CDpDataPort::ActivePipeHandle, Invalid pipe state: %d.",
|
|
1927 |
pipeState);
|
|
1928 |
OstTrace1( TRACE_NORMAL, DUP1_CDPDATAPORT_ACTIVEPIPEHANDLE, "ERROR, CDpDataPort::ActivePipeHandle, Invalid pipe state: %{TDpPipeState}", pipeState );
|
|
1929 |
|
|
1930 |
ret = KErrGeneral;
|
|
1931 |
}
|
|
1932 |
return ret;
|
|
1933 |
}
|
|
1934 |
|
|
1935 |
// ---------------------------------------------------------
|
|
1936 |
// CDpDataPort::SetRxBreakBytes
|
|
1937 |
// This method sets amount bytes to be sent before pending
|
|
1938 |
// break.
|
|
1939 |
// ---------------------------------------------------------
|
|
1940 |
//
|
|
1941 |
TInt CDpDataPort::SetRxBreakBytes(
|
|
1942 |
const TInt aBreakBytes )
|
|
1943 |
{
|
|
1944 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_SETRXBREAKBYTES, "CDpDataPort::SetRxBreakBytes" );
|
|
1945 |
LOGM(" CDpDataPort::SetRxBreakBytes");
|
|
1946 |
DEBUG( "CDpDataPort::SetRxBreakBytes()" )
|
|
1947 |
|
|
1948 |
iRx2Dte->SetBreakBytes( aBreakBytes );
|
|
1949 |
|
|
1950 |
return KErrNone;
|
|
1951 |
}
|
|
1952 |
|
|
1953 |
#ifdef USE_LOGGER
|
|
1954 |
// ---------------------------------------------------------
|
|
1955 |
// CDpDataPort::WriteStateLog
|
|
1956 |
// This method writes a state log.
|
|
1957 |
// ---------------------------------------------------------
|
|
1958 |
//
|
|
1959 |
void CDpDataPort::WriteStateLog()
|
|
1960 |
{
|
|
1961 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_WRITESTATELOG, "CDpDataPort::WriteStateLog" );
|
|
1962 |
LOG(" CDpDataPort::WriteStateLog");
|
|
1963 |
#ifdef USE_BYTE_COUNT_DEBUG
|
|
1964 |
|
|
1965 |
TInt rxlen( iRx->UsedBytes() );
|
|
1966 |
TInt txlen( iTx->UsedBytes() );
|
|
1967 |
|
|
1968 |
#ifdef USE_FILE_DEBUG
|
|
1969 |
|
|
1970 |
OstTrace0( TRACE_DETAILED, DUP1_CDPDATAPORT_WRITESTATELOG, "CDpDataPort:: --- DATA LOG: ----------------------------------------------" );
|
|
1971 |
OstTraceExt2( TRACE_DETAILED, DUP2_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugDteWrites= %d iDebugBytesFromDte= %d", iDebugDteWrites, iDebugBytesFromDte );
|
|
1972 |
OstTraceExt2( TRACE_DETAILED, DUP3_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugDteReads= %d iDebugBytesToDte= %d", iDebugDteReads, iDebugBytesToDte );
|
|
1973 |
OstTraceExt2( TRACE_DETAILED, DUP4_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugPnWrites= %d iDebugBytesToPn= %d", iDebugPnWrites, iDebugBytesToPn );
|
|
1974 |
OstTraceExt2( TRACE_DETAILED, DUP5_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugPnReads= %d iDebugBytesFromPn= %d", iDebugPnReads, iDebugBytesFromPn );
|
|
1975 |
OstTrace0( TRACE_DETAILED, DUP6_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|" );
|
|
1976 |
OstTraceExt2( TRACE_DETAILED, DUP7_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|rxlen= %d txlen= %d", rxlen, txlen );
|
|
1977 |
OstTrace0( TRACE_DETAILED, DUP8_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|" );
|
|
1978 |
OstTraceExt2( TRACE_DETAILED, DUP9_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iRx->iHead= %d iRx->iTail= %d", iRx->iHead, iRx->iTail );
|
|
1979 |
OstTraceExt2( TRACE_DETAILED, DUP10_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iRx->iTailWrp= %d iRx->iEnd= %d", iRx->iTailWhenWrappedAround, iRx->iEnd );
|
|
1980 |
OstTraceExt2( TRACE_DETAILED, DUP11_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iTx->iHead= %d iTx->iTail= %d", iTx->iHead, iTx->iTail );
|
|
1981 |
OstTraceExt2( TRACE_DETAILED, DUP12_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iTx->iTailWrp= %d iTx->iEnd= %d", iTx->iTailWhenWrappedAround, iTx->iEnd );
|
|
1982 |
OstTrace0( TRACE_DETAILED, DUP13_CDPDATAPORT_WRITESTATELOG, "CDpDataPort:: ------------------------------------------------------------" );
|
|
1983 |
|
|
1984 |
BDEBUG("\n DATA LOG:------------------------------------------------");
|
|
1985 |
BFDEBUG2("|iDebugDteWrites= %d\tiDebugBytesFromDte= %d",
|
|
1986 |
iDebugDteWrites, iDebugBytesFromDte );
|
|
1987 |
BFDEBUG2("|iDebugDteReads= %d\tiDebugBytesToDte= %d",
|
|
1988 |
iDebugDteReads, iDebugBytesToDte );
|
|
1989 |
|
|
1990 |
BFDEBUG2("|iDebugPnWrites= %d\tiDebugBytesToPn= %d",
|
|
1991 |
iDebugPnWrites, iDebugBytesToPn );
|
|
1992 |
BFDEBUG2("|iDebugPnReads= %d\tiDebugBytesFromPn= %d",
|
|
1993 |
iDebugPnReads, iDebugBytesFromPn );
|
|
1994 |
BDEBUG("|");
|
|
1995 |
BFDEBUG2("|rxlen= %d\ttxlen= %d", rxlen, txlen );
|
|
1996 |
BDEBUG("|");
|
|
1997 |
BFDEBUG2("|iRx->iHead= %d\tiRx->iTail= %d", iRx->iHead, iRx->iTail );
|
|
1998 |
BFDEBUG2("|iRx->iTailWrp= %d\tiRx->iEnd= %d",
|
|
1999 |
iRx->iTailWhenWrappedAround, iRx->iEnd );
|
|
2000 |
|
|
2001 |
BFDEBUG2("|iTx->iHead= %d\tiTx->iTail= %d", iTx->iHead, iTx->iTail );
|
|
2002 |
BFDEBUG2("|iTx->iTailWrp= %d\tiTx->iEnd= %d",
|
|
2003 |
iTx->iTailWhenWrappedAround, iTx->iEnd );
|
|
2004 |
|
|
2005 |
BDEBUG(" ------------------------------------------------------------");
|
|
2006 |
|
|
2007 |
#endif // USE_FILE_DEBUG
|
|
2008 |
|
|
2009 |
#if ( defined USE_SERIAL_DEBUG || defined USE_TRUST_DEBUG )
|
|
2010 |
|
|
2011 |
OstTrace0( TRACE_DETAILED, DUP14_CDPDATAPORT_WRITESTATELOG, "CDpDataPort:: --- DATA LOG: ----------------------------------------------" );
|
|
2012 |
OstTrace1( TRACE_DETAILED, DUP15_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugDteWrites= %d", iDebugDteWrites );
|
|
2013 |
OstTrace1( TRACE_DETAILED, DUP16_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugBytesFromDte= %d", iDebugBytesFromDte );
|
|
2014 |
OstTrace1( TRACE_DETAILED, DUP17_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugDteReads= %d", iDebugDteReads );
|
|
2015 |
OstTrace1( TRACE_DETAILED, DUP18_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugBytesToDte= %d", iDebugBytesToDte );
|
|
2016 |
OstTrace1( TRACE_DETAILED, DUP19_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugPnWrites= %d", iDebugPnWrites );
|
|
2017 |
OstTrace1( TRACE_DETAILED, DUP20_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugBytesToPn= %d", iDebugBytesToPn );
|
|
2018 |
OstTrace1( TRACE_DETAILED, DUP21_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugPnReads= %d", iDebugPnReads );
|
|
2019 |
OstTrace1( TRACE_DETAILED, DUP22_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|iDebugBytesFromPn= %d", iDebugBytesFromPn );
|
|
2020 |
OstTrace0( TRACE_DETAILED, DUP23_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|" );
|
|
2021 |
OstTrace1( TRACE_DETAILED, DUP24_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|rxlen= %d", rxlen );
|
|
2022 |
OstTrace1( TRACE_DETAILED, DUP25_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|txlen= %d", txlen );
|
|
2023 |
OstTrace0( TRACE_DETAILED, DUP26_CDPDATAPORT_WRITESTATELOG, "CDpDataPort::|" );
|
|
2024 |
OstTrace0( TRACE_DETAILED, DUP27_CDPDATAPORT_WRITESTATELOG, "CDpDataPort:: ------------------------------------------------------------" );
|
|
2025 |
|
|
2026 |
RDEBUG("\n DATA LOG:------------------------------------------------");
|
|
2027 |
FRDEBUG("|iDebugDteWrites= %d", iDebugDteWrites );
|
|
2028 |
FRDEBUG("|iDebugBytesFromDte= %d", iDebugBytesFromDte );
|
|
2029 |
FRDEBUG("|iDebugDteReads= %d", iDebugDteReads );
|
|
2030 |
FRDEBUG("|iDebugBytesToDte= %d", iDebugBytesToDte );
|
|
2031 |
FRDEBUG("|iDebugPnWrites= %d", iDebugPnWrites );
|
|
2032 |
FRDEBUG("|iDebugBytesToPn= %d", iDebugBytesToPn );
|
|
2033 |
FRDEBUG("|iDebugPnReads= %d", iDebugPnReads );
|
|
2034 |
FRDEBUG("|iDebugBytesFromPn= %d", iDebugBytesFromPn );
|
|
2035 |
|
|
2036 |
RDEBUG("|");
|
|
2037 |
FRDEBUG("|rxlen= %d", rxlen );
|
|
2038 |
FRDEBUG("|txlen= %d", txlen );
|
|
2039 |
RDEBUG("|");
|
|
2040 |
RDEBUG(" ------------------------------------------------------------");
|
|
2041 |
|
|
2042 |
#endif // USE_SERIAL_DEBUG || USE_TRUST_DEBUG
|
|
2043 |
|
|
2044 |
#endif // USE_BYTE_COUNT_DEBUG
|
|
2045 |
}
|
|
2046 |
#endif // USE_LOGGER
|
|
2047 |
|
|
2048 |
|
|
2049 |
#ifdef USE_FILE_SERIAL_TRUST_DEBUG
|
|
2050 |
// ---------------------------------------------------------
|
|
2051 |
// CDpDataPort::DebugBytesFromDte
|
|
2052 |
// This method stores amount of bytes received from DTE.
|
|
2053 |
// ---------------------------------------------------------
|
|
2054 |
//
|
|
2055 |
void CDpDataPort::DebugBytesFromDte(
|
|
2056 |
const TInt aLength )
|
|
2057 |
{
|
|
2058 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DEBUGBYTESFROMDTE, "CDpDataPort::DebugBytesFromDte" );
|
|
2059 |
LOG(" CDpDataPort::DebugBytesFromDte");
|
|
2060 |
|
|
2061 |
// Amount of bytes is increased by this length
|
|
2062 |
iDebugBytesFromDte += aLength;
|
|
2063 |
iDebugDteWrites++;
|
|
2064 |
}
|
|
2065 |
|
|
2066 |
// ---------------------------------------------------------
|
|
2067 |
// CDpDataPort::DebugBytesFromPn
|
|
2068 |
// This method stores amount of bytes received from IsaApi
|
|
2069 |
// (DCS).
|
|
2070 |
// ---------------------------------------------------------
|
|
2071 |
//
|
|
2072 |
void CDpDataPort::DebugBytesFromPn(
|
|
2073 |
const TInt aLength )
|
|
2074 |
{
|
|
2075 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DEBUGBYTESFROMPN, "CDpDataPort::DebugBytesFromPn" );
|
|
2076 |
LOG(" CDpDataPort::DebugBytesFromPn");
|
|
2077 |
|
|
2078 |
// Amount of bytes is increased by this length
|
|
2079 |
iDebugBytesFromPn += aLength;
|
|
2080 |
iDebugPnReads++;
|
|
2081 |
}
|
|
2082 |
|
|
2083 |
// ---------------------------------------------------------
|
|
2084 |
// CDpDataPort::DebugBytesToDte
|
|
2085 |
// This method stores amount of bytes sent to DTE.
|
|
2086 |
// ---------------------------------------------------------
|
|
2087 |
//
|
|
2088 |
void CDpDataPort::DebugBytesToDte(
|
|
2089 |
const TInt aLength )
|
|
2090 |
{
|
|
2091 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DEBUGBYTESTODTE, "CDpDataPort::DebugBytesToDte" );
|
|
2092 |
LOG(" CDpDataPort::DebugBytesToDte");
|
|
2093 |
|
|
2094 |
// Amount of bytes is increased by this length
|
|
2095 |
iDebugBytesToDte += aLength;
|
|
2096 |
iDebugDteReads++;
|
|
2097 |
}
|
|
2098 |
|
|
2099 |
// ---------------------------------------------------------
|
|
2100 |
// CDpDataPort::DebugBytesToPn
|
|
2101 |
// This method stores amount of bytes sent to IsaApi (DCS).
|
|
2102 |
// (other items were commented in a header).
|
|
2103 |
// Status : Draft/Proposal/Approved
|
|
2104 |
// ---------------------------------------------------------
|
|
2105 |
//
|
|
2106 |
void CDpDataPort::DebugBytesToPn(
|
|
2107 |
const TInt aLength )
|
|
2108 |
{
|
|
2109 |
OstTrace0( TRACE_NORMAL, CDPDATAPORT_DEBUGBYTESTOPN, "CDpDataPort::DebugBytesToPn" );
|
|
2110 |
LOG(" CDpDataPort::DebugBytesToPn");
|
|
2111 |
|
|
2112 |
// Amount of bytes is increased by this length
|
|
2113 |
iDebugBytesToPn += aLength;
|
|
2114 |
iDebugPnWrites++;
|
|
2115 |
}
|
|
2116 |
#endif // USE_FILE_SERIAL_TRUST_DEBUG
|
|
2117 |
|
|
2118 |
|
|
2119 |
// ================= OTHER EXPORTED FUNCTIONS ==============
|
|
2120 |
|
|
2121 |
extern "C"
|
|
2122 |
{
|
|
2123 |
IMPORT_C CSerial * LibEntry(); // Force export
|
|
2124 |
}
|
|
2125 |
|
|
2126 |
// ---------------------------------------------------------
|
|
2127 |
// LibEntry
|
|
2128 |
// This method implements main entry point of the library.
|
|
2129 |
// Returns: CSerial*: CSerial Pointer to DataPort factory
|
|
2130 |
// ---------------------------------------------------------
|
|
2131 |
EXPORT_C CSerial * LibEntry()
|
|
2132 |
{
|
|
2133 |
OstTrace0( TRACE_NORMAL, LIBENTRY, "LibEntry" );
|
|
2134 |
CDpDataPortFactory* dataPortFactory = NULL;
|
|
2135 |
|
|
2136 |
TRAPD( ret, dataPortFactory = CDpDataPortFactory::NewL() );
|
|
2137 |
|
|
2138 |
if ( KErrNone != ret )
|
|
2139 |
{
|
|
2140 |
dataPortFactory = NULL;
|
|
2141 |
}
|
|
2142 |
//no else
|
|
2143 |
|
|
2144 |
return dataPortFactory;
|
|
2145 |
}
|
|
2146 |
|
|
2147 |
// End of File
|
|
2148 |
|