sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // @file testdeviceb.cpp sl@0: // @internalComponent sl@0: // sl@0: // sl@0: sl@0: #include "modelleddevices.h" sl@0: #include "testinterfacesettingbase.h" sl@0: #include "testinterfacebase.h" sl@0: #include sl@0: sl@0: namespace NUnitTesting_USBDI sl@0: { sl@0: sl@0: RUsbDeviceB::RUsbDeviceB() sl@0: { sl@0: } sl@0: sl@0: RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase) sl@0: { sl@0: LOG_FUNC sl@0: } sl@0: sl@0: RUsbDeviceB::~RUsbDeviceB() sl@0: { sl@0: } sl@0: sl@0: sl@0: void RUsbDeviceB::OpenL(const TDesC& aSerialNumber) sl@0: { sl@0: LOG_FUNC sl@0: sl@0: RUsbTestDevice::OpenL(); sl@0: sl@0: // Device/Product information sl@0: SetUsbSpecification(0x0200); // Usb spec. 2.0 sl@0: SetVendor(0x0E22); sl@0: SetProduct(0x0040,KTestDeviceB, KManufacturer, aSerialNumber); sl@0: SetClassCode(0xFF,0xFF,0xFF); sl@0: SetConfigurationString(KConfigurationString); sl@0: sl@0: // Establish the an interface sl@0: sl@0: TUsbcInterfaceInfoBuf interfaceSetting; sl@0: TBuf16<64> name(_L("interfaceSetting")); sl@0: interfaceSetting().iString = &name; sl@0: TUsbcEndpointInfo ep(KUsbEpTypeBulk,KUsbEpDirOut,64,0,0); sl@0: interfaceSetting().iEndpointData[0] = ep; sl@0: interfaceSetting().iEndpointData[1] = ep; sl@0: interfaceSetting().iEndpointData[2] = ep; sl@0: interfaceSetting().iTotalEndpointsUsed = 3; sl@0: sl@0: TBuf8<75> cs_interfaceDescriptor; sl@0: cs_interfaceDescriptor.Fill(0xFF,cs_interfaceDescriptor.MaxLength()); sl@0: cs_interfaceDescriptor[0] = 75; sl@0: cs_interfaceDescriptor[1] = KUsbDescType_CS_Interface; sl@0: sl@0: TBuf8<75> cs_endpointDescriptor; sl@0: cs_endpointDescriptor.FillZ(cs_endpointDescriptor.MaxLength()); sl@0: cs_endpointDescriptor[0] = 75; sl@0: cs_endpointDescriptor[1] = KUsbDescType_CS_Endpoint; sl@0: sl@0: sl@0: // Interface 0 sl@0: sl@0: TInt err(iClientDriver.SetInterface(0,interfaceSetting)); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set interface setting 0",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // class-specific..... sl@0: sl@0: // .....interface sl@0: sl@0: err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific interface setting 0 descriptor",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // .....endpoints sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 1 descriptor on setting 0",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 2 descriptor on setting 0",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 3 descriptor on setting 0",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // Interface 1 sl@0: sl@0: err = iClientDriver.SetInterface(1,interfaceSetting); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set interface setting 1",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // class-specific...... sl@0: sl@0: // ......interface sl@0: sl@0: err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific interface setting 1 descriptor",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // .....endpoints sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 1 descriptor on setting 1",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 2 descriptor on setting 1",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 3 descriptor on setting 1",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // Interface 2 sl@0: sl@0: err = iClientDriver.SetInterface(2,interfaceSetting); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set interface setting 2",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // class-specific...... sl@0: sl@0: // ......interface sl@0: sl@0: err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific interface setting 2 descriptor",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // ......endpoints sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 1 descriptor on setting 2",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 2 descriptor on setting 2",err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Printf(" Unable to set class-specific endpoint 3 descriptor on setting 2",err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: sl@0: void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState) sl@0: { sl@0: LOG_FUNC sl@0: } sl@0: sl@0: sl@0: } sl@0: sl@0: