Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // @file controltransferrequests.cpp
19 #include "controltransferrequests.h"
20 #include "testdebug.h"
22 namespace NUnitTesting_USBDI
26 CEp0Transfer::CEp0Transfer(RUsbInterface& aInterface0)
27 : CActive(EPriorityStandard),
28 iUsbInterface0(aInterface0),
31 CActiveScheduler::Add(this);
35 CEp0Transfer::~CEp0Transfer()
42 void CEp0Transfer::DoCancel()
45 TRequestStatus* s = &iStatus;
46 User::RequestComplete(s,KErrCancel);
49 void CEp0Transfer::CancelSendRequest()
52 iUsbInterface0.CancelEP0Transfer();
56 void CEp0Transfer::SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver)
59 iObserver = aObserver;
61 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
62 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
63 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
64 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
65 RDebug::Printf("total sent : 8");
67 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus);
68 iRequestTime.HomeTime();
73 void CEp0Transfer::SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver)
76 iObserver = aObserver;
78 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
79 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
80 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
81 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
82 RDebug::Printf("data length : %d",aSetupPacket.iSendData.Length());
83 RDebug::Printf("total sent : %d",8+aSetupPacket.iSendData.Length());
85 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus);
86 iRequestTime.HomeTime();
90 void CEp0Transfer::SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver)
93 iObserver = aObserver;
95 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
96 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
97 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
98 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
99 RDebug::Printf("total sent : 8");
101 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus);
102 iRequestTime.HomeTime();
107 void CEp0Transfer::SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver)
110 iObserver = aObserver;
112 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
113 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
114 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
115 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
116 RDebug::Printf("data length : %d",aSetupPacket.iReadSpecificationData.Length());
117 RDebug::Printf("total sent : %d",8+aSetupPacket.iReadSpecificationData.Length());
118 TLex8 lex(aSetupPacket.iReadSpecificationData);
120 lex.Val(numBytes, EDecimal);
121 RDebug::Printf("Read length required (in bytes) : %d",numBytes);
123 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iReadSpecificationData,iTemp,iStatus);
124 iRequestTime.HomeTime();
128 void CEp0Transfer::SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver)
131 iObserver = aObserver;
133 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
134 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
135 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
136 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
137 RDebug::Printf("data length : %d",aSetupPacket.iSendData.Length());
138 RDebug::Printf("total sent : %d",8+aSetupPacket.iSendData.Length());
140 iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus);
141 iRequestTime.HomeTime();
145 void CEp0Transfer::SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver)
148 iObserver = aObserver;
150 RDebug::Printf("bmRequestType: 0x%02x",aSetupPacket.iRequestType);
151 RDebug::Printf("bRequest : 0x%02x",aSetupPacket.iRequest);
152 RDebug::Printf("wValue : 0x%04x",aSetupPacket.iValue);
153 RDebug::Printf("wIndex : 0x%04x",aSetupPacket.iIndex);
154 RDebug::Printf("data length : %d",aSetupPacket.iRecvData.Length());
156 iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,aSetupPacket.iRecvData,iStatus);
157 iRequestTime.HomeTime();
162 void CEp0Transfer::RunL()
164 iCompletionTime.HomeTime();
166 TInt completionCode(iStatus.Int());
168 RDebug::Printf("Client command sent, Completion code: %d",completionCode);
169 iObserver->Ep0TransferCompleteL(completionCode);
173 TInt CEp0Transfer::RunError(TInt aError)
179 void CEp0Transfer::LastRequestStartTime( TTime& aDuration)
181 aDuration= iRequestTime.Int64();
184 void CEp0Transfer::LastRequestCompletionTime( TTime& aDuration)
186 aDuration= iCompletionTime.Int64();