kerneltest/e32test/usbho/t_usbdi/src/testdeviceb.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 testdeviceb.cpp
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "modelleddevices.h"
       
    20 #include "testinterfacesettingbase.h"
       
    21 #include "testinterfacebase.h"
       
    22 #include <e32test.h>
       
    23 
       
    24 namespace NUnitTesting_USBDI
       
    25 	{
       
    26 
       
    27 RUsbDeviceB::RUsbDeviceB()
       
    28 	{
       
    29 	}
       
    30 	
       
    31 RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase)
       
    32 	{
       
    33 	LOG_FUNC	
       
    34 	}
       
    35 
       
    36 RUsbDeviceB::~RUsbDeviceB()
       
    37 	{
       
    38 	}
       
    39 
       
    40 
       
    41 void RUsbDeviceB::OpenL(const TDesC& aSerialNumber)
       
    42 	{
       
    43 	LOG_FUNC
       
    44 	
       
    45 	RUsbTestDevice::OpenL();
       
    46 	
       
    47 	// Device/Product information
       
    48 	SetUsbSpecification(0x0200); // Usb spec. 2.0
       
    49 	SetVendor(0x0E22);
       
    50 	SetProduct(0x0040,KTestDeviceB, KManufacturer, aSerialNumber);
       
    51 	SetClassCode(0xFF,0xFF,0xFF);
       
    52 	SetConfigurationString(KConfigurationString);
       
    53 		
       
    54 	// Establish the an interface
       
    55 	
       
    56 	TUsbcInterfaceInfoBuf interfaceSetting;
       
    57 	TBuf16<64> name(_L("interfaceSetting"));
       
    58 	interfaceSetting().iString = &name;
       
    59 	TUsbcEndpointInfo ep(KUsbEpTypeBulk,KUsbEpDirOut,64,0,0);
       
    60 	interfaceSetting().iEndpointData[0] = ep;
       
    61 	interfaceSetting().iEndpointData[1] = ep;
       
    62 	interfaceSetting().iEndpointData[2] = ep;
       
    63 	interfaceSetting().iTotalEndpointsUsed = 3;
       
    64 
       
    65 	TBuf8<75> cs_interfaceDescriptor;
       
    66 	cs_interfaceDescriptor.Fill(0xFF,cs_interfaceDescriptor.MaxLength());
       
    67 	cs_interfaceDescriptor[0] = 75;
       
    68 	cs_interfaceDescriptor[1] = KUsbDescType_CS_Interface;
       
    69 
       
    70 	TBuf8<75> cs_endpointDescriptor;
       
    71 	cs_endpointDescriptor.FillZ(cs_endpointDescriptor.MaxLength());
       
    72 	cs_endpointDescriptor[0] = 75;
       
    73 	cs_endpointDescriptor[1] = KUsbDescType_CS_Endpoint;
       
    74 
       
    75 
       
    76 	// Interface 0
       
    77 	
       
    78 	TInt err(iClientDriver.SetInterface(0,interfaceSetting));
       
    79 	if(err != KErrNone)
       
    80 		{
       
    81 		RDebug::Printf("<Error %d> Unable to set interface setting 0",err);
       
    82 		User::Leave(err);
       
    83 		}
       
    84 		
       
    85 	// class-specific.....
       
    86 	
       
    87 	// .....interface
       
    88 	
       
    89 	err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor);
       
    90 	if(err != KErrNone)
       
    91 		{
       
    92 		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 0 descriptor",err);
       
    93 		User::Leave(err);
       
    94 		}
       
    95 
       
    96 	// .....endpoints
       
    97 	
       
    98 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor);
       
    99 	if(err != KErrNone)
       
   100 		{
       
   101 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 0",err);
       
   102 		User::Leave(err);
       
   103 		}
       
   104 			
       
   105 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor);
       
   106 	if(err != KErrNone)
       
   107 		{
       
   108 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 0",err);
       
   109 		User::Leave(err);
       
   110 		}	
       
   111 		
       
   112 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor);
       
   113 	if(err != KErrNone)
       
   114 		{
       
   115 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 0",err);
       
   116 		User::Leave(err);
       
   117 		}
       
   118 	
       
   119 	// Interface 1
       
   120 	
       
   121 	err = iClientDriver.SetInterface(1,interfaceSetting);
       
   122 	if(err != KErrNone)
       
   123 		{
       
   124 		RDebug::Printf("<Error %d> Unable to set interface setting 1",err);
       
   125 		User::Leave(err);
       
   126 		}
       
   127 	
       
   128 	// class-specific......
       
   129 	
       
   130 	// ......interface
       
   131 	
       
   132 	err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor);
       
   133 	if(err != KErrNone)
       
   134 		{
       
   135 		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 1 descriptor",err);
       
   136 		User::Leave(err);
       
   137 		}
       
   138 
       
   139 	// .....endpoints
       
   140 		
       
   141 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor);
       
   142 	if(err != KErrNone)
       
   143 		{
       
   144 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 1",err);
       
   145 		User::Leave(err);
       
   146 		}
       
   147 	
       
   148 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor);
       
   149 	if(err != KErrNone)
       
   150 		{
       
   151 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 1",err);
       
   152 		User::Leave(err);
       
   153 		}
       
   154 		
       
   155 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor);
       
   156 	if(err != KErrNone)
       
   157 		{
       
   158 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 1",err);
       
   159 		User::Leave(err);
       
   160 		}
       
   161 
       
   162 	// Interface 2
       
   163 
       
   164 	err = iClientDriver.SetInterface(2,interfaceSetting);
       
   165 	if(err != KErrNone)
       
   166 		{
       
   167 		RDebug::Printf("<Error %d> Unable to set interface setting 2",err);
       
   168 		User::Leave(err);
       
   169 		}
       
   170 
       
   171 	// class-specific......
       
   172 	
       
   173 	// ......interface	
       
   174 
       
   175 	err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor);
       
   176 	if(err != KErrNone)
       
   177 		{
       
   178 		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 2 descriptor",err);
       
   179 		User::Leave(err);
       
   180 		}
       
   181 
       
   182 	// ......endpoints		
       
   183 		
       
   184 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor);
       
   185 	if(err != KErrNone)
       
   186 		{
       
   187 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 2",err);
       
   188 		User::Leave(err);
       
   189 		}
       
   190 	
       
   191 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor);
       
   192 	if(err != KErrNone)
       
   193 		{
       
   194 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 2",err);
       
   195 		User::Leave(err);
       
   196 		}
       
   197 		
       
   198 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor);
       
   199 	if(err != KErrNone)
       
   200 		{
       
   201 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 2",err);
       
   202 		User::Leave(err);
       
   203 		}
       
   204 	}
       
   205 
       
   206 
       
   207 void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState)
       
   208 	{
       
   209 	LOG_FUNC
       
   210 	}
       
   211 	
       
   212 	
       
   213 	}
       
   214 
       
   215