253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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"
|
253
|
22 |
#include "OstTraceDefinitions.h"
|
|
23 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
24 |
#include "testdevicebTraces.h"
|
|
25 |
#endif
|
0
|
26 |
#include <e32test.h>
|
|
27 |
|
|
28 |
namespace NUnitTesting_USBDI
|
|
29 |
{
|
|
30 |
|
|
31 |
RUsbDeviceB::RUsbDeviceB()
|
|
32 |
{
|
253
|
33 |
OstTraceFunctionEntry1( RUSBDEVICEB_RUSBDEVICEB_ENTRY, this );
|
|
34 |
OstTraceFunctionExit1( RUSBDEVICEB_RUSBDEVICEB_EXIT, this );
|
0
|
35 |
}
|
|
36 |
|
|
37 |
RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase)
|
|
38 |
{
|
253
|
39 |
OstTraceFunctionEntryExt( RUSBDEVICEB_RUSBDEVICEB_ENTRY_DUP01, this );
|
|
40 |
OstTraceFunctionExit1( RUSBDEVICEB_RUSBDEVICEB_EXIT_DUP01, this );
|
0
|
41 |
}
|
|
42 |
|
|
43 |
RUsbDeviceB::~RUsbDeviceB()
|
|
44 |
{
|
253
|
45 |
OstTraceFunctionEntry1( RUSBDEVICEB_RUSBDEVICEB_ENTRY_DUP02, this );
|
|
46 |
OstTraceFunctionExit1( RUSBDEVICEB_RUSBDEVICEB_EXIT_DUP02, this );
|
0
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
void RUsbDeviceB::OpenL(const TDesC& aSerialNumber)
|
|
51 |
{
|
253
|
52 |
OstTraceFunctionEntryExt( RUSBDEVICEB_OPENL_ENTRY, this );
|
0
|
53 |
|
|
54 |
RUsbTestDevice::OpenL();
|
|
55 |
|
|
56 |
// Device/Product information
|
|
57 |
SetUsbSpecification(0x0200); // Usb spec. 2.0
|
|
58 |
SetVendor(0x0E22);
|
|
59 |
SetProduct(0x0040,KTestDeviceB, KManufacturer, aSerialNumber);
|
|
60 |
SetClassCode(0xFF,0xFF,0xFF);
|
|
61 |
SetConfigurationString(KConfigurationString);
|
|
62 |
|
|
63 |
// Establish the an interface
|
|
64 |
|
|
65 |
TUsbcInterfaceInfoBuf interfaceSetting;
|
|
66 |
TBuf16<64> name(_L("interfaceSetting"));
|
|
67 |
interfaceSetting().iString = &name;
|
|
68 |
TUsbcEndpointInfo ep(KUsbEpTypeBulk,KUsbEpDirOut,64,0,0);
|
|
69 |
interfaceSetting().iEndpointData[0] = ep;
|
|
70 |
interfaceSetting().iEndpointData[1] = ep;
|
|
71 |
interfaceSetting().iEndpointData[2] = ep;
|
|
72 |
interfaceSetting().iTotalEndpointsUsed = 3;
|
|
73 |
|
|
74 |
TBuf8<75> cs_interfaceDescriptor;
|
|
75 |
cs_interfaceDescriptor.Fill(0xFF,cs_interfaceDescriptor.MaxLength());
|
|
76 |
cs_interfaceDescriptor[0] = 75;
|
|
77 |
cs_interfaceDescriptor[1] = KUsbDescType_CS_Interface;
|
|
78 |
|
|
79 |
TBuf8<75> cs_endpointDescriptor;
|
|
80 |
cs_endpointDescriptor.FillZ(cs_endpointDescriptor.MaxLength());
|
|
81 |
cs_endpointDescriptor[0] = 75;
|
|
82 |
cs_endpointDescriptor[1] = KUsbDescType_CS_Endpoint;
|
|
83 |
|
|
84 |
|
|
85 |
// Interface 0
|
|
86 |
|
|
87 |
TInt err(iClientDriver.SetInterface(0,interfaceSetting));
|
|
88 |
if(err != KErrNone)
|
|
89 |
{
|
253
|
90 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL, "<Error %d> Unable to set interface setting 0",err);
|
0
|
91 |
User::Leave(err);
|
|
92 |
}
|
|
93 |
|
|
94 |
// class-specific.....
|
|
95 |
|
|
96 |
// .....interface
|
|
97 |
|
|
98 |
err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor);
|
|
99 |
if(err != KErrNone)
|
|
100 |
{
|
253
|
101 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP01, "<Error %d> Unable to set class-specific interface setting 0 descriptor",err);
|
0
|
102 |
User::Leave(err);
|
|
103 |
}
|
|
104 |
|
|
105 |
// .....endpoints
|
|
106 |
|
|
107 |
err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor);
|
|
108 |
if(err != KErrNone)
|
|
109 |
{
|
253
|
110 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP02, "<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 0",err);
|
0
|
111 |
User::Leave(err);
|
|
112 |
}
|
|
113 |
|
|
114 |
err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor);
|
|
115 |
if(err != KErrNone)
|
|
116 |
{
|
253
|
117 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP03, "<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 0",err);
|
0
|
118 |
User::Leave(err);
|
|
119 |
}
|
|
120 |
|
|
121 |
err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor);
|
|
122 |
if(err != KErrNone)
|
|
123 |
{
|
253
|
124 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP04, "<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 0",err);
|
0
|
125 |
User::Leave(err);
|
|
126 |
}
|
|
127 |
|
|
128 |
// Interface 1
|
|
129 |
|
|
130 |
err = iClientDriver.SetInterface(1,interfaceSetting);
|
|
131 |
if(err != KErrNone)
|
|
132 |
{
|
253
|
133 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP05, "<Error %d> Unable to set interface setting 1",err);
|
0
|
134 |
User::Leave(err);
|
|
135 |
}
|
|
136 |
|
|
137 |
// class-specific......
|
|
138 |
|
|
139 |
// ......interface
|
|
140 |
|
|
141 |
err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor);
|
|
142 |
if(err != KErrNone)
|
|
143 |
{
|
253
|
144 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP06, "<Error %d> Unable to set class-specific interface setting 1 descriptor",err);
|
0
|
145 |
User::Leave(err);
|
|
146 |
}
|
|
147 |
|
|
148 |
// .....endpoints
|
|
149 |
|
|
150 |
err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor);
|
|
151 |
if(err != KErrNone)
|
|
152 |
{
|
253
|
153 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP07, "<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 1",err);
|
0
|
154 |
User::Leave(err);
|
|
155 |
}
|
|
156 |
|
|
157 |
err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor);
|
|
158 |
if(err != KErrNone)
|
|
159 |
{
|
253
|
160 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP08, "<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 1",err);
|
0
|
161 |
User::Leave(err);
|
|
162 |
}
|
|
163 |
|
|
164 |
err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor);
|
|
165 |
if(err != KErrNone)
|
|
166 |
{
|
253
|
167 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP09, "<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 1",err);
|
0
|
168 |
User::Leave(err);
|
|
169 |
}
|
|
170 |
|
|
171 |
// Interface 2
|
|
172 |
|
|
173 |
err = iClientDriver.SetInterface(2,interfaceSetting);
|
|
174 |
if(err != KErrNone)
|
|
175 |
{
|
253
|
176 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP10, "<Error %d> Unable to set interface setting 2",err);
|
0
|
177 |
User::Leave(err);
|
|
178 |
}
|
|
179 |
|
|
180 |
// class-specific......
|
|
181 |
|
|
182 |
// ......interface
|
|
183 |
|
|
184 |
err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor);
|
|
185 |
if(err != KErrNone)
|
|
186 |
{
|
253
|
187 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP11, "<Error %d> Unable to set class-specific interface setting 2 descriptor",err);
|
0
|
188 |
User::Leave(err);
|
|
189 |
}
|
|
190 |
|
|
191 |
// ......endpoints
|
|
192 |
|
|
193 |
err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor);
|
|
194 |
if(err != KErrNone)
|
|
195 |
{
|
253
|
196 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP12, "<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 2",err);
|
0
|
197 |
User::Leave(err);
|
|
198 |
}
|
|
199 |
|
|
200 |
err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor);
|
|
201 |
if(err != KErrNone)
|
|
202 |
{
|
253
|
203 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP13, "<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 2",err);
|
0
|
204 |
User::Leave(err);
|
|
205 |
}
|
|
206 |
|
|
207 |
err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor);
|
|
208 |
if(err != KErrNone)
|
|
209 |
{
|
253
|
210 |
OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP14, "<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 2",err);
|
0
|
211 |
User::Leave(err);
|
|
212 |
}
|
253
|
213 |
OstTraceFunctionExit1( RUSBDEVICEB_OPENL_EXIT, this );
|
0
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState)
|
|
218 |
{
|
253
|
219 |
OstTraceFunctionEntryExt( RUSBDEVICEB_ONSTATECHANGEL_ENTRY, this );
|
|
220 |
OstTraceFunctionExit1( RUSBDEVICEB_ONSTATECHANGEL_EXIT, this );
|
0
|
221 |
}
|
|
222 |
|
|
223 |
|
|
224 |
}
|
|
225 |
|
|
226 |
|