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 testdeviceb.cpp
19 #include "modelleddevices.h"
20 #include "testinterfacesettingbase.h"
21 #include "testinterfacebase.h"
24 namespace NUnitTesting_USBDI
27 RUsbDeviceB::RUsbDeviceB()
31 RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase)
36 RUsbDeviceB::~RUsbDeviceB()
41 void RUsbDeviceB::OpenL(const TDesC& aSerialNumber)
45 RUsbTestDevice::OpenL();
47 // Device/Product information
48 SetUsbSpecification(0x0200); // Usb spec. 2.0
50 SetProduct(0x0040,KTestDeviceB, KManufacturer, aSerialNumber);
51 SetClassCode(0xFF,0xFF,0xFF);
52 SetConfigurationString(KConfigurationString);
54 // Establish the an interface
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;
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;
70 TBuf8<75> cs_endpointDescriptor;
71 cs_endpointDescriptor.FillZ(cs_endpointDescriptor.MaxLength());
72 cs_endpointDescriptor[0] = 75;
73 cs_endpointDescriptor[1] = KUsbDescType_CS_Endpoint;
78 TInt err(iClientDriver.SetInterface(0,interfaceSetting));
81 RDebug::Printf("<Error %d> Unable to set interface setting 0",err);
85 // class-specific.....
89 err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor);
92 RDebug::Printf("<Error %d> Unable to set class-specific interface setting 0 descriptor",err);
98 err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor);
101 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 0",err);
105 err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor);
108 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 0",err);
112 err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor);
115 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 0",err);
121 err = iClientDriver.SetInterface(1,interfaceSetting);
124 RDebug::Printf("<Error %d> Unable to set interface setting 1",err);
128 // class-specific......
132 err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor);
135 RDebug::Printf("<Error %d> Unable to set class-specific interface setting 1 descriptor",err);
141 err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor);
144 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 1",err);
148 err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor);
151 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 1",err);
155 err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor);
158 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 1",err);
164 err = iClientDriver.SetInterface(2,interfaceSetting);
167 RDebug::Printf("<Error %d> Unable to set interface setting 2",err);
171 // class-specific......
175 err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor);
178 RDebug::Printf("<Error %d> Unable to set class-specific interface setting 2 descriptor",err);
184 err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor);
187 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 2",err);
191 err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor);
194 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 2",err);
198 err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor);
201 RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 2",err);
207 void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState)