16 // |
16 // |
17 // |
17 // |
18 |
18 |
19 #include "controltransferrequests.h" |
19 #include "controltransferrequests.h" |
20 #include "testdebug.h" |
20 #include "testdebug.h" |
21 #include "OstTraceDefinitions.h" |
|
22 #ifdef OST_TRACE_COMPILER_IN_USE |
|
23 #include "controltransferrequestsTraces.h" |
|
24 #endif |
|
25 |
21 |
26 namespace NUnitTesting_USBDI |
22 namespace NUnitTesting_USBDI |
27 { |
23 { |
28 |
24 |
29 |
25 |
30 CEp0Transfer::CEp0Transfer(RUsbInterface& aInterface0) |
26 CEp0Transfer::CEp0Transfer(RUsbInterface& aInterface0) |
31 : CActive(EPriorityStandard), |
27 : CActive(EPriorityStandard), |
32 iUsbInterface0(aInterface0), |
28 iUsbInterface0(aInterface0), |
33 iDataRequest(EFalse) |
29 iDataRequest(EFalse) |
34 { |
30 { |
35 OstTraceFunctionEntryExt( CEP0TRANSFER_CEP0TRANSFER_ENTRY, this ); |
|
36 CActiveScheduler::Add(this); |
31 CActiveScheduler::Add(this); |
37 OstTraceFunctionExit1( CEP0TRANSFER_CEP0TRANSFER_EXIT, this ); |
|
38 } |
32 } |
39 |
33 |
40 |
34 |
41 CEp0Transfer::~CEp0Transfer() |
35 CEp0Transfer::~CEp0Transfer() |
42 { |
36 { |
43 OstTraceFunctionEntry1( CEP0TRANSFER_CEP0TRANSFER_ENTRY_DUP01, this ); |
37 LOG_FUNC |
44 Cancel(); |
38 Cancel(); |
45 OstTraceFunctionExit1( CEP0TRANSFER_CEP0TRANSFER_EXIT_DUP01, this ); |
|
46 } |
39 } |
47 |
40 |
48 |
41 |
49 void CEp0Transfer::DoCancel() |
42 void CEp0Transfer::DoCancel() |
50 { |
43 { |
51 OstTraceFunctionEntry1( CEP0TRANSFER_DOCANCEL_ENTRY, this ); |
|
52 // Pretend cancel |
44 // Pretend cancel |
53 TRequestStatus* s = &iStatus; |
45 TRequestStatus* s = &iStatus; |
54 User::RequestComplete(s,KErrCancel); |
46 User::RequestComplete(s,KErrCancel); |
55 OstTraceFunctionExit1( CEP0TRANSFER_DOCANCEL_EXIT, this ); |
|
56 } |
47 } |
57 |
48 |
58 void CEp0Transfer::CancelSendRequest() |
49 void CEp0Transfer::CancelSendRequest() |
59 { |
50 { |
60 OstTraceFunctionEntry1( CEP0TRANSFER_CANCELSENDREQUEST_ENTRY, this ); |
|
61 // Pretend cancel |
51 // Pretend cancel |
62 iUsbInterface0.CancelEP0Transfer(); |
52 iUsbInterface0.CancelEP0Transfer(); |
63 OstTraceFunctionExit1( CEP0TRANSFER_CANCELSENDREQUEST_EXIT, this ); |
|
64 } |
53 } |
65 |
54 |
66 |
55 |
67 void CEp0Transfer::SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver) |
56 void CEp0Transfer::SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver) |
68 { |
57 { |
69 OstTraceFunctionEntryExt( CEP0TRANSFER_SENDREQUEST_ENTRY, this ); |
58 LOG_FUNC |
70 iObserver = aObserver; |
59 iObserver = aObserver; |
71 |
60 |
72 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST, "bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
61 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
73 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP01, "bRequest : 0x%02x",aSetupPacket.iRequest); |
62 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest); |
74 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP02, "wValue : 0x%04x",aSetupPacket.iValue); |
63 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue); |
75 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP03, "wIndex : 0x%04x",aSetupPacket.iIndex); |
64 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex); |
76 OstTrace0(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP04, "total sent : 8"); |
65 RDebug::Printf("total sent : 8"); |
77 |
66 |
78 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus); |
67 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus); |
79 iRequestTime.HomeTime(); |
68 iRequestTime.HomeTime(); |
80 SetActive(); |
69 SetActive(); |
81 OstTraceFunctionExit1( CEP0TRANSFER_SENDREQUEST_EXIT, this ); |
|
82 } |
70 } |
83 |
71 |
84 |
72 |
85 void CEp0Transfer::SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver) |
73 void CEp0Transfer::SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver) |
86 { |
74 { |
87 OstTraceFunctionEntryExt( CEP0TRANSFER_SENDREQUEST_ENTRY_DUP01, this ); |
75 LOG_FUNC |
88 iObserver = aObserver; |
76 iObserver = aObserver; |
89 |
77 |
90 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP10, "bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
78 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
91 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP11, "bRequest : 0x%02x",aSetupPacket.iRequest); |
79 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest); |
92 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP12, "wValue : 0x%04x",aSetupPacket.iValue); |
80 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue); |
93 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP13, "wIndex : 0x%04x",aSetupPacket.iIndex); |
81 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex); |
94 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP14, "data length : %d",aSetupPacket.iSendData.Length()); |
82 RDebug::Printf("data length : %d",aSetupPacket.iSendData.Length()); |
95 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP15, "total sent : %d",8+aSetupPacket.iSendData.Length()); |
83 RDebug::Printf("total sent : %d",8+aSetupPacket.iSendData.Length()); |
96 |
84 |
97 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus); |
85 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus); |
98 iRequestTime.HomeTime(); |
86 iRequestTime.HomeTime(); |
99 SetActive(); |
87 SetActive(); |
100 OstTraceFunctionExit1( CEP0TRANSFER_SENDREQUEST_EXIT_DUP01, this ); |
|
101 } |
88 } |
102 |
89 |
103 void CEp0Transfer::SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver) |
90 void CEp0Transfer::SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver) |
104 { |
91 { |
105 OstTraceFunctionEntryExt( CEP0TRANSFER_SENDREQUEST_ENTRY_DUP02, this ); |
92 LOG_FUNC |
106 iObserver = aObserver; |
93 iObserver = aObserver; |
107 |
94 |
108 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP20, "bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
95 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
109 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP21, "bRequest : 0x%02x",aSetupPacket.iRequest); |
96 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest); |
110 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP22, "wValue : 0x%04x",aSetupPacket.iValue); |
97 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue); |
111 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP23, "wIndex : 0x%04x",aSetupPacket.iIndex); |
98 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex); |
112 OstTrace0(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP24, "total sent : 8"); |
99 RDebug::Printf("total sent : 8"); |
113 |
100 |
114 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus); |
101 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus); |
115 iRequestTime.HomeTime(); |
102 iRequestTime.HomeTime(); |
116 SetActive(); |
103 SetActive(); |
117 OstTraceFunctionExit1( CEP0TRANSFER_SENDREQUEST_EXIT_DUP02, this ); |
|
118 } |
104 } |
119 |
105 |
120 |
106 |
121 void CEp0Transfer::SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver) |
107 void CEp0Transfer::SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver) |
122 { |
108 { |
123 OstTraceFunctionEntryExt( CEP0TRANSFER_SENDREQUEST_ENTRY_DUP03, this ); |
109 LOG_FUNC |
124 iObserver = aObserver; |
110 iObserver = aObserver; |
125 |
111 |
126 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP30, "bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
112 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
127 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP31, "bRequest : 0x%02x",aSetupPacket.iRequest); |
113 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest); |
128 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP32, "wValue : 0x%04x",aSetupPacket.iValue); |
114 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue); |
129 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP33, "wIndex : 0x%04x",aSetupPacket.iIndex); |
115 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex); |
130 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP34, "data length : %d",aSetupPacket.iReadSpecificationData.Length()); |
116 RDebug::Printf("data length : %d",aSetupPacket.iReadSpecificationData.Length()); |
131 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP35, "total sent : %d",8+aSetupPacket.iReadSpecificationData.Length()); |
117 RDebug::Printf("total sent : %d",8+aSetupPacket.iReadSpecificationData.Length()); |
132 TLex8 lex(aSetupPacket.iReadSpecificationData); |
118 TLex8 lex(aSetupPacket.iReadSpecificationData); |
133 TUint numBytes = 0; |
119 TUint numBytes = 0; |
134 lex.Val(numBytes, EDecimal); |
120 lex.Val(numBytes, EDecimal); |
135 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP06, "Read length required (in bytes) : %d",numBytes); |
121 RDebug::Printf("Read length required (in bytes) : %d",numBytes); |
136 |
122 |
137 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iReadSpecificationData,iTemp,iStatus); |
123 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iReadSpecificationData,iTemp,iStatus); |
138 iRequestTime.HomeTime(); |
124 iRequestTime.HomeTime(); |
139 SetActive(); |
125 SetActive(); |
140 OstTraceFunctionExit1( CEP0TRANSFER_SENDREQUEST_EXIT_DUP03, this ); |
|
141 } |
126 } |
142 |
127 |
143 void CEp0Transfer::SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver) |
128 void CEp0Transfer::SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver) |
144 { |
129 { |
145 OstTraceFunctionEntryExt( CEP0TRANSFER_SENDREQUEST_ENTRY_DUP04, this ); |
130 LOG_FUNC |
146 iObserver = aObserver; |
131 iObserver = aObserver; |
147 |
132 |
148 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP40, "bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
133 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
149 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP41, "bRequest : 0x%02x",aSetupPacket.iRequest); |
134 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest); |
150 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP42, "wValue : 0x%04x",aSetupPacket.iValue); |
135 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue); |
151 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP43, "wIndex : 0x%04x",aSetupPacket.iIndex); |
136 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex); |
152 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP44, "data length : %d",aSetupPacket.iSendData.Length()); |
137 RDebug::Printf("data length : %d",aSetupPacket.iSendData.Length()); |
153 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP45, "total sent : %d",8+aSetupPacket.iSendData.Length()); |
138 RDebug::Printf("total sent : %d",8+aSetupPacket.iSendData.Length()); |
154 |
139 |
155 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus); |
140 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus); |
156 iRequestTime.HomeTime(); |
141 iRequestTime.HomeTime(); |
157 SetActive(); |
142 SetActive(); |
158 OstTraceFunctionExit1( CEP0TRANSFER_SENDREQUEST_EXIT_DUP04, this ); |
|
159 } |
143 } |
160 |
144 |
161 void CEp0Transfer::SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver) |
145 void CEp0Transfer::SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver) |
162 { |
146 { |
163 OstTraceFunctionEntryExt( CEP0TRANSFER_SENDREQUEST_ENTRY_DUP05, this ); |
147 LOG_FUNC |
164 iObserver = aObserver; |
148 iObserver = aObserver; |
165 |
149 |
166 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP50, "bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
150 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType); |
167 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP51, "bRequest : 0x%02x",aSetupPacket.iRequest); |
151 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest); |
168 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP52, "wValue : 0x%04x",aSetupPacket.iValue); |
152 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue); |
169 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP53, "wIndex : 0x%04x",aSetupPacket.iIndex); |
153 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex); |
170 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_SENDREQUEST_DUP54, "data length : %d",aSetupPacket.iRecvData.Length()); |
154 RDebug::Printf("data length : %d",aSetupPacket.iRecvData.Length()); |
171 |
155 |
172 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,aSetupPacket.iRecvData,iStatus); |
156 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,aSetupPacket.iRecvData,iStatus); |
173 iRequestTime.HomeTime(); |
157 iRequestTime.HomeTime(); |
174 SetActive(); |
158 SetActive(); |
175 OstTraceFunctionExit1( CEP0TRANSFER_SENDREQUEST_EXIT_DUP05, this ); |
|
176 } |
159 } |
177 |
160 |
178 |
161 |
179 void CEp0Transfer::RunL() |
162 void CEp0Transfer::RunL() |
180 { |
163 { |
181 OstTraceFunctionEntry1( CEP0TRANSFER_RUNL_ENTRY, this ); |
|
182 iCompletionTime.HomeTime(); |
164 iCompletionTime.HomeTime(); |
|
165 LOG_FUNC |
183 TInt completionCode(iStatus.Int()); |
166 TInt completionCode(iStatus.Int()); |
184 |
167 |
185 OstTrace1(TRACE_NORMAL, CEP0TRANSFER_RUNL, "Client command sent, Completion code: %d",completionCode); |
168 RDebug::Printf("Client command sent, Completion code: %d",completionCode); |
186 iObserver->Ep0TransferCompleteL(completionCode); |
169 iObserver->Ep0TransferCompleteL(completionCode); |
187 OstTraceFunctionExit1( CEP0TRANSFER_RUNL_EXIT, this ); |
|
188 } |
170 } |
189 |
171 |
190 |
172 |
191 TInt CEp0Transfer::RunError(TInt aError) |
173 TInt CEp0Transfer::RunError(TInt aError) |
192 { |
174 { |
193 OstTraceFunctionEntryExt( CEP0TRANSFER_RUNERROR_ENTRY, this ); |
175 LOG_FUNC |
194 OstTraceFunctionExitExt( CEP0TRANSFER_RUNERROR_EXIT, this, KErrNone ); |
|
195 return KErrNone; |
176 return KErrNone; |
196 } |
177 } |
197 |
178 |
198 void CEp0Transfer::LastRequestStartTime( TTime& aDuration) |
179 void CEp0Transfer::LastRequestStartTime( TTime& aDuration) |
199 { |
180 { |
200 OstTraceFunctionEntryExt( CEP0TRANSFER_LASTREQUESTSTARTTIME_ENTRY, this ); |
|
201 aDuration= iRequestTime.Int64(); |
181 aDuration= iRequestTime.Int64(); |
202 OstTraceFunctionExit1( CEP0TRANSFER_LASTREQUESTSTARTTIME_EXIT, this ); |
|
203 } |
182 } |
204 |
183 |
205 void CEp0Transfer::LastRequestCompletionTime( TTime& aDuration) |
184 void CEp0Transfer::LastRequestCompletionTime( TTime& aDuration) |
206 { |
185 { |
207 OstTraceFunctionEntryExt( CEP0TRANSFER_LASTREQUESTCOMPLETIONTIME_ENTRY, this ); |
|
208 aDuration= iCompletionTime.Int64(); |
186 aDuration= iCompletionTime.Int64(); |
209 OstTraceFunctionExit1( CEP0TRANSFER_LASTREQUESTCOMPLETIONTIME_EXIT, this ); |
|
210 } |
187 } |
211 |
188 |
212 } |
189 } |
213 |
190 |
214 |
191 |