kerneltest/e32test/usbho/t_usbdi/src/controltransferrequests.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file controltransferrequests.cpp
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "controltransferrequests.h"
       
    20 #include "testdebug.h"
       
    21 
       
    22 namespace NUnitTesting_USBDI
       
    23 	{
       
    24 	
       
    25 	
       
    26 CEp0Transfer::CEp0Transfer(RUsbInterface& aInterface0)
       
    27 :	CActive(EPriorityStandard),
       
    28 	iUsbInterface0(aInterface0),
       
    29 	iDataRequest(EFalse)
       
    30 	{
       
    31 	CActiveScheduler::Add(this);
       
    32 	}
       
    33 	
       
    34 	
       
    35 CEp0Transfer::~CEp0Transfer()
       
    36 	{
       
    37 	LOG_FUNC
       
    38 	Cancel();
       
    39 	}
       
    40 	
       
    41 	
       
    42 void CEp0Transfer::DoCancel()
       
    43 	{
       
    44 	// Pretend cancel
       
    45 	TRequestStatus* s = &iStatus;
       
    46 	User::RequestComplete(s,KErrCancel);
       
    47 	}
       
    48 
       
    49 void CEp0Transfer::CancelSendRequest()
       
    50 	{
       
    51 	// Pretend cancel
       
    52 	iUsbInterface0.CancelEP0Transfer();
       
    53 	}
       
    54 
       
    55 
       
    56 void CEp0Transfer::SendRequest(TEmptyRequest& aSetupPacket,MCommandObserver* aObserver) 
       
    57 	{
       
    58 	LOG_FUNC
       
    59 	iObserver = aObserver;	
       
    60 	
       
    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");
       
    66 	
       
    67 	iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus);
       
    68 	iRequestTime.HomeTime();
       
    69 	SetActive();	
       
    70 	}
       
    71 
       
    72 
       
    73 void CEp0Transfer::SendRequest(TDataSendRequest& aSetupPacket,MCommandObserver* aObserver)
       
    74 	{
       
    75 	LOG_FUNC
       
    76 	iObserver = aObserver;
       
    77 	
       
    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());
       
    84 	
       
    85 	iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus);
       
    86 	iRequestTime.HomeTime();
       
    87 	SetActive();
       
    88 	}
       
    89 	
       
    90 void CEp0Transfer::SendRequest(TWriteSynchronousCachedReadDataRequest& aSetupPacket,MCommandObserver* aObserver)
       
    91 	{
       
    92 	LOG_FUNC
       
    93 	iObserver = aObserver;
       
    94 	
       
    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");
       
   100 	
       
   101 	iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,iTemp,iStatus);
       
   102 	iRequestTime.HomeTime();
       
   103 	SetActive();
       
   104 	}
       
   105 
       
   106 
       
   107 void CEp0Transfer::SendRequest(TEndpointReadRequest& aSetupPacket,MCommandObserver* aObserver)
       
   108 	{
       
   109 	LOG_FUNC
       
   110 	iObserver = aObserver;
       
   111 	
       
   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);
       
   119 	TUint numBytes = 0;
       
   120 	lex.Val(numBytes, EDecimal);
       
   121 	RDebug::Printf("Read length required (in bytes)   : %d",numBytes);
       
   122 	
       
   123 	iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iReadSpecificationData,iTemp,iStatus);
       
   124 	iRequestTime.HomeTime();
       
   125 	SetActive();
       
   126 	}
       
   127 	
       
   128 void CEp0Transfer::SendRequest(TClassDataSendRequest& aSetupPacket,MCommandObserver* aObserver)
       
   129 	{
       
   130 	LOG_FUNC
       
   131 	iObserver = aObserver;
       
   132 	
       
   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());
       
   139 	
       
   140 	iUsbInterface0.Ep0Transfer(aSetupPacket,aSetupPacket.iSendData,iTemp,iStatus);
       
   141 	iRequestTime.HomeTime();
       
   142 	SetActive();
       
   143 	}
       
   144 	
       
   145 void CEp0Transfer::SendRequest(TDataRecvRequest& aSetupPacket,MCommandObserver* aObserver)
       
   146 	{
       
   147 	LOG_FUNC
       
   148 	iObserver = aObserver;
       
   149 	
       
   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());
       
   155 	
       
   156 	iUsbInterface0.Ep0Transfer(aSetupPacket,KNullDesC8,aSetupPacket.iRecvData,iStatus);
       
   157 	iRequestTime.HomeTime();
       
   158 	SetActive();
       
   159 	}
       
   160 
       
   161 
       
   162 void CEp0Transfer::RunL()
       
   163 	{
       
   164 	iCompletionTime.HomeTime();
       
   165 	LOG_FUNC
       
   166 	TInt completionCode(iStatus.Int());
       
   167 	
       
   168 	RDebug::Printf("Client command sent, Completion code: %d",completionCode);
       
   169 	iObserver->Ep0TransferCompleteL(completionCode);
       
   170 	}
       
   171 	
       
   172 	
       
   173 TInt CEp0Transfer::RunError(TInt aError)
       
   174 	{
       
   175 	LOG_FUNC
       
   176 	return KErrNone;
       
   177 	}
       
   178 
       
   179 void CEp0Transfer::LastRequestStartTime( TTime& aDuration)
       
   180 	{
       
   181 	aDuration= iRequestTime.Int64();
       
   182 	}
       
   183 
       
   184 void CEp0Transfer::LastRequestCompletionTime( TTime& aDuration)
       
   185 	{
       
   186 	aDuration= iCompletionTime.Int64();
       
   187 	}
       
   188 	
       
   189 	}
       
   190 
       
   191