author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
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 |
// |
|
15 |
// |
|
16 |
||
17 |
#include "Ep0Reader.h" |
|
18 |
#include "testdebug.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
19 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
20 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
#include "Ep0ReaderTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#endif |
0 | 23 |
|
24 |
namespace NUnitTesting_USBDI |
|
25 |
{ |
|
26 |
||
27 |
CDeviceEndpoint0* CDeviceEndpoint0::NewL(MRequestHandler& aRequestHandler) |
|
28 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
OstTraceFunctionEntry1( CDEVICEENDPOINT0_NEWL_ENTRY, ( TUint )&( aRequestHandler ) ); |
0 | 30 |
CDeviceEndpoint0* self = new (ELeave) CDeviceEndpoint0(); |
31 |
CleanupStack::PushL(self); |
|
32 |
self->ConstructL(aRequestHandler); |
|
33 |
CleanupStack::Pop(self); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_NEWL_EXIT, ( TUint )( self ) ); |
0 | 35 |
return self; |
36 |
} |
|
37 |
||
38 |
||
39 |
CDeviceEndpoint0::CDeviceEndpoint0() |
|
40 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
OstTraceFunctionEntry1( CDEVICEENDPOINT0_CDEVICEENDPOINT0_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
42 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_CDEVICEENDPOINT0_EXIT, this ); |
0 | 43 |
} |
44 |
||
45 |
||
46 |
CDeviceEndpoint0::~CDeviceEndpoint0() |
|
47 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
OstTraceFunctionEntry1( CDEVICEENDPOINT0_CDEVICEENDPOINT0_ENTRY_DUP01, this ); |
0 | 49 |
|
50 |
// Destroy the reader/writer |
|
51 |
delete iEndpoint0Writer; |
|
52 |
delete iEndpoint0Reader; |
|
53 |
||
54 |
// Close channel to the driver |
|
55 |
iClientDriver.Close(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_CDEVICEENDPOINT0_EXIT_DUP01, this ); |
0 | 57 |
} |
58 |
||
59 |
||
60 |
void CDeviceEndpoint0::ConstructL(MRequestHandler& aRequestHandler) |
|
61 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
OstTraceFunctionEntryExt( CDEVICEENDPOINT0_CONSTRUCTL_ENTRY, this ); |
0 | 63 |
TInt err(iClientDriver.Open(0)); |
64 |
if(err != KErrNone) |
|
65 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
OstTrace1(TRACE_NORMAL, CDEVICEENDPOINT0_CONSTRUCTL, "<Error %d> Unable to open a channel to USB client driver",err); |
0 | 67 |
User::Leave(err); |
68 |
} |
|
69 |
||
70 |
// Create the reader of data on device endpoint 0 |
|
71 |
iEndpoint0Reader = new (ELeave) CControlEndpointReader(iClientDriver,aRequestHandler); |
|
72 |
||
73 |
// Create the writer of data on device endpoint 0 |
|
74 |
iEndpoint0Writer = new (ELeave) CEndpointWriter(iClientDriver,EEndpoint0); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_CONSTRUCTL_EXIT, this ); |
0 | 76 |
} |
77 |
||
78 |
||
79 |
TInt CDeviceEndpoint0::Start() |
|
80 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
OstTraceFunctionEntry1( CDEVICEENDPOINT0_START_ENTRY, this ); |
0 | 82 |
|
83 |
// Make this channel to the driver able to get device directed ep0 requests |
|
84 |
TInt err(iClientDriver.SetDeviceControl()); |
|
85 |
||
86 |
// Check operation success |
|
87 |
if(err != KErrNone) |
|
88 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
OstTrace1(TRACE_NORMAL, CDEVICEENDPOINT0_START, "<Error %d> Unable to obtain device control",err); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
OstTraceFunctionExitExt( CDEVICEENDPOINT0_START_EXIT, this, err ); |
0 | 91 |
return err; |
92 |
} |
|
93 |
||
94 |
// Start reading for requests from host |
|
95 |
TRAP(err,iEndpoint0Reader->ReadRequestsL()); |
|
96 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
OstTraceFunctionExitExt( CDEVICEENDPOINT0_START_EXIT_DUP01, this, err ); |
0 | 98 |
return err; |
99 |
} |
|
100 |
||
101 |
||
102 |
TInt CDeviceEndpoint0::Stop() |
|
103 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
OstTraceFunctionEntry1( CDEVICEENDPOINT0_STOP_ENTRY, this ); |
0 | 105 |
// Cancel the data reader and writer |
106 |
iEndpoint0Writer->Cancel(); |
|
107 |
iEndpoint0Reader->Cancel(); |
|
108 |
||
109 |
// Give device control back |
|
110 |
TInt err(iClientDriver.ReleaseDeviceControl()); |
|
111 |
if(err != KErrNone) |
|
112 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
OstTrace1(TRACE_NORMAL, CDEVICEENDPOINT0_STOP, "<Error %d> Unable to release device control",err); |
0 | 114 |
} |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
OstTraceFunctionExitExt( CDEVICEENDPOINT0_STOP_EXIT, this, err ); |
0 | 116 |
return err; |
117 |
} |
|
118 |
||
119 |
||
120 |
void CDeviceEndpoint0::SendData(const TDesC8& aData) |
|
121 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
OstTraceFunctionEntryExt( CDEVICEENDPOINT0_SENDDATA_ENTRY, this ); |
0 | 123 |
iEndpoint0Writer->Write(aData, ETrue); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_SENDDATA_EXIT, this ); |
0 | 125 |
} |
126 |
||
127 |
TInt CDeviceEndpoint0::SendDataSynchronous(const TDesC8& aData) |
|
128 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
OstTraceFunctionEntryExt( CDEVICEENDPOINT0_SENDDATASYNCHRONOUS_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
TInt ret = iEndpoint0Writer->WriteSynchronous(aData, ETrue); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_SENDDATASYNCHRONOUS_EXIT, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
132 |
return ret; |
0 | 133 |
} |
134 |
||
135 |
CControlEndpointReader& CDeviceEndpoint0::Reader() |
|
136 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
OstTraceFunctionEntry1( CDEVICEENDPOINT0_READER_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
OstTraceFunctionExit1( CDEVICEENDPOINT0_READER_EXIT, this ); |
0 | 139 |
return *iEndpoint0Reader; |
140 |
} |
|
141 |
||
142 |
} |
|
143 |