sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// @file controltransferrequests.cpp
|
sl@0
|
15 |
// @internalComponent
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "controltransferrequests.h"
|
sl@0
|
20 |
#include "testdebug.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
namespace NUnitTesting_USBDI
|
sl@0
|
23 |
{
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
CEp0Transfer::CEp0Transfer(RUsbInterface& aInterface0)
|
sl@0
|
27 |
: CActive(EPriorityStandard),
|
sl@0
|
28 |
iUsbInterface0(aInterface0),
|
sl@0
|
29 |
iDataRequest(EFalse)
|
sl@0
|
30 |
{
|
sl@0
|
31 |
CActiveScheduler::Add(this);
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
CEp0Transfer::~CEp0Transfer()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
LOG_FUNC
|
sl@0
|
38 |
Cancel();
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
|
sl@0
|
42 |
void CEp0Transfer::DoCancel()
|
sl@0
|
43 |
{
|
sl@0
|
44 |
// Pretend cancel
|
sl@0
|
45 |
TRequestStatus* s = &iStatus;
|
sl@0
|
46 |
User::RequestComplete(s,KErrCancel);
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
void CEp0Transfer::CancelSendRequest()
|
sl@0
|
50 |
{
|
sl@0
|
51 |
// Pretend cancel
|
sl@0
|
52 |
iUsbInterface0.CancelEP0Transfer();
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
void CEp0Transfer::SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
LOG_FUNC
|
sl@0
|
59 |
iObserver = aObserver;
|
sl@0
|
60 |
|
sl@0
|
61 |
RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
|
sl@0
|
62 |
RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
|
sl@0
|
63 |
RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
|
sl@0
|
64 |
RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
|
sl@0
|
65 |
RDebug::Printf("total sent : 8");
|
sl@0
|
66 |
|
sl@0
|
67 |
iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus);
|
sl@0
|
68 |
iRequestTime.HomeTime();
|
sl@0
|
69 |
SetActive();
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
void CEp0Transfer::SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
LOG_FUNC
|
sl@0
|
76 |
iObserver = aObserver;
|
sl@0
|
77 |
|
sl@0
|
78 |
RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
|
sl@0
|
79 |
RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
|
sl@0
|
80 |
RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
|
sl@0
|
81 |
RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
|
sl@0
|
82 |
RDebug::Printf("data length : %d",aSetupPacket.iSendData.Length());
|
sl@0
|
83 |
RDebug::Printf("total sent : %d",8+aSetupPacket.iSendData.Length());
|
sl@0
|
84 |
|
sl@0
|
85 |
iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus);
|
sl@0
|
86 |
iRequestTime.HomeTime();
|
sl@0
|
87 |
SetActive();
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
void CEp0Transfer::SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
LOG_FUNC
|
sl@0
|
93 |
iObserver = aObserver;
|
sl@0
|
94 |
|
sl@0
|
95 |
RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
|
sl@0
|
96 |
RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
|
sl@0
|
97 |
RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
|
sl@0
|
98 |
RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
|
sl@0
|
99 |
RDebug::Printf("total sent : 8");
|
sl@0
|
100 |
|
sl@0
|
101 |
iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus);
|
sl@0
|
102 |
iRequestTime.HomeTime();
|
sl@0
|
103 |
SetActive();
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
|
sl@0
|
107 |
void CEp0Transfer::SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
LOG_FUNC
|
sl@0
|
110 |
iObserver = aObserver;
|
sl@0
|
111 |
|
sl@0
|
112 |
RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
|
sl@0
|
113 |
RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
|
sl@0
|
114 |
RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
|
sl@0
|
115 |
RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
|
sl@0
|
116 |
RDebug::Printf("data length : %d",aSetupPacket.iReadSpecificationData.Length());
|
sl@0
|
117 |
RDebug::Printf("total sent : %d",8+aSetupPacket.iReadSpecificationData.Length());
|
sl@0
|
118 |
TLex8 lex(aSetupPacket.iReadSpecificationData);
|
sl@0
|
119 |
TUint numBytes = 0;
|
sl@0
|
120 |
lex.Val(numBytes, EDecimal);
|
sl@0
|
121 |
RDebug::Printf("Read length required (in bytes) : %d",numBytes);
|
sl@0
|
122 |
|
sl@0
|
123 |
iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iReadSpecificationData,iTemp,iStatus);
|
sl@0
|
124 |
iRequestTime.HomeTime();
|
sl@0
|
125 |
SetActive();
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
void CEp0Transfer::SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
LOG_FUNC
|
sl@0
|
131 |
iObserver = aObserver;
|
sl@0
|
132 |
|
sl@0
|
133 |
RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
|
sl@0
|
134 |
RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
|
sl@0
|
135 |
RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
|
sl@0
|
136 |
RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
|
sl@0
|
137 |
RDebug::Printf("data length : %d",aSetupPacket.iSendData.Length());
|
sl@0
|
138 |
RDebug::Printf("total sent : %d",8+aSetupPacket.iSendData.Length());
|
sl@0
|
139 |
|
sl@0
|
140 |
iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus);
|
sl@0
|
141 |
iRequestTime.HomeTime();
|
sl@0
|
142 |
SetActive();
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
void CEp0Transfer::SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver)
|
sl@0
|
146 |
{
|
sl@0
|
147 |
LOG_FUNC
|
sl@0
|
148 |
iObserver = aObserver;
|
sl@0
|
149 |
|
sl@0
|
150 |
RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
|
sl@0
|
151 |
RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
|
sl@0
|
152 |
RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
|
sl@0
|
153 |
RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
|
sl@0
|
154 |
RDebug::Printf("data length : %d",aSetupPacket.iRecvData.Length());
|
sl@0
|
155 |
|
sl@0
|
156 |
iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,aSetupPacket.iRecvData,iStatus);
|
sl@0
|
157 |
iRequestTime.HomeTime();
|
sl@0
|
158 |
SetActive();
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
|
sl@0
|
162 |
void CEp0Transfer::RunL()
|
sl@0
|
163 |
{
|
sl@0
|
164 |
iCompletionTime.HomeTime();
|
sl@0
|
165 |
LOG_FUNC
|
sl@0
|
166 |
TInt completionCode(iStatus.Int());
|
sl@0
|
167 |
|
sl@0
|
168 |
RDebug::Printf("Client command sent, Completion code: %d",completionCode);
|
sl@0
|
169 |
iObserver->Ep0TransferCompleteL(completionCode);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
TInt CEp0Transfer::RunError(TInt aError)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
LOG_FUNC
|
sl@0
|
176 |
return KErrNone;
|
sl@0
|
177 |
}
|
sl@0
|
178 |
|
sl@0
|
179 |
void CEp0Transfer::LastRequestStartTime( TTime& aDuration)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
aDuration= iRequestTime.Int64();
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
void CEp0Transfer::LastRequestCompletionTime( TTime& aDuration)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
aDuration= iCompletionTime.Int64();
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
|