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