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 "dpdataport.h" // dataport main and c32 interface
|
|
23 |
#include "dppn2rx.h" // moves data from isc api to rx buffer
|
|
24 |
#include "dppif.h" // pipe interface (pif)
|
|
25 |
#include "dpflowctrl.h" // flow control handling
|
|
26 |
#include "dpdataconfig.h" // configuration store
|
|
27 |
#include "dpparityhandler.h" // parity bit handling in 7-bit data mode
|
|
28 |
#include "dplog.h" // dataport logging
|
|
29 |
#include "osttracedefinitions.h"
|
|
30 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
31 |
#include "dppn2rxtraces.h"
|
|
32 |
#endif
|
|
33 |
|
|
34 |
|
|
35 |
// EXTERNAL DATA STRUCTURES
|
|
36 |
// none
|
|
37 |
|
|
38 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
39 |
// none
|
|
40 |
|
|
41 |
// CONSTANTS
|
|
42 |
// none
|
|
43 |
|
|
44 |
// MACROS
|
|
45 |
// none
|
|
46 |
|
|
47 |
// LOCAL CONSTANTS AND MACROS
|
|
48 |
// none
|
|
49 |
|
|
50 |
// MODULE DATA STRUCTURES
|
|
51 |
// none
|
|
52 |
|
|
53 |
// LOCAL FUNCTION PROTOTYPES
|
|
54 |
// none
|
|
55 |
|
|
56 |
// FORWARD DECLARATIONS
|
|
57 |
// none
|
|
58 |
|
|
59 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
60 |
// none
|
|
61 |
|
|
62 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// CDpPn2Rx::CDpPn2Rx
|
|
66 |
// C++ default constructor can NOT contain any code, that
|
|
67 |
// might leave.
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CDpPn2Rx::CDpPn2Rx(
|
|
71 |
CDpDataPort& aDataPort ) :
|
|
72 |
CActive( KDpPn2RxPriority ),
|
|
73 |
iDataPort( aDataPort ),
|
|
74 |
iBufferRx( iDataPort.Rx() ),
|
|
75 |
iPifDcs( iDataPort.Pif() ),
|
|
76 |
iDataConfig( iDataPort.DataConfig() ),
|
|
77 |
iFlowCtrl( iDataPort.FlowCtrl() ),
|
|
78 |
iParityHandler( iDataPort.ParityHandler() ),
|
|
79 |
iRx( 0, 0 ),
|
|
80 |
iState( EElementWait ),
|
|
81 |
iInBufHasDataNotify( EFalse ),
|
|
82 |
iRequestActive( EFalse ),
|
|
83 |
iRole( MDpDataClient::EDbDataClientWriter )
|
|
84 |
{
|
|
85 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_CDPPN2RX, "CDpPn2Rx::CDpPn2Rx" );
|
|
86 |
LOGM(" CDpPn2Rx::CDpPn2Rx");
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CDpPn2Rx::ConstructL
|
|
91 |
// Symbian 2nd phase constructor can leave.
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CDpPn2Rx::ConstructL()
|
|
95 |
{
|
|
96 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_CONSTRUCTL, "CDpPn2Rx::ConstructL" );
|
|
97 |
LOGM("CDpPn2Rx::ConstructL");
|
|
98 |
|
|
99 |
// initialise inner observer object
|
|
100 |
iDpPn2RxObserver.Init( this );
|
|
101 |
// register to PIF as observer
|
|
102 |
iPifDcs.Attach( iDpPn2RxObserver );
|
|
103 |
// If registering fails => can't do nothing here => must leave
|
|
104 |
User::LeaveIfError( iBufferRx.RegisterDataClient( *this ) );
|
|
105 |
|
|
106 |
CActiveScheduler::Add( this );
|
|
107 |
}
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// CDpPn2Rx::NewL
|
|
111 |
// Two-phased constructor.
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
CDpPn2Rx* CDpPn2Rx::NewL(
|
|
115 |
CDpDataPort& aDataPort )
|
|
116 |
{
|
|
117 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_NEWL, "CDpPn2Rx::NewL" );
|
|
118 |
LOGM("CDpPn2Rx::NewL");
|
|
119 |
|
|
120 |
CDpPn2Rx* self = new (ELeave) CDpPn2Rx( aDataPort );
|
|
121 |
|
|
122 |
CleanupStack::PushL( self );
|
|
123 |
self->ConstructL();
|
|
124 |
CleanupStack::Pop( self );
|
|
125 |
|
|
126 |
return self;
|
|
127 |
}
|
|
128 |
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
// CDpPn2Rx::~CDpPn2Rx
|
|
131 |
// Destructor
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
CDpPn2Rx::~CDpPn2Rx()
|
|
135 |
{
|
|
136 |
OstTrace0( TRACE_NORMAL, DUP1_CDPPN2RX_CDPPN2RX, "CDpPn2Rx::~CDpPn2Rx" );
|
|
137 |
LOGM("CDpPn2Rx::~CDpPn2Rx");
|
|
138 |
// unregister from PIF as observer
|
|
139 |
iPifDcs.Detach( iDpPn2RxObserver );
|
|
140 |
}
|
|
141 |
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
// CDpPn2Rx::RunL
|
|
144 |
// This active object is signalled by Isc Api.
|
|
145 |
// We will renew read to Isc Api.
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void CDpPn2Rx::RunL()
|
|
149 |
{
|
|
150 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_RUNL, "CDpPn2Rx::RunL" );
|
|
151 |
OstTraceExt2( TRACE_NORMAL, DUP1_CDPPN2RX_RUNL, "CDpPn2Rx:: Port: %u, Status: %d", iDataPort.PortUnit(), iStatus.Int() );
|
|
152 |
|
|
153 |
LOGM2("CDpPn2Rx::RunL - Port %d, Status: %d ",
|
|
154 |
iDataPort.PortUnit(), iStatus.Int() );
|
|
155 |
|
|
156 |
iRequestActive = EFalse;
|
|
157 |
User::LeaveIfError( Read() );
|
|
158 |
|
|
159 |
// don't set iStatus nor set_active here as it is better done in functions
|
|
160 |
}
|
|
161 |
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
// CDpPn2Rx::RunError
|
|
164 |
// Leave in RunL() is handled here. Error code is returned,
|
|
165 |
// when internal error has occured.
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
TInt CDpPn2Rx::RunError(
|
|
169 |
TInt aError )
|
|
170 |
{
|
|
171 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_RUNERROR, "CDpPn2Rx::RunError" );
|
|
172 |
OstTraceExt2( TRACE_NORMAL, DUP1_CDPPN2RX_RUNERROR, "CDpPn2Rx:: Port: %u, error code: %d", iDataPort.PortUnit(), aError );
|
|
173 |
|
|
174 |
LOGM2("CDpPn2Rx::RunError - Port %d, error code: %d",
|
|
175 |
iDataPort.PortUnit(), aError );
|
|
176 |
|
|
177 |
return aError;
|
|
178 |
}
|
|
179 |
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
// CDpPn2Rx::DoCancel
|
|
182 |
// Cancels this active object and cancels pipe receive.
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
void CDpPn2Rx::DoCancel()
|
|
186 |
{
|
|
187 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_DOCANCEL, "CDpPn2Rx::DoCancel" );
|
|
188 |
LOGM("CDpPn2Rx::DoCancel");
|
|
189 |
|
|
190 |
switch ( iState )
|
|
191 |
{
|
|
192 |
case EDpReadWait:
|
|
193 |
{
|
|
194 |
if ( iRequestActive )
|
|
195 |
{
|
|
196 |
// cancel pipe
|
|
197 |
iDataPort.ISAHandle().DataReceiveCancel();
|
|
198 |
|
|
199 |
LOG(" CDpPn2Rx::DoCancel, Rx element release");
|
|
200 |
OstTrace0( TRACE_NORMAL, DUP1_CDPPN2RX_DOCANCEL, "CDpPn2Rx:: Rx element release" );
|
|
201 |
|
|
202 |
TInt ret = iBufferRx.WriteElement().Release( iRx.Length() );
|
|
203 |
|
|
204 |
if ( KErrNone == ret )
|
|
205 |
{
|
|
206 |
#ifdef USE_FILE_SERIAL_TRUST_DEBUG
|
|
207 |
iDataPort.DebugBytesFromPn( iRx.Length() );
|
|
208 |
#endif
|
|
209 |
if ( 0 < iRx.Length() )
|
|
210 |
{
|
|
211 |
// 7-bit data extract parity bits
|
|
212 |
if ( EData7 == iDataConfig.DataBits() )
|
|
213 |
{
|
|
214 |
iParityHandler.ExtractParityBits( iRx );
|
|
215 |
}
|
|
216 |
//no else
|
|
217 |
|
|
218 |
if ( iDataPort.IsRx2DteReadPending() )
|
|
219 |
{
|
|
220 |
// Signal RX2DTE
|
|
221 |
iDataPort.SignalRx2Dte();
|
|
222 |
}
|
|
223 |
//no else
|
|
224 |
|
|
225 |
// New data is available. is client interested about that
|
|
226 |
if ( iInBufHasDataNotify )
|
|
227 |
{
|
|
228 |
// We should notify client
|
|
229 |
iInBufHasDataNotify = EFalse;
|
|
230 |
iDataPort.NotifyDataAvailableCompleted( KErrNone );
|
|
231 |
}
|
|
232 |
//no else
|
|
233 |
}
|
|
234 |
//no else
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
|
238 |
// Element release couldn't be done. Can't leave here.
|
|
239 |
// Element remains reserved and something has gone totally
|
|
240 |
// wrong before release.
|
|
241 |
LOG(" ERROR, CDpPn2Rx::DoCancel, Element release failed");
|
|
242 |
OstTrace0( TRACE_NORMAL, DUP2_CDPPN2RX_DOCANCEL, "CDpPn2Rx:: Element release failed" );
|
|
243 |
}
|
|
244 |
//no else
|
|
245 |
|
|
246 |
// reset the state
|
|
247 |
iState = EDefault;
|
|
248 |
iRequestActive = EFalse;
|
|
249 |
}
|
|
250 |
//no else
|
|
251 |
break;
|
|
252 |
}
|
|
253 |
case EElementWait:
|
|
254 |
{
|
|
255 |
// Do not complete request if pipe is closed
|
|
256 |
if ( CDpPif::EDpPipeDisabled != iPifDcs.PipeState() &&
|
|
257 |
CDpPif::EDpPipeDisconnected != iPifDcs.PipeState() )
|
|
258 |
{
|
|
259 |
// do the required signaling
|
|
260 |
if ( iStatus == KRequestPending )
|
|
261 |
{
|
|
262 |
if ( iRequestActive )
|
|
263 |
{
|
|
264 |
// do the required signaling
|
|
265 |
iRequestActive = EFalse;
|
|
266 |
iState = EDefault;
|
|
267 |
TRequestStatus* s = &iStatus;
|
|
268 |
User::RequestComplete( s, KErrCancel );
|
|
269 |
}
|
|
270 |
//no else
|
|
271 |
}
|
|
272 |
//no else
|
|
273 |
}
|
|
274 |
//no else
|
|
275 |
break;
|
|
276 |
}
|
|
277 |
case EDefault:
|
|
278 |
{
|
|
279 |
break;
|
|
280 |
}
|
|
281 |
default:
|
|
282 |
{
|
|
283 |
LOG(" ERROR, CDpPn2Rx::DoCancel, Unknown iState");
|
|
284 |
OstTrace0( TRACE_NORMAL, DUP3_CDPPN2RX_DOCANCEL, "ERROR, CDpPn2Rx::DoCancel, Unknown iState" );
|
|
285 |
break;
|
|
286 |
}
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
// CDpPn2Rx::Read
|
|
292 |
// Reserves space from rx buffer and makes new PipeReceive
|
|
293 |
// to Isc Api. Checks if flow control high water mark is reached.
|
|
294 |
// Extracts paritybits if 7-bit data.Signals Rx2Dte.
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
//
|
|
297 |
TInt CDpPn2Rx::Read()
|
|
298 |
{
|
|
299 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_READ, "CDpPn2Rx::Read" );
|
|
300 |
OstTrace1( TRACE_NORMAL, DUP1_CDPPN2RX_READ, "CDpPn2Rx::Read %x", &iDataPort );
|
|
301 |
OstTraceExt2( TRACE_NORMAL, DUP2_CDPPN2RX_READ, "CDpPn2Rx:: (Read from ISC) - Port: %u, iRx.Length: %d", iDataPort.PortUnit(), iRx.Length() );
|
|
302 |
|
|
303 |
LOGM1("CDpPn2Rx::Read %x", &iDataPort);
|
|
304 |
LOGM2("CDpPn2Rx::Read (Read from ISC) - Port %d, iRx.Length: %d",
|
|
305 |
iDataPort.PortUnit(), iRx.Length() );
|
|
306 |
|
|
307 |
TInt ret( KErrNone );
|
|
308 |
|
|
309 |
// We've been listening pn_pipe
|
|
310 |
if ( EDpReadWait == iState )
|
|
311 |
{
|
|
312 |
LOGHEX(iRx, EFalse);
|
|
313 |
OstTraceExt1( TRACE_NORMAL, DUP10_CDPPN2RX_READ, "CDpPn2Rx:: RX = %s", iRx );
|
|
314 |
|
|
315 |
ret = iBufferRx.WriteElement().Release( iRx.Length() );
|
|
316 |
|
|
317 |
if ( KErrNone == ret )
|
|
318 |
{
|
|
319 |
#ifdef USE_FILE_SERIAL_TRUST_DEBUG
|
|
320 |
iDataPort.DebugBytesFromPn( iRx.Length() );
|
|
321 |
#endif
|
|
322 |
if ( 0 < iRx.Length() )
|
|
323 |
{
|
|
324 |
// 7-bit data extract parity bits
|
|
325 |
if ( EData7 == iDataConfig.DataBits() )
|
|
326 |
{
|
|
327 |
iParityHandler.ExtractParityBits( iRx );
|
|
328 |
}
|
|
329 |
//no else
|
|
330 |
|
|
331 |
if ( iDataPort.IsRx2DteReadPending() )
|
|
332 |
{
|
|
333 |
// Signal RX2DTE
|
|
334 |
iDataPort.SignalRx2Dte();
|
|
335 |
}
|
|
336 |
//no else
|
|
337 |
|
|
338 |
// New data is available. is client interested about that
|
|
339 |
if ( iInBufHasDataNotify )
|
|
340 |
{
|
|
341 |
// We should notify client
|
|
342 |
iInBufHasDataNotify = EFalse;
|
|
343 |
iDataPort.NotifyDataAvailableCompleted( KErrNone );
|
|
344 |
}
|
|
345 |
//no else
|
|
346 |
}
|
|
347 |
//no else
|
|
348 |
}
|
|
349 |
//no else
|
|
350 |
}
|
|
351 |
//no else
|
|
352 |
|
|
353 |
// Check pipe state
|
|
354 |
if ( KErrNone == ret && CDpPif::EDpPipeEnabled != iPifDcs.PipeState() )
|
|
355 |
{
|
|
356 |
ret = KErrNotReady;
|
|
357 |
}
|
|
358 |
else if ( KErrNone == ret )
|
|
359 |
{
|
|
360 |
// Try reserve element for writing
|
|
361 |
TPtr8 nullPtr( 0, 0 );
|
|
362 |
|
|
363 |
// Check if reserved buffer was too small
|
|
364 |
// => override MaxReservationSize for next read request.
|
|
365 |
if ( KErrNoMemory == iStatus.Int() &&
|
|
366 |
iLen > iBufferRx.MaxReservationSize() )
|
|
367 |
{
|
|
368 |
OstTrace0( TRACE_NORMAL, DUP4_CDPPN2RX_READ, "CDpPn2Rx::KErrNoMemory from ISC =>" );
|
|
369 |
OstTraceExt1( TRACE_NORMAL, DUP5_CDPPN2RX_READ, "CDpPn2Rx:: -- Try to read more than MaxReservationSize, %hu --", iLen );
|
|
370 |
|
|
371 |
LOG(" CDpPn2Rx::Read, KErrNoMemory from ISC =>");
|
|
372 |
LOG1(" -- Try to read more than MaxReservationSize, %d --", iLen );
|
|
373 |
|
|
374 |
ret = iBufferRx.WriteElement().Reserve(
|
|
375 |
iLen, iRx, nullPtr, ETrue );
|
|
376 |
// Set iLen to zero (required buffer lenght for read,
|
|
377 |
// received from ISC if buffer was too small)
|
|
378 |
iLen = 0;
|
|
379 |
}
|
|
380 |
else
|
|
381 |
{
|
|
382 |
ret = iBufferRx.WriteElement().Reserve(
|
|
383 |
iBufferRx.MaxReservationSize(), iRx, nullPtr );
|
|
384 |
}
|
|
385 |
|
|
386 |
// Is flowctrl off and rx "high watermark" reached
|
|
387 |
if ( EFlowControlOff == iFlowCtrl.FlowCtrlDcs2Dp() )
|
|
388 |
{
|
|
389 |
if ( IsHighWaterMarkReached() )
|
|
390 |
{
|
|
391 |
// Buffer is almost full set flowcontrol on
|
|
392 |
LOG(" CDpPn2Rx::Read, Rx High WaterMarkReached");
|
|
393 |
OstTrace0( TRACE_NORMAL, DUP6_CDPPN2RX_READ, "CDpPn2Rx:: Rx High WaterMark reached" );
|
|
394 |
|
|
395 |
iFlowCtrl.WaterMarkHighReached();
|
|
396 |
}
|
|
397 |
//no else
|
|
398 |
}
|
|
399 |
//no else
|
|
400 |
|
|
401 |
switch ( ret )
|
|
402 |
{
|
|
403 |
// Reservation successed
|
|
404 |
case KErrNone:
|
|
405 |
{
|
|
406 |
LOG1(" CDpPn2Rx::Read, ISAHandle Pipe Receive. iRx.MaxLength: %d",
|
|
407 |
iRx.MaxLength() );
|
|
408 |
OstTrace1( TRACE_NORMAL, DUP7_CDPPN2RX_READ, "CDpPn2Rx:: ISAHandle Pipe Receive. iRx.MaxLength: %d", iRx.MaxLength() );
|
|
409 |
|
|
410 |
// Set pipe receive
|
|
411 |
if ( !IsActive() )
|
|
412 |
{
|
|
413 |
iDataPort.ISAHandle().DataReceive( iStatus, iRx, iLen );
|
|
414 |
|
|
415 |
iRequestActive = ETrue;
|
|
416 |
// Change state
|
|
417 |
iState = EDpReadWait;
|
|
418 |
|
|
419 |
SetActive();
|
|
420 |
}
|
|
421 |
//no else
|
|
422 |
break;
|
|
423 |
}
|
|
424 |
// Reservation failed
|
|
425 |
case KErrNotReady:
|
|
426 |
{
|
|
427 |
LOG(" ERROR, CDpPn2Rx::Read, Element reservation failed (KErrNotReady).");
|
|
428 |
OstTrace0( TRACE_NORMAL, DUP8_CDPPN2RX_READ, "ERROR, CDpPn2Rx::Read, Element reservation failed (KErrNotReady)" );
|
|
429 |
|
|
430 |
// Change state
|
|
431 |
iState = EElementWait;
|
|
432 |
// Better done here
|
|
433 |
if ( !IsActive() )
|
|
434 |
{
|
|
435 |
iStatus = KRequestPending;
|
|
436 |
SetActive();
|
|
437 |
}
|
|
438 |
//no else
|
|
439 |
iRequestActive = ETrue;
|
|
440 |
|
|
441 |
ret = KErrNone;
|
|
442 |
|
|
443 |
break;
|
|
444 |
}
|
|
445 |
default:
|
|
446 |
{
|
|
447 |
// An error value returned
|
|
448 |
LOG1(" ERROR, CDpPn2Rx::Read, Fail to reserve Element, error code: %d",
|
|
449 |
ret );
|
|
450 |
OstTrace1( TRACE_NORMAL, DUP9_CDPPN2RX_READ, "CDpPn2Rx:: ERROR, CDpPn2Rx::Read, Fail to reserve Element, error code: %d", ret );
|
|
451 |
}
|
|
452 |
}
|
|
453 |
}
|
|
454 |
//no else
|
|
455 |
|
|
456 |
return ret;
|
|
457 |
}
|
|
458 |
|
|
459 |
// -----------------------------------------------------------------------------
|
|
460 |
// CDpPn2Rx::UpDate
|
|
461 |
// Pipe state has been changed.
|
|
462 |
// -----------------------------------------------------------------------------
|
|
463 |
//
|
|
464 |
void CDpPn2Rx::UpDate(
|
|
465 |
CDpSubject* /*aChangedSubject*/ )
|
|
466 |
{
|
|
467 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_UPDATE, "CDpPn2Rx::UpDate" );
|
|
468 |
LOGM("CDpPn2Rx::UpDate");
|
|
469 |
|
|
470 |
TInt r( KErrNone );
|
|
471 |
// DCS PIF state changed
|
|
472 |
switch ( iPifDcs.PipeState() )
|
|
473 |
{
|
|
474 |
case CDpPif::EDpPipeEnabled:
|
|
475 |
{
|
|
476 |
// start read but beware double read
|
|
477 |
if ( iState == EElementWait )
|
|
478 |
{
|
|
479 |
r = Read();
|
|
480 |
if ( r != KErrNone )
|
|
481 |
{
|
|
482 |
LOG(" ERROR, CDpPn2Rx::UpDate, Read() failed");
|
|
483 |
OstTrace0( TRACE_NORMAL, DUP1_CDPPN2RX_UPDATE, "ERROR, CDpPn2Rx::UpDate, Read() failed" );
|
|
484 |
}
|
|
485 |
//no else
|
|
486 |
}
|
|
487 |
//no else
|
|
488 |
break;
|
|
489 |
}
|
|
490 |
case CDpPif::EDpPipeDisabled: // Fall through
|
|
491 |
case CDpPif::EDpPipeDisconnected:
|
|
492 |
{
|
|
493 |
if ( IsActive() )
|
|
494 |
{
|
|
495 |
Cancel();
|
|
496 |
}
|
|
497 |
//no else
|
|
498 |
break;
|
|
499 |
}
|
|
500 |
default:
|
|
501 |
{
|
|
502 |
// Pipe is in state that is not regonized
|
|
503 |
LOG1(" ERROR, CDpPn2Rx::UpDate, Unrecognized pipe state: %d",
|
|
504 |
iPifDcs.PipeState() );
|
|
505 |
OstTraceExt1( TRACE_NORMAL, DUP2_CDPPN2RX_UPDATE, "ERROR, CDpPn2Rx::UpDate, Unrecognized pipe state: %s", iPifDcs.PipeState() );
|
|
506 |
|
|
507 |
Cancel();
|
|
508 |
break;
|
|
509 |
}
|
|
510 |
}
|
|
511 |
}
|
|
512 |
|
|
513 |
// -----------------------------------------------------------------------------
|
|
514 |
// CDpPn2Rx::ReleaseNotify
|
|
515 |
// This method signals ourselves.
|
|
516 |
// -----------------------------------------------------------------------------
|
|
517 |
//
|
|
518 |
void CDpPn2Rx::ReleaseNotify()
|
|
519 |
{
|
|
520 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_RELEASENOTIFY, "CDpPn2Rx::ReleaseNotify" );
|
|
521 |
LOGM("CDpPn2Rx::ReleaseNotify");
|
|
522 |
|
|
523 |
// This is done because receive data might me also active
|
|
524 |
DoCancel();
|
|
525 |
}
|
|
526 |
|
|
527 |
// -----------------------------------------------------------------------------
|
|
528 |
// CDpPn2Rx::FlushNotify
|
|
529 |
// This method notifies that buffer is flushed. Classes which have access
|
|
530 |
// to buffers are derived from this class. Derived class could override
|
|
531 |
// this method, otherwise this default method will be used.
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
void CDpPn2Rx::FlushNotify()
|
|
535 |
{
|
|
536 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_FLUSHNOTIFY, "CDpPn2Rx::FlushNotify" );
|
|
537 |
LOGM("CDpPn2Rx::FlushNotify()");
|
|
538 |
|
|
539 |
ReleaseNotify();
|
|
540 |
}
|
|
541 |
|
|
542 |
// -----------------------------------------------------------------------------
|
|
543 |
// CDpPn2Rx::Role
|
|
544 |
// This method gets the role (reader/writer) of data client.
|
|
545 |
// -----------------------------------------------------------------------------
|
|
546 |
//
|
|
547 |
TUint8 CDpPn2Rx::Role()
|
|
548 |
{
|
|
549 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_ROLE, "CDpPn2Rx::Role" );
|
|
550 |
|
|
551 |
return iRole;
|
|
552 |
}
|
|
553 |
|
|
554 |
// -----------------------------------------------------------------------------
|
|
555 |
// CDpPn2Rx::SetDataAvailableNotification
|
|
556 |
// Set flag that indicates are requested to notify the C32
|
|
557 |
// client, if there is data available in rx buffer.
|
|
558 |
// -----------------------------------------------------------------------------
|
|
559 |
//
|
|
560 |
TInt CDpPn2Rx::SetDataAvailableNotification(
|
|
561 |
const TBool aUsedOrNot )
|
|
562 |
{
|
|
563 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_SETDATAAVAILABLENOTIFICATION, "CDpPn2Rx::SetDataAvailableNotification" );
|
|
564 |
LOGM(" CDpPn2Rx::SetDataAvailableNotification");
|
|
565 |
|
|
566 |
iInBufHasDataNotify = aUsedOrNot;
|
|
567 |
return KErrNone;
|
|
568 |
}
|
|
569 |
|
|
570 |
// -----------------------------------------------------------------------------
|
|
571 |
// CDpPn2Rx::IsHighWaterMarkReached
|
|
572 |
// Is high water mark reached
|
|
573 |
// -----------------------------------------------------------------------------
|
|
574 |
//
|
|
575 |
TBool CDpPn2Rx::IsHighWaterMarkReached()
|
|
576 |
{
|
|
577 |
OstTrace0( TRACE_NORMAL, CDPPN2RX_ISHIGHWATERMARKREACHED, "CDpPn2Rx::IsHighWaterMarkReached" );
|
|
578 |
TBool waterMarkReached( EFalse );
|
|
579 |
|
|
580 |
if ( iBufferRx.UsedBytes() >= iDataConfig.WaterMarkHighSize( iBufferRx ) )
|
|
581 |
{
|
|
582 |
waterMarkReached = ETrue;
|
|
583 |
}
|
|
584 |
else
|
|
585 |
{
|
|
586 |
waterMarkReached = EFalse;
|
|
587 |
}
|
|
588 |
|
|
589 |
return waterMarkReached;
|
|
590 |
}
|
|
591 |
|
|
592 |
//==============================================================================
|
|
593 |
|
|
594 |
// -----------------------------------------------------------------------------
|
|
595 |
// CDpPn2Rx::CDpPn2RxObserver::Init
|
|
596 |
// This method initializes Pn2Rx observer.
|
|
597 |
// -----------------------------------------------------------------------------
|
|
598 |
//
|
|
599 |
void CDpPn2Rx::CDpPn2RxObserver::Init(
|
|
600 |
CDpPn2Rx* aDpPn2Rx )
|
|
601 |
{
|
|
602 |
iDpPn2Rx = aDpPn2Rx;
|
|
603 |
}
|
|
604 |
|
|
605 |
// -----------------------------------------------------------------------------
|
|
606 |
// CDpPn2Rx::CDpPn2RxObserver::UpDate
|
|
607 |
// This method updates Pn2Rx.
|
|
608 |
// -----------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
void CDpPn2Rx::CDpPn2RxObserver::UpDate(
|
|
611 |
CDpSubject* aChangedSubject )
|
|
612 |
{
|
|
613 |
LOGM("CDpPn2Rx::CDpPn2RxObserver::UpDate");
|
|
614 |
|
|
615 |
if ( iDpPn2Rx )
|
|
616 |
{
|
|
617 |
iDpPn2Rx->UpDate( aChangedSubject );
|
|
618 |
}
|
|
619 |
//no else
|
|
620 |
}
|
|
621 |
|
|
622 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
623 |
// none
|
|
624 |
|
|
625 |
// End of File
|