author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// @file testinterfacebase.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include "testdevicebase.h" |
|
20 |
#include "testinterfacebase.h" |
|
21 |
#include "testinterfacesettingbase.h" |
|
22 |
#include "testdebug.h" |
|
23 |
#include "controltransferrequests.h" |
|
24 |
#include "endpointwriter.h" |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#include "TestInterfaceBaseTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
#endif |
0 | 29 |
|
30 |
||
31 |
namespace NUnitTesting_USBDI |
|
32 |
{ |
|
33 |
||
34 |
||
35 |
CInterfaceBase::CInterfaceBase(RUsbTestDevice& aTestDevice,const TDesC16& aName) |
|
36 |
: iDevice(aTestDevice), |
|
37 |
iInterfaceName(aName), |
|
38 |
iCurrentAlternateInterfaceSetting(0) // The default alternate interface setting will be zero when opened |
|
39 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
OstTraceFunctionEntryExt( CINTERFACEBASE_CINTERFACEBASE_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
OstTraceFunctionExit1( CINTERFACEBASE_CINTERFACEBASE_EXIT, this ); |
0 | 42 |
} |
43 |
||
44 |
CInterfaceBase::~CInterfaceBase() |
|
45 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
OstTraceFunctionEntry1( CINTERFACEBASE_CINTERFACEBASE_ENTRY_DUP01, this ); |
0 | 47 |
|
48 |
delete iAuxBuffer; |
|
49 |
delete iStallWatcher; |
|
50 |
delete iSelectionWatcher; |
|
51 |
||
52 |
// Release all interfaces |
|
53 |
delete iEp0Writer; |
|
54 |
||
55 |
// Destroy the endpoint 0 reader |
|
56 |
delete iEp0Reader; |
|
57 |
||
58 |
// Destroy interface settings |
|
59 |
iAlternateSettings.ResetAndDestroy(); |
|
60 |
||
61 |
// Close the channel to the driver |
|
62 |
iClientDriver.Close(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
OstTraceFunctionExit1( CINTERFACEBASE_CINTERFACEBASE_EXIT_DUP01, this ); |
0 | 64 |
} |
65 |
||
66 |
||
67 |
void CInterfaceBase::BaseConstructL() |
|
68 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
OstTraceFunctionEntry1( CINTERFACEBASE_BASECONSTRUCTL_ENTRY, this ); |
0 | 70 |
// Open channel to driver |
71 |
TInt err(iClientDriver.Open(0)); |
|
72 |
if(err != KErrNone) |
|
73 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_BASECONSTRUCTL, "<Error %d> Unable to open a channel to USB client driver",err); |
0 | 75 |
User::Leave(err); |
76 |
} |
|
77 |
||
78 |
// Start the watcher for host selecting alternate interface settings |
|
79 |
iSelectionWatcher = CAlternateInterfaceSelectionWatcher::NewL(iClientDriver,*this); |
|
80 |
||
81 |
// |
|
82 |
iStallWatcher = new (ELeave) CEndpointStallWatcher(iClientDriver); |
|
83 |
||
84 |
// Create the Ep0 reader/writer |
|
85 |
iEp0Reader = new (ELeave) CControlEndpointReader(iClientDriver,*this); |
|
86 |
iEp0Writer = new (ELeave) CEndpointWriter(iClientDriver,EEndpoint0); |
|
87 |
||
88 |
// Hide bus from host while interfaces are being set up |
|
89 |
iClientDriver.DeviceDisconnectFromHost(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
OstTraceFunctionExit1( CINTERFACEBASE_BASECONSTRUCTL_EXIT, this ); |
0 | 91 |
} |
92 |
||
93 |
||
94 |
void CInterfaceBase::AddInterfaceSettingL(CInterfaceSettingBase* aInterfaceSetting) |
|
95 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
OstTraceFunctionEntryExt( CINTERFACEBASE_ADDINTERFACESETTINGL_ENTRY, this ); |
0 | 97 |
|
98 |
// Append to the container |
|
99 |
TInt err(iAlternateSettings.Append(aInterfaceSetting)); |
|
100 |
if(err != KErrNone) |
|
101 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
102 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL, "<Error %d> Unable to add interface setting",err); |
0 | 103 |
User::Leave(err); |
104 |
} |
|
105 |
||
106 |
// Get the current number of alternate interface settings |
|
107 |
TInt alternateSettingNumber(iAlternateSettings.Count()-1); |
|
108 |
||
109 |
TUint endpointSettingCount(aInterfaceSetting->iInterfaceInfo().iTotalEndpointsUsed); |
|
110 |
||
111 |
if(endpointSettingCount > 0) |
|
112 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP01, "%u endpoint(s) to configure for this interface setting",endpointSettingCount); |
0 | 114 |
|
115 |
// Device capabilities |
|
116 |
TUsbDeviceCaps devCaps; |
|
117 |
err = iClientDriver.DeviceCaps(devCaps); |
|
118 |
if(err != KErrNone) |
|
119 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP02, "<Error %d> Unable to retrieve device capabilities",err); |
0 | 121 |
User::Leave(err); |
122 |
} |
|
123 |
||
124 |
// Endpoint capabilities |
|
125 |
TUsbcEndpointData endpointCaps[KUsbcMaxEndpoints]; |
|
126 |
TPtr8 dataptr(reinterpret_cast<TUint8*>(endpointCaps), sizeof(endpointCaps), sizeof(endpointCaps)); |
|
127 |
err = iClientDriver.EndpointCaps(dataptr); |
|
128 |
if(err != KErrNone) |
|
129 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP03, "<Error %d> Unable to get endpoint capabilities",err); |
0 | 131 |
User::Leave(err); |
132 |
} |
|
133 |
||
134 |
TInt totalEndpoints(devCaps().iTotalEndpoints); |
|
135 |
||
136 |
// Loop through available hardware endpoints to find suitable one |
|
137 |
// i.e. endpoints that can be configured |
|
138 |
||
139 |
TUint epIndex(0); |
|
140 |
TUint epCount(0); |
|
141 |
||
142 |
for(; epIndex<totalEndpoints; epIndex++) |
|
143 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP04, "Examining hardware endpoint %u",epIndex); |
0 | 145 |
const TUsbcEndpointData ep = endpointCaps[epIndex]; |
146 |
||
147 |
// Check the endpoint index to see if already claimed |
|
148 |
if(!ep.iInUse) |
|
149 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP05, "...its free"); |
0 | 151 |
const TUsbcEndpointCaps caps(ep.iCaps); |
152 |
||
153 |
// Information about the endpoint we are looking for |
|
154 |
TUsbcEndpointInfo& endpointSpec = aInterfaceSetting->iInterfaceInfo().iEndpointData[epCount]; |
|
155 |
||
156 |
if( (caps.iTypesAndDir & (endpointSpec.iDir | endpointSpec.iType)) == |
|
157 |
(endpointSpec.iDir | endpointSpec.iType) ) |
|
158 |
{ |
|
159 |
// Found suitable endpoint |
|
160 |
||
161 |
// Create the reader/writer for this endpoint |
|
162 |
||
163 |
if(endpointSpec.iDir == KUsbEpDirIn) |
|
164 |
{ |
|
165 |
// Create an endpoint writer for this endpoint |
|
166 |
||
167 |
aInterfaceSetting->CreateEndpointWriterL(iClientDriver,(epCount+1)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP06, "Created endpoint writer for endpoint%d",epCount+1); |
0 | 169 |
} |
170 |
else if(endpointSpec.iDir == KUsbEpDirOut) |
|
171 |
{ |
|
172 |
// Create an endpoint reader for this endpoint |
|
173 |
||
174 |
aInterfaceSetting->CreateEndpointReaderL(iClientDriver,epCount+1); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP07, "Created endpoint reader for endpoint%d",epCount+1); |
0 | 176 |
} |
177 |
||
178 |
epCount++; // Increment to next endpoint spec |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP08, "Endpoint %u configured",epCount); |
0 | 180 |
endpointSpec.iSize = caps.MaxPacketSize(); |
181 |
||
182 |
if(epCount >= endpointSettingCount) |
|
183 |
{ |
|
184 |
// Found all desired endpoints |
|
185 |
break; |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
else |
|
190 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP09, "...its busy"); |
0 | 192 |
} |
193 |
} |
|
194 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP10, "Configure %u out of %u endpoints",epCount,endpointSettingCount); |
0 | 196 |
|
197 |
if(epCount < endpointSettingCount) |
|
198 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
OstTraceExt3(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP11, "<Error %d> Only managed to configure %u out of %u endpoints",KErrNotFound,epCount,endpointSettingCount); |
0 | 200 |
User::Leave(KErrNotFound); |
201 |
} |
|
202 |
} |
|
203 |
else |
|
204 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP12, "No endpoints for this interface setting"); |
0 | 206 |
} |
207 |
||
208 |
// Add the new setting to the device |
|
209 |
err = iClientDriver.SetInterface(alternateSettingNumber,aInterfaceSetting->iInterfaceInfo); |
|
210 |
if(err != KErrNone) |
|
211 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
212 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP13, "<Error %d> Unable to set the alternate interface setting %d",err,alternateSettingNumber); |
0 | 213 |
User::Leave(err); |
214 |
} |
|
215 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_ADDINTERFACESETTINGL_DUP14, "Alternate interface setting %d set",alternateSettingNumber); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
OstTraceFunctionExit1( CINTERFACEBASE_ADDINTERFACESETTINGL_EXIT, this ); |
0 | 218 |
} |
219 |
||
220 |
||
221 |
TInt CInterfaceBase::StallEndpoint(TUint16 aEndpointNumber) |
|
222 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
OstTraceFunctionEntryExt( CINTERFACEBASE_STALLENDPOINT_ENTRY, this ); |
0 | 224 |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_STALLENDPOINT, "Stalling endpoint%d",aEndpointNumber); |
0 | 226 |
return iClientDriver.HaltEndpoint(static_cast<TEndpointNumber>(aEndpointNumber)); |
227 |
} |
|
228 |
||
229 |
||
230 |
CInterfaceSettingBase& CInterfaceBase::AlternateSetting(TInt aSettingNumber) const |
|
231 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
OstTraceFunctionEntryExt( CINTERFACEBASE_ALTERNATESETTING_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
OstTraceFunctionExit1( CINTERFACEBASE_ALTERNATESETTING_EXIT, this ); |
0 | 234 |
return *iAlternateSettings[aSettingNumber]; |
235 |
} |
|
236 |
||
237 |
||
238 |
TInt CInterfaceBase::InterfaceSettingCount() const |
|
239 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
OstTraceFunctionEntry1( CINTERFACEBASE_INTERFACESETTINGCOUNT_ENTRY, this ); |
0 | 241 |
return iAlternateSettings.Count(); |
242 |
} |
|
243 |
||
244 |
||
245 |
TUint32 CInterfaceBase::ExtractNumberL(const TDesC8& aPayload) |
|
246 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
OstTraceFunctionEntryExt( CINTERFACEBASE_EXTRACTNUMBERL_ENTRY, this ); |
0 | 248 |
|
249 |
// Read the number of repeats and the data supplied by the host, on the specified endpoint |
|
250 |
TLex8 lex(aPayload.Left(KNumberStringLength)); |
|
251 |
TUint32 numBytes; |
|
252 |
User::LeaveIfError(lex.Val(numBytes, EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_EXTRACTNUMBERL, "Writing %d bytes using string pattern below to IN endpoint",numBytes); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
const TPtrC8& midPayload = aPayload.Mid(KNumberStringLength); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
OstTraceData(TRACE_NORMAL, CINTERFACEBASE_EXTRACTNUMBERL_DUP50, "", midPayload.Ptr(), midPayload.Length()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
256 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_EXTRACTNUMBERL_DUP01, ""); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
OstTraceFunctionExitExt( CINTERFACEBASE_EXTRACTNUMBERL_EXIT, this, ( TUint )( numBytes ) ); |
0 | 258 |
return numBytes; |
259 |
} |
|
260 |
||
261 |
void CInterfaceBase::ExtractTwoNumbersL(const TDesC8& aPayload, TUint32& aFirstNum, TUint32& aSecondNum) |
|
262 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
OstTraceFunctionEntryExt( CINTERFACEBASE_EXTRACTTWONUMBERSL_ENTRY, this ); |
0 | 264 |
|
265 |
// Read the number of repeats and the data supplied by the host, on the specified endpoint |
|
266 |
TLex8 lex1(aPayload.Left(KNumberStringLength)); |
|
267 |
User::LeaveIfError(lex1.Val(aFirstNum, EDecimal)); |
|
268 |
TLex8 lex2(aPayload.Mid(KNumberStringLength, KNumberStringLength)); |
|
269 |
User::LeaveIfError(lex2.Val(aSecondNum, EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_EXTRACTTWONUMBERSL, "Writing or Reading a total of %d bytes in repeats of %d bytes using string pattern below to IN endpoint",aFirstNum,aSecondNum); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
const TPtrC8& midPayload = aPayload.Mid(2*KNumberStringLength); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
OstTraceData(TRACE_NORMAL, CINTERFACEBASE_EXTRACTTWONUMBERSL_DUP50, "", midPayload.Ptr(), midPayload.Length()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
273 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_EXTRACTTWONUMBERSL_DUP01, ""); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
274 |
OstTraceFunctionExit1( CINTERFACEBASE_EXTRACTTWONUMBERSL_EXIT, this ); |
0 | 275 |
return; |
276 |
} |
|
277 |
||
278 |
void CInterfaceBase::AlternateInterfaceSelectedL(TInt aAlternateInterfaceSetting) |
|
279 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
280 |
OstTraceFunctionEntryExt( CINTERFACEBASE_ALTERNATEINTERFACESELECTEDL_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
OstTraceExt1(TRACE_NORMAL, CINTERFACEBASE_ALTERNATEINTERFACESELECTEDL, "Interface %S:",iInterfaceName); |
0 | 282 |
iCurrentAlternateInterfaceSetting = aAlternateInterfaceSetting; |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
283 |
OstTraceFunctionExit1( CINTERFACEBASE_ALTERNATEINTERFACESELECTEDL_EXIT, this ); |
0 | 284 |
} |
285 |
||
286 |
||
287 |
TInt CInterfaceBase::ProcessRequestL(TUint8 aRequest,TUint16 aValue,TUint16 aIndex, |
|
288 |
TUint16 aDataReqLength,const TDesC8& aPayload) |
|
289 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
OstTraceFunctionEntryExt( CINTERFACEBASE_PROCESSREQUESTL_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
OstTraceExt1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL, "Interface %S:",iInterfaceName); |
0 | 292 |
|
293 |
switch(aRequest) |
|
294 |
{ |
|
295 |
case KVendorEmptyRequest: |
|
296 |
// Acknowledge the request and do nothing |
|
297 |
iEp0Reader->Acknowledge(); |
|
298 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP01, "Request: Empty"); |
0 | 300 |
break; |
301 |
||
302 |
case KVendorPutPayloadRequest: |
|
303 |
// Acknowledge the request |
|
304 |
iEp0Reader->Acknowledge(); |
|
305 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP02, "Put payload"); |
0 | 307 |
if(aPayload.Compare(_L8("DEADBEEF")) != 0) |
308 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP03, "<Error %d> Payload not as expected",KErrCorrupt); |
0 | 310 |
iDevice.ReportError(KErrCorrupt); |
311 |
} |
|
312 |
break; |
|
313 |
||
314 |
case KVendorGetPayloadRequest: |
|
315 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP04, "Get payload"); |
0 | 317 |
__ASSERT_DEBUG(iAuxBuffer, User::Panic(_L("Trying to write non-allocated buffer"), KErrGeneral)); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP05, "iAuxBuffer = ...."); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
OstTraceData(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP55, "", iAuxBuffer->Ptr(), iAuxBuffer->Length()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP06, "\n"); |
0 | 321 |
|
322 |
//Perform synchronous write to EP0 |
|
323 |
//This allows the subsequent 'Read' request to |
|
324 |
//take place |
|
325 |
TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP07, "Write (from interface callback) executed with error %d", ret); |
0 | 327 |
} |
328 |
break; |
|
329 |
||
330 |
case KVendorGetRecordedNumBytesReadInPayloadRequest: |
|
331 |
{ |
|
332 |
delete iAuxBuffer; |
|
333 |
iAuxBuffer = HBufC8::NewL(KNumberStringLength); |
|
334 |
TPtr8 ptr(iAuxBuffer->Des()); |
|
335 |
TInt retValue = 0; |
|
336 |
retValue = AlternateSetting(iCurrentAlternateInterfaceSetting).NumBytesReadSoFarL(aValue); |
|
337 |
ptr.Zero(); |
|
338 |
ptr.Format(KNumberFormatString, retValue); |
|
339 |
||
340 |
//Perform synchronous write to EP0 |
|
341 |
//This allows the subsequent 'Read' request to |
|
342 |
//take place |
|
343 |
TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP08, "Write (from interface callback) executed with error %d", ret); |
0 | 345 |
} |
346 |
break; |
|
347 |
||
348 |
case KVendorGetRecordedNumBytesWrittenInPayloadRequest: |
|
349 |
{ |
|
350 |
delete iAuxBuffer; |
|
351 |
iAuxBuffer = HBufC8::NewL(KNumberStringLength); |
|
352 |
TPtr8 ptr(iAuxBuffer->Des()); |
|
353 |
TInt retValue = 0; |
|
354 |
retValue = AlternateSetting(iCurrentAlternateInterfaceSetting).NumBytesWrittenSoFarL(aValue); |
|
355 |
ptr.Zero(); |
|
356 |
ptr.Format(KNumberFormatString, retValue); |
|
357 |
||
358 |
//Perform synchronous write to EP0 |
|
359 |
//This allows the subsequent 'Read' request to |
|
360 |
//take place |
|
361 |
TInt ret = iEp0Writer->WriteSynchronous(*iAuxBuffer, ETrue); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP09, "Write (from interface callback) executed with error %d", ret); |
0 | 363 |
} |
364 |
break; |
|
365 |
||
366 |
case KVendorWriteToEndpointRequest: |
|
367 |
// Acknowledge the request |
|
368 |
iEp0Reader->Acknowledge(); |
|
369 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP10, "Writing %d bytes to IN endpoint (index %d)",aPayload.Length(),aValue); |
0 | 371 |
|
372 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
373 |
||
374 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSpecifiedDataToEndpointL(aPayload,aValue); |
|
375 |
break; |
|
376 |
||
377 |
case KVendorCancelWriteToEndpointRequest: |
|
378 |
// Acknowledge the request |
|
379 |
iEp0Reader->Acknowledge(); |
|
380 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
381 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP11, "CANCEL Writing to IN endpoint (index %d)",aValue); |
0 | 382 |
|
383 |
// CANCEL writing the data supplied by the host, back to the host though the specified endpoint |
|
384 |
||
385 |
AlternateSetting(iCurrentAlternateInterfaceSetting).CancelWriteDataToEndpointL(aValue); |
|
386 |
break; |
|
387 |
||
388 |
case KVendorPatternWriteToEndpointRequest: |
|
389 |
{ |
|
390 |
// Acknowledge the request |
|
391 |
iEp0Reader->Acknowledge(); |
|
392 |
||
393 |
// Read the number of repeats and the data supplied by the host, on the specified endpoint |
|
394 |
TUint32 numBytes = ExtractNumberL(aPayload); |
|
395 |
||
396 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
397 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSpecifiedDataToEndpointL(aPayload.Mid(KNumberStringLength),numBytes,aValue); |
|
398 |
} |
|
399 |
break; |
|
400 |
||
401 |
case KVendorPatternWriteSynchronousToEndpointRequest: |
|
402 |
{ |
|
403 |
// Acknowledge the request |
|
404 |
iEp0Reader->Acknowledge(); |
|
405 |
||
406 |
// Read the number of repeats and the data supplied by the host, on the specified endpoint |
|
407 |
TUint32 numBytes = ExtractNumberL(aPayload); |
|
408 |
||
409 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
410 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousSpecifiedDataToEndpointL(aPayload.Mid(KNumberStringLength),numBytes,aValue); |
|
411 |
} |
|
412 |
break; |
|
413 |
||
414 |
case KVendorPatternWriteSynchronousToAndHaltEndpointRequest: |
|
415 |
{ |
|
416 |
// Acknowledge the request |
|
417 |
iEp0Reader->Acknowledge(); |
|
418 |
||
419 |
// Read the number of repeats and the data supplied by the host, on the specified endpoint |
|
420 |
TUint32 numBytes = ExtractNumberL(aPayload); |
|
421 |
||
422 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
423 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousSpecifiedDataToAndHaltEndpointL(aPayload.Mid(KNumberStringLength),numBytes,aValue); |
|
424 |
} |
|
425 |
break; |
|
426 |
||
427 |
case KVendorRepeatedReadAndValidateDataRequest: |
|
428 |
{ |
|
429 |
// Acknowledge the request |
|
430 |
iEp0Reader->Acknowledge(); |
|
431 |
||
432 |
// Read the number of bytes to read in total and per individual 'Read' together with the data supplied by the host, on the specified endpoint |
|
433 |
TUint32 numBytesPerRead = 0; |
|
434 |
TUint32 totalNumBytes = 0; |
|
435 |
ExtractTwoNumbersL(aPayload, numBytesPerRead, totalNumBytes); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
436 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP12, "Extracted: Number of Bytes per Read = %d, Total Number of Bytes = %d",numBytesPerRead,totalNumBytes); |
0 | 437 |
|
438 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
439 |
AlternateSetting(iCurrentAlternateInterfaceSetting).RepeatedReadAndValidateFromEndpointL(aPayload.Mid(KTwoNumberStringLength),numBytesPerRead,totalNumBytes,aValue); |
|
440 |
} |
|
441 |
break; |
|
442 |
||
443 |
case KVendorRepeatedPatternWriteDataRequest: |
|
444 |
{ |
|
445 |
// Acknowledge the request |
|
446 |
iEp0Reader->Acknowledge(); |
|
447 |
||
448 |
// Read the number of bytes to write in total and per individual 'Write' together with the data supplied by the host, on the specified endpoint |
|
449 |
TUint32 numBytesPerWrite = 0; |
|
450 |
TUint32 totalNumBytes = 0; |
|
451 |
ExtractTwoNumbersL(aPayload, numBytesPerWrite, totalNumBytes); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
452 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP13, "Extracted: Number of Bytes per Read = %d, Total Number of Bytes = %d",numBytesPerWrite,totalNumBytes); |
0 | 453 |
|
454 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
455 |
AlternateSetting(iCurrentAlternateInterfaceSetting).RepeatedWriteSpecifiedDataToEndpointL(aPayload.Mid(KTwoNumberStringLength),numBytesPerWrite,totalNumBytes,aValue); |
|
456 |
} |
|
457 |
break; |
|
458 |
||
459 |
case KVendorWriteCachedReadRequest: |
|
460 |
{ |
|
461 |
// Acknowledge the request |
|
462 |
iEp0Reader->Acknowledge(); |
|
463 |
||
464 |
TUint16 readEndpoint = aValue >> 8; //HI 8 buts |
|
465 |
TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits |
|
466 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
467 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP14, "Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d)",readEndpoint,writeEndpoint); |
0 | 468 |
|
469 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
470 |
||
471 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint); |
|
472 |
} |
|
473 |
break; |
|
474 |
||
475 |
case KVendorWriteSynchronousCachedReadRequest: |
|
476 |
{ |
|
477 |
// Acknowledge the request |
|
478 |
iEp0Reader->Acknowledge(); |
|
479 |
||
480 |
TUint16 readEndpoint = aValue >> 8; //HI 8 buts |
|
481 |
TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits |
|
482 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP15, "Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d)",readEndpoint,writeEndpoint); |
0 | 484 |
|
485 |
// Write the data supplied by the host, back to the host though the specified endpoint |
|
486 |
||
487 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint); |
|
488 |
} |
|
489 |
break; |
|
490 |
||
491 |
case KVendorSplitWriteSynchronousCachedReadRequest: |
|
492 |
{ |
|
493 |
// Acknowledge the request |
|
494 |
iEp0Reader->Acknowledge(); |
|
495 |
||
496 |
TUint16 readEndpoint = aValue >> 8; //HI 8 buts |
|
497 |
TUint16 writeEndpoint = aValue & 0x00ff; //LO 8 bits |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP16, "Writing data cached on OUT endpoint (index %d) to IN endpoint (index %d) in sections of....",readEndpoint,writeEndpoint); |
0 | 499 |
|
500 |
// Read the number of bytes to use for each Write |
|
501 |
TUint numBytes[KNumSplitWriteSections]; |
|
502 |
TUint numBytesWritten = 0; |
|
503 |
for(TUint i=0; i<KNumSplitWriteSections; ++i) |
|
504 |
{ |
|
505 |
TLex8 lex(aPayload.Mid(i*KNumberStringLength, KNumberStringLength)); |
|
506 |
User::LeaveIfError(lex.Val(numBytes[i], EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP17, "%d bytes", numBytes[i]); |
0 | 508 |
// Write the data supplied by the host, back to the host though the specified endpoint |
509 |
AlternateSetting(iCurrentAlternateInterfaceSetting).WriteSynchronousCachedEndpointDataToEndpointL(readEndpoint,writeEndpoint,numBytesWritten,numBytes[i]); |
|
510 |
// Updates bytes written for next round of 'for'loop |
|
511 |
numBytesWritten += numBytes[i]; |
|
512 |
} |
|
513 |
} |
|
514 |
break; |
|
515 |
||
516 |
case KVendorReadFromEndpointRequest: |
|
517 |
{ |
|
518 |
// Acknowledge the request |
|
519 |
iEp0Reader->Acknowledge(); |
|
520 |
||
521 |
// Read the amount of data supplied by the host, on the specified endpoint |
|
522 |
TLex8 lex(aPayload); |
|
523 |
TUint32 numBytes; |
|
524 |
User::LeaveIfError(lex.Val(numBytes, EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
525 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP18, "Reading %u bytes on OUT endpoint (index %u)",numBytes,(TUint32)aValue); |
0 | 526 |
AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataFromEndpointL(numBytes,aValue); |
527 |
} |
|
528 |
break; |
|
529 |
||
530 |
case KVendorReadFromAndHaltEndpointRequest: |
|
531 |
{ |
|
532 |
// Acknowledge the request |
|
533 |
iEp0Reader->Acknowledge(); |
|
534 |
||
535 |
// Read the amount of data supplied by the host, on the specified endpoint |
|
536 |
TLex8 lex(aPayload); |
|
537 |
TUint32 numBytes; |
|
538 |
User::LeaveIfError(lex.Val(numBytes, EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
539 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP19, "Reading %u bytes on OUT endpoint (index %u) ... then halting endpoint",numBytes,(TUint32)aValue); |
0 | 540 |
AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataFromAndHaltEndpointL(numBytes,aValue); |
541 |
} |
|
542 |
break; |
|
543 |
||
544 |
case KVendorCancelAnyReadFromEndpointRequest: |
|
545 |
{ |
|
546 |
// Acknowledge the request |
|
547 |
iEp0Reader->Acknowledge(); |
|
548 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
549 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP20, "CANCEL Reading on OUT endpoint (index %u)",(TUint32)aValue); |
0 | 550 |
AlternateSetting(iCurrentAlternateInterfaceSetting).CancelAnyReadDataFromEndpointL(aValue); |
551 |
} |
|
552 |
break; |
|
553 |
||
554 |
case KVendorReadUntilShortFromEndpointRequest: |
|
555 |
{ |
|
556 |
// Acknowledge the request |
|
557 |
iEp0Reader->Acknowledge(); |
|
558 |
||
559 |
// Read the amount of data supplied by the host, on the specified endpoint |
|
560 |
TLex8 lex(aPayload); |
|
561 |
TUint32 numBytes; |
|
562 |
User::LeaveIfError(lex.Val(numBytes, EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
563 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP21, "Reading %u bytes on OUT endpoint (index %u)",numBytes,(TUint32)aValue); |
0 | 564 |
AlternateSetting(iCurrentAlternateInterfaceSetting).ReadDataUntilShortFromEndpointL(numBytes,aValue); |
565 |
} |
|
566 |
break; |
|
567 |
||
568 |
case KVendorStringValidationRequest: |
|
569 |
{ |
|
570 |
// Acknowledge the request |
|
571 |
iEp0Reader->Acknowledge(); |
|
572 |
||
573 |
// Read the number of repeats and the data supplied by the host, on the specified endpoint |
|
574 |
TLex8 lex(aPayload.Left(KNumberStringLength)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
575 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP22, "NUMBER STRING LENGTH CALCULATED AS %d",KNumberStringLength); |
0 | 576 |
TUint32 numBytes; |
577 |
User::LeaveIfError(lex.Val(numBytes, EDecimal)); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
578 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP23, "Validation"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
579 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP24, "Checking %u bytes using string pattern below exist in the buffer for endpoint %u",numBytes,(TUint32)aValue); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
580 |
const TPtrC8& midPayload = aPayload.Mid(KNumberStringLength); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
OstTraceData(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP54, "", midPayload.Ptr(), midPayload.Length()); |
0 | 582 |
|
583 |
delete iAuxBuffer; |
|
584 |
iAuxBuffer = HBufC8::NewL(KPassFailStringLength); |
|
585 |
TPtr8 ptr(iAuxBuffer->Des()); |
|
586 |
if(AlternateSetting(iCurrentAlternateInterfaceSetting).ValidateCachedEndpointDataL(aPayload.Mid(KNumberStringLength),numBytes,aValue)) |
|
587 |
{ |
|
588 |
ptr.Copy(KClientPassString); |
|
589 |
} |
|
590 |
else |
|
591 |
{ |
|
592 |
ptr.Copy(KClientFailString); |
|
593 |
} |
|
594 |
} |
|
595 |
break; |
|
596 |
||
597 |
case KVendorRecordedValidationResultRequest: |
|
598 |
{ |
|
599 |
// Acknowledge the request |
|
600 |
iEp0Reader->Acknowledge(); |
|
601 |
||
602 |
delete iAuxBuffer; |
|
603 |
iAuxBuffer = HBufC8::NewL(KPassFailStringLength); |
|
604 |
TPtr8 ptr(iAuxBuffer->Des()); |
|
605 |
if(AlternateSetting(iCurrentAlternateInterfaceSetting).CachedEndpointResultL(aValue)) |
|
606 |
{ |
|
607 |
ptr.Copy(KClientPassString); |
|
608 |
} |
|
609 |
else |
|
610 |
{ |
|
611 |
ptr.Copy(KClientFailString); |
|
612 |
} |
|
613 |
} |
|
614 |
break; |
|
615 |
||
616 |
case KVendorUnrespondRequest: |
|
617 |
// Do not acknowledge this request |
|
618 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
619 |
OstTrace0(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP25, "Unrespond request: continually NAK the host"); |
0 | 620 |
break; |
621 |
||
622 |
case KVendorStallRequest: |
|
623 |
{ |
|
624 |
// Stall the specified endpoint |
|
625 |
iEp0Reader->Acknowledge(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
626 |
OstTrace1(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP26, "Stalling endpoint%d",aValue); |
0 | 627 |
TInt err = StallEndpoint(aValue); |
628 |
if(err != KErrNone) |
|
629 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
630 |
OstTraceExt2(TRACE_NORMAL, CINTERFACEBASE_PROCESSREQUESTL_DUP27, "<Error %d> unable to stall endpoint index %d",err,aValue); |
0 | 631 |
iDevice.ReportError(err); |
632 |
} |
|
633 |
} |
|
634 |
||
635 |
default: |
|
636 |
// Maybe forward to derived classes |
|
637 |
break; |
|
638 |
} |
|
639 |
||
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
640 |
OstTraceFunctionExitExt( CINTERFACEBASE_PROCESSREQUESTL_EXIT, this, KErrNone ); |
0 | 641 |
return KErrNone; |
642 |
} |
|
643 |
||
644 |
||
645 |
void CInterfaceBase::StartEp0Reading() |
|
646 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
647 |
OstTraceFunctionEntry1( CINTERFACEBASE_STARTEP0READING_ENTRY, this ); |
0 | 648 |
|
649 |
iEp0Reader->ReadRequestsL(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
650 |
OstTraceFunctionExit1( CINTERFACEBASE_STARTEP0READING_EXIT, this ); |
0 | 651 |
} |
652 |
||
653 |
||
654 |
void CInterfaceBase::StopEp0Reading() |
|
655 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
OstTraceFunctionEntry1( CINTERFACEBASE_STOPEP0READING_ENTRY, this ); |
0 | 657 |
|
658 |
iEp0Reader->Cancel(); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
659 |
OstTraceFunctionExit1( CINTERFACEBASE_STOPEP0READING_EXIT, this ); |
0 | 660 |
} |
661 |
||
662 |
} |
|
663 |
||
664 |