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 "dptermdetect.h" // terminator bytes detection
|
|
24 |
#include "dpstd.h" // fault codes etc.
|
|
25 |
#include "dpdataconfig.h" // configuration store
|
|
26 |
#include "dplog.h" // dataport logging
|
|
27 |
#include "osttracedefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "dptermdetecttraces.h"
|
|
30 |
#endif
|
|
31 |
|
|
32 |
// EXTERNAL DATA STRUCTURES
|
|
33 |
// none
|
|
34 |
|
|
35 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
36 |
// none
|
|
37 |
|
|
38 |
// CONSTANTS
|
|
39 |
// none
|
|
40 |
|
|
41 |
// MACROS
|
|
42 |
// none
|
|
43 |
|
|
44 |
// LOCAL CONSTANTS AND MACROS
|
|
45 |
// none
|
|
46 |
|
|
47 |
// MODULE DATA STRUCTURES
|
|
48 |
// none
|
|
49 |
|
|
50 |
// LOCAL FUNCTION PROTOTYPES
|
|
51 |
// none
|
|
52 |
|
|
53 |
// FORWARD DECLARATIONS
|
|
54 |
// none
|
|
55 |
|
|
56 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
57 |
|
|
58 |
// none
|
|
59 |
|
|
60 |
|
|
61 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// CDpTermDetect::CDpTermDetect
|
|
65 |
// C++ default constructor can NOT contain any code, that
|
|
66 |
// might leave.
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CDpTermDetect::CDpTermDetect(
|
|
70 |
CDpDataConfig& aDataConfig ) :
|
|
71 |
iDataConfig( aDataConfig )
|
|
72 |
{
|
|
73 |
OstTrace0( TRACE_NORMAL, CDPTERMDETECT_CDPTERMDETECT, "CDpTermDetect::CDpTermDetect" );
|
|
74 |
LOGM("CDpTermDetect::CDpTermDetect");
|
|
75 |
}
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// CDpTermDetect::~CDpTermDetect
|
|
79 |
// Destructor
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
CDpTermDetect::~CDpTermDetect()
|
|
83 |
{
|
|
84 |
OstTrace0( TRACE_NORMAL, DUP1_CDPTERMDETECT_CDPTERMDETECT, "CDpTermDetect::~CDpTermDetect" );
|
|
85 |
LOGM("CDpTermDetect::~CDpTermDetect");
|
|
86 |
DEBUG( "CDpTermDetect::~CDpTermDetect" )
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CDpTermDetect::Scan
|
|
91 |
// This methods scans terminator characters from descriptor.
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
TInt CDpTermDetect::Scan(
|
|
95 |
const TPtr8& aDes )
|
|
96 |
{
|
|
97 |
OstTrace0( TRACE_NORMAL, CDPTERMDETECT_SCAN, "CDpTermDetect::Scan" );
|
|
98 |
LOGM("CDpTermDetect::Scan");
|
|
99 |
FDEBUG("CDpTermDetect::Scan %d", 0)
|
|
100 |
|
|
101 |
TInt termCount( iDataConfig.TerminatorCount() );
|
|
102 |
TInt ret( KErrNotFound );
|
|
103 |
TBool isTerminator (EFalse );
|
|
104 |
|
|
105 |
// The C32 client has set terminator array's characters.
|
|
106 |
// Client may change terminators during data receive.
|
|
107 |
// --> we must ask it from DataConfig.
|
|
108 |
|
|
109 |
// Terminator array's terminator characters are scanned sequentially.
|
|
110 |
for ( TInt j( 0 ); j < termCount; j++ ) //termCount is max 4
|
|
111 |
{
|
|
112 |
TBuf8<1> terminator;
|
|
113 |
terminator.Append(iDataConfig.Terminator(j));
|
|
114 |
|
|
115 |
ret = aDes.Find( terminator );
|
|
116 |
|
|
117 |
if ( 0 <= ret )
|
|
118 |
{
|
|
119 |
isTerminator = ETrue;
|
|
120 |
break;
|
|
121 |
}
|
|
122 |
//no else
|
|
123 |
}
|
|
124 |
|
|
125 |
if ( !isTerminator )
|
|
126 |
{
|
|
127 |
ret = KErrNotFound;
|
|
128 |
}
|
|
129 |
//no else
|
|
130 |
|
|
131 |
return ret;
|
|
132 |
}
|
|
133 |
|
|
134 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
135 |
|
|
136 |
// none
|
|
137 |
|
|
138 |
|
|
139 |
// End of File
|