os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/testdeviceb.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/testdeviceb.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,215 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// @file testdeviceb.cpp
    1.18 +// @internalComponent
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "modelleddevices.h"
    1.23 +#include "testinterfacesettingbase.h"
    1.24 +#include "testinterfacebase.h"
    1.25 +#include <e32test.h>
    1.26 +
    1.27 +namespace NUnitTesting_USBDI
    1.28 +	{
    1.29 +
    1.30 +RUsbDeviceB::RUsbDeviceB()
    1.31 +	{
    1.32 +	}
    1.33 +	
    1.34 +RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase)
    1.35 +	{
    1.36 +	LOG_FUNC	
    1.37 +	}
    1.38 +
    1.39 +RUsbDeviceB::~RUsbDeviceB()
    1.40 +	{
    1.41 +	}
    1.42 +
    1.43 +
    1.44 +void RUsbDeviceB::OpenL(const TDesC& aSerialNumber)
    1.45 +	{
    1.46 +	LOG_FUNC
    1.47 +	
    1.48 +	RUsbTestDevice::OpenL();
    1.49 +	
    1.50 +	// Device/Product information
    1.51 +	SetUsbSpecification(0x0200); // Usb spec. 2.0
    1.52 +	SetVendor(0x0E22);
    1.53 +	SetProduct(0x0040,KTestDeviceB, KManufacturer, aSerialNumber);
    1.54 +	SetClassCode(0xFF,0xFF,0xFF);
    1.55 +	SetConfigurationString(KConfigurationString);
    1.56 +		
    1.57 +	// Establish the an interface
    1.58 +	
    1.59 +	TUsbcInterfaceInfoBuf interfaceSetting;
    1.60 +	TBuf16<64> name(_L("interfaceSetting"));
    1.61 +	interfaceSetting().iString = &name;
    1.62 +	TUsbcEndpointInfo ep(KUsbEpTypeBulk,KUsbEpDirOut,64,0,0);
    1.63 +	interfaceSetting().iEndpointData[0] = ep;
    1.64 +	interfaceSetting().iEndpointData[1] = ep;
    1.65 +	interfaceSetting().iEndpointData[2] = ep;
    1.66 +	interfaceSetting().iTotalEndpointsUsed = 3;
    1.67 +
    1.68 +	TBuf8<75> cs_interfaceDescriptor;
    1.69 +	cs_interfaceDescriptor.Fill(0xFF,cs_interfaceDescriptor.MaxLength());
    1.70 +	cs_interfaceDescriptor[0] = 75;
    1.71 +	cs_interfaceDescriptor[1] = KUsbDescType_CS_Interface;
    1.72 +
    1.73 +	TBuf8<75> cs_endpointDescriptor;
    1.74 +	cs_endpointDescriptor.FillZ(cs_endpointDescriptor.MaxLength());
    1.75 +	cs_endpointDescriptor[0] = 75;
    1.76 +	cs_endpointDescriptor[1] = KUsbDescType_CS_Endpoint;
    1.77 +
    1.78 +
    1.79 +	// Interface 0
    1.80 +	
    1.81 +	TInt err(iClientDriver.SetInterface(0,interfaceSetting));
    1.82 +	if(err != KErrNone)
    1.83 +		{
    1.84 +		RDebug::Printf("<Error %d> Unable to set interface setting 0",err);
    1.85 +		User::Leave(err);
    1.86 +		}
    1.87 +		
    1.88 +	// class-specific.....
    1.89 +	
    1.90 +	// .....interface
    1.91 +	
    1.92 +	err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor);
    1.93 +	if(err != KErrNone)
    1.94 +		{
    1.95 +		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 0 descriptor",err);
    1.96 +		User::Leave(err);
    1.97 +		}
    1.98 +
    1.99 +	// .....endpoints
   1.100 +	
   1.101 +	err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor);
   1.102 +	if(err != KErrNone)
   1.103 +		{
   1.104 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 0",err);
   1.105 +		User::Leave(err);
   1.106 +		}
   1.107 +			
   1.108 +	err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor);
   1.109 +	if(err != KErrNone)
   1.110 +		{
   1.111 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 0",err);
   1.112 +		User::Leave(err);
   1.113 +		}	
   1.114 +		
   1.115 +	err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor);
   1.116 +	if(err != KErrNone)
   1.117 +		{
   1.118 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 0",err);
   1.119 +		User::Leave(err);
   1.120 +		}
   1.121 +	
   1.122 +	// Interface 1
   1.123 +	
   1.124 +	err = iClientDriver.SetInterface(1,interfaceSetting);
   1.125 +	if(err != KErrNone)
   1.126 +		{
   1.127 +		RDebug::Printf("<Error %d> Unable to set interface setting 1",err);
   1.128 +		User::Leave(err);
   1.129 +		}
   1.130 +	
   1.131 +	// class-specific......
   1.132 +	
   1.133 +	// ......interface
   1.134 +	
   1.135 +	err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor);
   1.136 +	if(err != KErrNone)
   1.137 +		{
   1.138 +		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 1 descriptor",err);
   1.139 +		User::Leave(err);
   1.140 +		}
   1.141 +
   1.142 +	// .....endpoints
   1.143 +		
   1.144 +	err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor);
   1.145 +	if(err != KErrNone)
   1.146 +		{
   1.147 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 1",err);
   1.148 +		User::Leave(err);
   1.149 +		}
   1.150 +	
   1.151 +	err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor);
   1.152 +	if(err != KErrNone)
   1.153 +		{
   1.154 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 1",err);
   1.155 +		User::Leave(err);
   1.156 +		}
   1.157 +		
   1.158 +	err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor);
   1.159 +	if(err != KErrNone)
   1.160 +		{
   1.161 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 1",err);
   1.162 +		User::Leave(err);
   1.163 +		}
   1.164 +
   1.165 +	// Interface 2
   1.166 +
   1.167 +	err = iClientDriver.SetInterface(2,interfaceSetting);
   1.168 +	if(err != KErrNone)
   1.169 +		{
   1.170 +		RDebug::Printf("<Error %d> Unable to set interface setting 2",err);
   1.171 +		User::Leave(err);
   1.172 +		}
   1.173 +
   1.174 +	// class-specific......
   1.175 +	
   1.176 +	// ......interface	
   1.177 +
   1.178 +	err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor);
   1.179 +	if(err != KErrNone)
   1.180 +		{
   1.181 +		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 2 descriptor",err);
   1.182 +		User::Leave(err);
   1.183 +		}
   1.184 +
   1.185 +	// ......endpoints		
   1.186 +		
   1.187 +	err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor);
   1.188 +	if(err != KErrNone)
   1.189 +		{
   1.190 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 2",err);
   1.191 +		User::Leave(err);
   1.192 +		}
   1.193 +	
   1.194 +	err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor);
   1.195 +	if(err != KErrNone)
   1.196 +		{
   1.197 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 2",err);
   1.198 +		User::Leave(err);
   1.199 +		}
   1.200 +		
   1.201 +	err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor);
   1.202 +	if(err != KErrNone)
   1.203 +		{
   1.204 +		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 2",err);
   1.205 +		User::Leave(err);
   1.206 +		}
   1.207 +	}
   1.208 +
   1.209 +
   1.210 +void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState)
   1.211 +	{
   1.212 +	LOG_FUNC
   1.213 +	}
   1.214 +	
   1.215 +	
   1.216 +	}
   1.217 +
   1.218 +