author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
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 controlendpointreader.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include "controlendpointreader.h" |
|
20 |
#include "testdebug.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#include "controlendpointreaderTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
#endif |
0 | 25 |
|
26 |
namespace NUnitTesting_USBDI |
|
27 |
{ |
|
28 |
||
29 |
CControlEndpointReader::CControlEndpointReader(RDevUsbcClient& aClientDriver,MRequestHandler& aRequestHandler) |
|
30 |
: CEndpointReader(aClientDriver,EEndpoint0), |
|
31 |
iDeviceToHost(EFalse), |
|
32 |
iDataPhase(EFalse), |
|
33 |
iRequestHandler(aRequestHandler) |
|
34 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
OstTraceFunctionEntryExt( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
OstTraceFunctionExit1( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_EXIT, this ); |
0 | 37 |
} |
38 |
||
39 |
||
40 |
CControlEndpointReader::~CControlEndpointReader() |
|
41 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
OstTraceFunctionEntry1( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_ENTRY_DUP01, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
43 |
OstTraceFunctionExit1( CCONTROLENDPOINTREADER_CCONTROLENDPOINTREADER_EXIT_DUP01, this ); |
0 | 44 |
} |
45 |
||
46 |
||
47 |
void CControlEndpointReader::ReadRequestsL() |
|
48 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
OstTraceFunctionEntry1( CCONTROLENDPOINTREADER_READREQUESTSL_ENTRY, this ); |
0 | 50 |
|
51 |
// Read a packet from endpoint 0 (this should incorporate a request) |
|
52 |
||
53 |
ReadPacketL(this); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
OstTraceFunctionExit1( CCONTROLENDPOINTREADER_READREQUESTSL_EXIT, this ); |
0 | 55 |
} |
56 |
||
57 |
||
58 |
void CControlEndpointReader::EndpointReadError(TEndpointNumber aEndpointNumber,TInt aErrorCode) |
|
59 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
OstTraceFunctionEntryExt( CCONTROLENDPOINTREADER_ENDPOINTREADERROR_ENTRY, this ); |
0 | 61 |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
OstTraceExt2(TRACE_NORMAL, CCONTROLENDPOINTREADER_ENDPOINTREADERROR, "<Error %d> Asynchronous read on endpoint %d",aErrorCode,aEndpointNumber); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
OstTraceFunctionExit1( CCONTROLENDPOINTREADER_ENDPOINTREADERROR_EXIT, this ); |
0 | 64 |
} |
65 |
||
66 |
||
67 |
void CControlEndpointReader::DataReceivedFromEndpointL(TEndpointNumber aEndpointNumber,const TDesC8& aData) |
|
68 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
OstTraceFunctionEntryExt( CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_ENTRY, this ); |
0 | 70 |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
OstTraceExt5(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL, "ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
OstTraceExt2(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP01, "iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase); |
0 | 73 |
if(iDeviceToHost && iDataPhase) |
74 |
{ |
|
75 |
TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,aData); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
OstTrace1(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP02, "ProdessRequestL returned %d",err); |
0 | 77 |
|
78 |
if(err != KErrAbort) |
|
79 |
{ |
|
80 |
iDeviceToHost = EFalse; |
|
81 |
iDataPhase = EFalse; |
|
82 |
||
83 |
// After processing the request keep reading for more requests |
|
84 |
// from the host |
|
85 |
ReadPacketL(this); |
|
86 |
} |
|
87 |
} |
|
88 |
else |
|
89 |
{ |
|
90 |
// Understand the setup packet |
|
91 |
ibRequestType = aData[0]; |
|
92 |
iDeviceToHost = (ibRequestType & 0x80) == 0x00; |
|
93 |
||
94 |
// The request |
|
95 |
ibRequest = aData[1]; |
|
96 |
||
97 |
// The request parameter |
|
98 |
TUint8* p = reinterpret_cast<TUint8*>(&iwValue); |
|
99 |
*p = aData[2]; |
|
100 |
*(p+1) = aData[3]; |
|
101 |
||
102 |
// The index for the request |
|
103 |
p = reinterpret_cast<TUint8*>(&iwIndex); |
|
104 |
*p = aData[4]; |
|
105 |
*(p+1) = aData[5]; |
|
106 |
||
107 |
// The length of data transfer |
|
108 |
p = reinterpret_cast<TUint8*>(&iwLength); |
|
109 |
*p = aData[6]; |
|
110 |
*(p+1) = aData[7]; |
|
111 |
||
112 |
iDataPhase = (iwLength > 0); |
|
113 |
||
114 |
// Read all information about the request sent by the host |
|
115 |
// i.e. any DATA1 packets sent after the setup DATA0 packet |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
OstTrace0(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP03, "AFTER UPDATES"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
OstTraceExt5(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP04, "ibRequestType = %d, ibRequest = %d, iwValue = %d, iwIndex = %d, iwLength = %d",ibRequestType, ibRequest, iwValue, iwIndex, iwLength); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
OstTraceExt2(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP05, "iDeviceToHost = %d, iDataPhase = %d",iDeviceToHost,iDataPhase); |
0 | 119 |
if(iDeviceToHost && iDataPhase) |
120 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
OstTrace1(TRACE_NORMAL, CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_DUP06, "Issuing another read of %d bytes",iwLength); |
0 | 122 |
ReadL(iwLength); |
123 |
} |
|
124 |
else |
|
125 |
{ |
|
126 |
TInt err = iRequestHandler.ProcessRequestL(ibRequest,iwValue,iwIndex,iwLength,KNullDesC8); |
|
127 |
||
128 |
if(err != KErrAbort) |
|
129 |
{ |
|
130 |
// After processing the request keep reading for more requests |
|
131 |
// from the host |
|
132 |
ReadPacketL(this); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
OstTraceFunctionExit1( CCONTROLENDPOINTREADER_DATARECEIVEDFROMENDPOINTL_EXIT, this ); |
0 | 137 |
} |
138 |
||
139 |
||
140 |
} |