15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <e32std.h> |
18 #include <e32std.h> |
19 #include "CdcInterfaceBase.h" |
19 #include "CdcInterfaceBase.h" |
20 #include <usb/usblogger.h> |
20 #include "OstTraceDefinitions.h" |
|
21 #ifdef OST_TRACE_COMPILER_IN_USE |
|
22 #include "CdcInterfaceBaseTraces.h" |
|
23 #endif |
21 |
24 |
22 #ifdef __FLOG_ACTIVE |
|
23 _LIT8(KLogComponent, "ECACM"); |
|
24 #endif |
|
25 |
25 |
26 CCdcInterfaceBase::CCdcInterfaceBase(const TDesC16& aIfcName) |
26 CCdcInterfaceBase::CCdcInterfaceBase(const TDesC16& aIfcName) |
27 /** |
27 /** |
28 * Constructor. |
28 * Constructor. |
29 * |
29 * |
30 * @param aIfcName The name of the interface. |
30 * @param aIfcName The name of the interface. |
31 */ |
31 */ |
32 { |
32 { |
|
33 OstTraceFunctionEntry0( CCDCINTERFACEBASE_CCDCINTERFACEBASE_CONS_ENTRY ); |
33 iIfcName.Set(aIfcName); |
34 iIfcName.Set(aIfcName); |
|
35 OstTraceFunctionExit0( CCDCINTERFACEBASE_CCDCINTERFACEBASE_CONS_EXIT ); |
34 } |
36 } |
35 |
37 |
36 void CCdcInterfaceBase::BaseConstructL() |
38 void CCdcInterfaceBase::BaseConstructL() |
37 /** |
39 /** |
38 * Construct the object |
40 * Construct the object |
39 * This call registers the object with the USB device driver |
41 * This call registers the object with the USB device driver |
40 */ |
42 */ |
41 { |
43 { |
42 LOGTEXT(_L8("\tcalling RDevUsbcClient::Open")); |
44 OstTraceFunctionEntry0( CCDCINTERFACEBASE_BASECONSTRUCTL_ENTRY ); |
|
45 OstTrace0( TRACE_NORMAL, CCDCINTERFACEBASE_BASECONSTRUCTL, "CCdcInterfaceBase::BaseConstructL;\tcalling RDevUsbcClient::Open" ); |
43 // 0 is assumed to mean ep0 |
46 // 0 is assumed to mean ep0 |
44 TInt ret = iLdd.Open(0); |
47 TInt ret = iLdd.Open(0); |
45 if ( ret ) |
48 if ( ret ) |
46 { |
49 { |
47 LOGTEXT2(_L8("\tRDevUsbcClient::Open = %d"), ret); |
50 OstTrace1( TRACE_NORMAL, CCDCINTERFACEBASE_BASECONSTRUCTL_DUP1, |
48 LEAVEIFERRORL(ret); |
51 "CCdcInterfaceBase::BaseConstructL;\tRDevUsbcClient::Open = %d", ret ); |
|
52 if (ret < 0) |
|
53 { |
|
54 User::Leave(ret); |
|
55 } |
49 } |
56 } |
50 |
57 |
51 ret = SetUpInterface(); |
58 ret = SetUpInterface(); |
52 if ( ret ) |
59 if ( ret ) |
53 { |
60 { |
54 LOGTEXT2(_L8("\tSetUpInterface = %d"), ret); |
61 OstTrace1( TRACE_NORMAL, CCDCINTERFACEBASE_BASECONSTRUCTL_DUP2, |
55 LEAVEIFERRORL(ret); |
62 "CCdcInterfaceBase::BaseConstructL;\tSetUpInterface = %d", ret ); |
|
63 if (ret < 0) |
|
64 { |
|
65 User::Leave(ret); |
|
66 } |
56 } |
67 } |
|
68 OstTraceFunctionExit0( CCDCINTERFACEBASE_BASECONSTRUCTL_EXIT ); |
57 } |
69 } |
58 |
70 |
59 CCdcInterfaceBase::~CCdcInterfaceBase() |
71 CCdcInterfaceBase::~CCdcInterfaceBase() |
60 /** |
72 /** |
61 * Destructor. |
73 * Destructor. |
62 */ |
74 */ |
63 { |
75 { |
64 LOG_FUNC |
76 OstTraceFunctionEntry0( CCDCINTERFACEBASE_CCDCINTERFACEBASE_DES_ENTRY ); |
65 |
|
66 if ( iLdd.Handle() ) |
77 if ( iLdd.Handle() ) |
67 { |
78 { |
68 LOGTEXT(_L8("\tLDD handle exists")); |
79 OstTrace0( TRACE_NORMAL, CCDCINTERFACEBASE_CCDCINTERFACEBASE_DES, |
69 |
80 "CCdcInterfaceBase::~CCdcInterfaceBase;\tLDD handle exists" ); |
70 // Don't bother calling ReleaseInterface- the base driver spec says |
81 // Don't bother calling ReleaseInterface- the base driver spec says |
71 // that Close does it for us. |
82 // that Close does it for us. |
72 |
83 OstTrace0( TRACE_NORMAL, CCDCINTERFACEBASE_CCDCINTERFACEBASE_DES_DUP1, |
73 LOGTEXT(_L8("\tclosing LDD session")); |
84 "CCdcInterfaceBase::~CCdcInterfaceBase;\tclosing LDD session" ); |
74 iLdd.Close(); |
85 iLdd.Close(); |
75 } |
86 } |
|
87 OstTraceFunctionExit0( CCDCINTERFACEBASE_CCDCINTERFACEBASE_DES_EXIT ); |
76 } |
88 } |
77 |
89 |
78 TInt CCdcInterfaceBase::GetInterfaceNumber(TUint8& aIntNumber) |
90 TInt CCdcInterfaceBase::GetInterfaceNumber(TUint8& aIntNumber) |
79 /** |
91 /** |
80 * Get my interface number |
92 * Get my interface number |
81 * |
93 * |
82 * @param aIntNumber My interface number |
94 * @param aIntNumber My interface number |
83 * @return Error. |
95 * @return Error. |
84 */ |
96 */ |
85 { |
97 { |
86 LOG_FUNC |
98 OstTraceFunctionEntry0( CCDCINTERFACEBASE_GETINTERFACENUMBER_ENTRY ); |
87 |
|
88 TInt interfaceSize = 0; |
99 TInt interfaceSize = 0; |
89 |
|
90 // 0 means the main interface in the LDD API |
100 // 0 means the main interface in the LDD API |
91 TInt res = iLdd.GetInterfaceDescriptorSize(0, interfaceSize); |
101 TInt res = iLdd.GetInterfaceDescriptorSize(0, interfaceSize); |
92 |
102 |
93 if ( res ) |
103 if ( res ) |
94 { |
104 { |
95 LOGTEXT2(_L8("\t***GetInterfaceDescriptorSize()=%d"), res); |
105 OstTrace1( TRACE_NORMAL, CCDCINTERFACEBASE_GETINTERFACENUMBER, |
|
106 "CCdcInterfaceBase::GetInterfaceNumber;\t***GetInterfaceDescriptorSize()=%d", res ); |
|
107 OstTraceFunctionExit0( CCDCINTERFACEBASE_GETINTERFACENUMBER_EXIT ); |
96 return res; |
108 return res; |
97 } |
109 } |
98 |
110 |
99 HBufC8* interfaceBuf = HBufC8::New(interfaceSize); |
111 HBufC8* interfaceBuf = HBufC8::New(interfaceSize); |
100 if ( !interfaceBuf ) |
112 if ( !interfaceBuf ) |
101 { |
113 { |
102 LOGTEXT(_L8("\t***failed to create interfaceBuf- " |
114 OstTrace0( TRACE_NORMAL, CCDCINTERFACEBASE_GETINTERFACENUMBER_DUP1, |
103 "returning KErrNoMemory")); |
115 "CCdcInterfaceBase::GetInterfaceNumber;\t***failed to create interfaceBuf-returning KErrNoMemory" ); |
|
116 OstTraceFunctionExit0( CCDCINTERFACEBASE_GETINTERFACENUMBER_EXIT_DUP1 ); |
104 return KErrNoMemory; |
117 return KErrNoMemory; |
105 } |
118 } |
106 |
119 |
107 TPtr8 interfacePtr = interfaceBuf->Des(); |
120 TPtr8 interfacePtr = interfaceBuf->Des(); |
108 interfacePtr.SetLength(0); |
121 interfacePtr.SetLength(0); |
110 res = iLdd.GetInterfaceDescriptor(0, interfacePtr); |
123 res = iLdd.GetInterfaceDescriptor(0, interfacePtr); |
111 |
124 |
112 if ( res ) |
125 if ( res ) |
113 { |
126 { |
114 delete interfaceBuf; |
127 delete interfaceBuf; |
115 LOGTEXT2(_L8("\t***GetInterfaceDescriptor()=%d"), res); |
128 OstTrace1( TRACE_NORMAL, CCDCINTERFACEBASE_GETINTERFACENUMBER_DUP2, "CCdcInterfaceBase::GetInterfaceNumber;res=%d", res ); |
|
129 OstTraceFunctionExit0( CCDCINTERFACEBASE_GETINTERFACENUMBER_EXIT_DUP2 ); |
116 return res; |
130 return res; |
117 } |
131 } |
118 |
132 |
119 #ifdef __FLOG_ACTIVE |
133 OstTrace1( TRACE_NORMAL, CCDCINTERFACEBASE_GETINTERFACENUMBER_DUP3, |
120 LOGTEXT2(_L8("\t***interface length = %d"), interfacePtr.Length()); |
134 "CCdcInterfaceBase::GetInterfaceNumber;\t***interface length = %d", interfacePtr.Length() ); |
121 for ( TInt i = 0 ; i < interfacePtr.Length() ; i++ ) |
135 for ( TInt i = 0 ; i < interfacePtr.Length() ; i++ ) |
122 { |
136 { |
123 LOGTEXT2(_L8("\t***** %x"),interfacePtr[i]); |
137 OstTraceExt1( TRACE_NORMAL, CCDCINTERFACEBASE_GETINTERFACENUMBER_DUP4, |
|
138 "\t***** %hhx", interfacePtr[i] ); |
124 } |
139 } |
125 #endif |
|
126 |
140 |
127 const TUint8* buffer = reinterpret_cast<const TUint8*>(interfacePtr.Ptr()); |
141 const TUint8* buffer = reinterpret_cast<const TUint8*>(interfacePtr.Ptr()); |
128 // 2 is where the interface number is, according to the LDD API |
142 // 2 is where the interface number is, according to the LDD API |
129 aIntNumber = buffer[2]; |
143 aIntNumber = buffer[2]; |
130 |
144 OstTrace1( TRACE_NORMAL, CCDCINTERFACEBASE_GETINTERFACENUMBER_DUP5, |
131 LOGTEXT2(_L8("\tinterface number = %d"), aIntNumber); |
145 "CCdcInterfaceBase::GetInterfaceNumber;\tinterface number = %d", (TInt)aIntNumber ); |
132 |
146 |
133 delete interfaceBuf; |
147 delete interfaceBuf; |
134 |
148 OstTraceFunctionExit0( CCDCINTERFACEBASE_GETINTERFACENUMBER_EXIT_DUP3 ); |
135 return KErrNone; |
149 return KErrNone; |
136 } |
150 } |
137 |
151 |
138 // |
152 // |
139 // End of file |
153 // End of file |