17 // |
17 // |
18 |
18 |
19 #include "testinterfacesettingbase.h" |
19 #include "testinterfacesettingbase.h" |
20 #include "testinterfacebase.h" |
20 #include "testinterfacebase.h" |
21 #include "controltransferrequests.h" |
21 #include "controltransferrequests.h" |
22 #include "OstTraceDefinitions.h" |
|
23 #ifdef OST_TRACE_COMPILER_IN_USE |
|
24 #include "testinterfacesettingbaseTraces.h" |
|
25 #endif |
|
26 |
22 |
27 |
23 |
28 namespace NUnitTesting_USBDI |
24 namespace NUnitTesting_USBDI |
29 { |
25 { |
30 |
26 |
31 CInterfaceSettingBase::CInterfaceSettingBase(const TDesC& aString) |
27 CInterfaceSettingBase::CInterfaceSettingBase(const TDesC& aString) |
32 : iHashEndpointFunction(EndpointNumberHash), |
28 : iHashEndpointFunction(EndpointNumberHash), |
33 iIdRelEndpoint(EndpointIdentityRelationship), |
29 iIdRelEndpoint(EndpointIdentityRelationship), |
34 iEndpoints(iHashEndpointFunction,iIdRelEndpoint) |
30 iEndpoints(iHashEndpointFunction,iIdRelEndpoint) |
35 { |
31 { |
36 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_ENTRY, this ); |
|
37 // Set the name of this interface setting |
32 // Set the name of this interface setting |
38 iSettingString.Copy(aString); |
33 iSettingString.Copy(aString); |
39 iInterfaceInfo().iString = &iSettingString; |
34 iInterfaceInfo().iString = &iSettingString; |
40 |
35 |
41 // Zero count the number of endpoints used for this setting |
36 // Zero count the number of endpoints used for this setting |
42 iInterfaceInfo().iTotalEndpointsUsed = 0; |
37 iInterfaceInfo().iTotalEndpointsUsed = 0; |
43 OstTraceFunctionExit1( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_EXIT, this ); |
|
44 } |
38 } |
45 |
39 |
46 |
40 |
47 CInterfaceSettingBase::~CInterfaceSettingBase() |
41 CInterfaceSettingBase::~CInterfaceSettingBase() |
48 { |
42 { |
49 OstTraceFunctionEntry1( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_ENTRY_DUP01, this ); |
43 LOG_FUNC |
50 |
44 |
51 iEndpointReaders.ResetAndDestroy(); |
45 iEndpointReaders.ResetAndDestroy(); |
52 iEndpointWriters.ResetAndDestroy(); |
46 iEndpointWriters.ResetAndDestroy(); |
53 OstTraceFunctionExit1( CINTERFACESETTINGBASE_CINTERFACESETTINGBASE_EXIT_DUP01, this ); |
|
54 } |
47 } |
55 |
48 |
56 |
49 |
57 const TDesC& CInterfaceSettingBase::Name() const |
50 const TDesC& CInterfaceSettingBase::Name() const |
58 { |
51 { |
59 OstTraceFunctionEntry1( CINTERFACESETTINGBASE_NAME_ENTRY, this ); |
|
60 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_NAME_EXIT, this, ( TUint )&( iSettingString ) ); |
|
61 return iSettingString; |
52 return iSettingString; |
62 } |
53 } |
63 |
54 |
64 |
55 |
65 void CInterfaceSettingBase::SetClassCodeL(TUint8 aClassCode,TUint8 aSubClassCode,TUint8 aDeviceProtocol) |
56 void CInterfaceSettingBase::SetClassCodeL(TUint8 aClassCode,TUint8 aSubClassCode,TUint8 aDeviceProtocol) |
66 { |
57 { |
67 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_SETCLASSCODEL_ENTRY, this ); |
|
68 // Set class specific information |
58 // Set class specific information |
69 iInterfaceInfo().iClass = TUsbcClassInfo(aClassCode,aSubClassCode,aDeviceProtocol); |
59 iInterfaceInfo().iClass = TUsbcClassInfo(aClassCode,aSubClassCode,aDeviceProtocol); |
70 OstTraceFunctionExit1( CINTERFACESETTINGBASE_SETCLASSCODEL_EXIT, this ); |
|
71 } |
60 } |
72 |
61 |
73 |
62 |
74 TInt CInterfaceSettingBase::AddEndpoint(TEndpoint& aEndpoint) |
63 TInt CInterfaceSettingBase::AddEndpoint(TEndpoint& aEndpoint) |
75 { |
64 { |
76 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_ADDENDPOINT_ENTRY, this ); |
65 LOG_FUNC |
77 |
66 |
78 if(aEndpoint.iEndpointNumber == EEndpoint0) |
67 if(aEndpoint.iEndpointNumber == EEndpoint0) |
79 { |
68 { |
80 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_ADDENDPOINT_EXIT, this, KErrInUse ); |
|
81 return KErrInUse; |
69 return KErrInUse; |
82 } |
70 } |
83 |
71 |
84 if(iEndpoints.Count() < KMaxEndpointsPerClient) |
72 if(iEndpoints.Count() < KMaxEndpointsPerClient) |
85 { |
73 { |
88 iEndpoints.Insert(aEndpoint.iEndpointNumber,aEndpoint); |
76 iEndpoints.Insert(aEndpoint.iEndpointNumber,aEndpoint); |
89 |
77 |
90 // Update the total endpoints used on this interface |
78 // Update the total endpoints used on this interface |
91 iInterfaceInfo().iTotalEndpointsUsed = iEndpoints.Count(); |
79 iInterfaceInfo().iTotalEndpointsUsed = iEndpoints.Count(); |
92 |
80 |
93 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_ADDENDPOINT_EXIT_DUP01, this, KErrNone ); |
|
94 return KErrNone; |
81 return KErrNone; |
95 } |
82 } |
96 else |
83 else |
97 { |
84 { |
98 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_ADDENDPOINT_EXIT_DUP02, this, KErrOverflow ); |
|
99 return KErrOverflow; |
85 return KErrOverflow; |
100 } |
86 } |
101 } |
87 } |
102 |
88 |
103 |
89 |
104 void CInterfaceSettingBase::CreateEndpointReaderL(RDevUsbcClient& aClientDriver,TUint aEndpoint) |
90 void CInterfaceSettingBase::CreateEndpointReaderL(RDevUsbcClient& aClientDriver,TUint aEndpoint) |
105 { |
91 { |
106 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CREATEENDPOINTREADERL_ENTRY, this ); |
92 LOG_FUNC |
107 // Create the reader for this endpoint and store in the container |
93 // Create the reader for this endpoint and store in the container |
108 CEndpointReader* epReader = new (ELeave) CEndpointReader(aClientDriver, |
94 CEndpointReader* epReader = new (ELeave) CEndpointReader(aClientDriver, |
109 iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber); |
95 iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber); |
110 CleanupStack::PushL(epReader); |
96 CleanupStack::PushL(epReader); |
111 iEndpointReaders.AppendL(epReader); |
97 iEndpointReaders.AppendL(epReader); |
112 CleanupStack::Pop(epReader); |
98 CleanupStack::Pop(epReader); |
113 OstTraceFunctionExit1( CINTERFACESETTINGBASE_CREATEENDPOINTREADERL_EXIT, this ); |
|
114 } |
99 } |
115 |
100 |
116 |
101 |
117 void CInterfaceSettingBase::CreateEndpointWriterL(RDevUsbcClient& aClientDriver,TUint aEndpoint) |
102 void CInterfaceSettingBase::CreateEndpointWriterL(RDevUsbcClient& aClientDriver,TUint aEndpoint) |
118 { |
103 { |
119 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CREATEENDPOINTWRITERL_ENTRY, this ); |
104 LOG_FUNC |
120 // Create the writer for this endpoint and store in the container |
105 // Create the writer for this endpoint and store in the container |
121 CEndpointWriter* epWriter = new (ELeave) CEndpointWriter(aClientDriver, |
106 CEndpointWriter* epWriter = new (ELeave) CEndpointWriter(aClientDriver, |
122 iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber); |
107 iEndpoints.Find(static_cast<TEndpointNumber>(aEndpoint))->iEndpointNumber); |
123 CleanupStack::PushL(epWriter); |
108 CleanupStack::PushL(epWriter); |
124 iEndpointWriters.AppendL(epWriter); |
109 iEndpointWriters.AppendL(epWriter); |
125 CleanupStack::Pop(epWriter); |
110 CleanupStack::Pop(epWriter); |
126 OstTraceFunctionExit1( CINTERFACESETTINGBASE_CREATEENDPOINTWRITERL_EXIT, this ); |
|
127 } |
111 } |
128 |
112 |
129 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aData,TUint16 aEndpointNumber) |
113 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aData,TUint16 aEndpointNumber) |
130 { |
114 { |
131 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_ENTRY, this ); |
115 LOG_FUNC |
132 // Access the correct writer for the given endpoint |
116 // Access the correct writer for the given endpoint |
133 // and write the data to the host |
117 // and write the data to the host |
134 iEndpointWriters[aEndpointNumber-1]->Write(aData, ETrue); |
118 iEndpointWriters[aEndpointNumber-1]->Write(aData, ETrue); |
135 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_EXIT, this ); |
|
136 } |
119 } |
137 |
120 |
138 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber) |
121 void CInterfaceSettingBase::WriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber) |
139 { |
122 { |
140 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_ENTRY_DUP01, this ); |
123 LOG_FUNC |
141 // Access the correct writer for the given endpoint |
124 // Access the correct writer for the given endpoint |
142 // and write the data to the host |
125 // and write the data to the host |
143 iEndpointWriters[aEndpointNumber-1]->WriteUsingPatternL(aDataPattern,aNumBytes,ETrue); |
126 iEndpointWriters[aEndpointNumber-1]->WriteUsingPatternL(aDataPattern,aNumBytes,ETrue); |
144 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESPECIFIEDDATATOENDPOINTL_EXIT_DUP01, this ); |
|
145 } |
127 } |
146 |
128 |
147 void CInterfaceSettingBase::RepeatedWriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerWrite, TUint aTotalNumBytes, TUint16 aEndpointNumber) |
129 void CInterfaceSettingBase::RepeatedWriteSpecifiedDataToEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerWrite, TUint aTotalNumBytes, TUint16 aEndpointNumber) |
148 { |
130 { |
149 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_REPEATEDWRITESPECIFIEDDATATOENDPOINTL_ENTRY, this ); |
131 LOG_FUNC |
150 // Access the correct writer for the given endpoint |
132 // Access the correct writer for the given endpoint |
151 // and write the data to the host |
133 // and write the data to the host |
152 iEndpointWriters[aEndpointNumber-1]->WriteInPartsUsingPatternL(aDataPattern,aNumBytesPerWrite,aTotalNumBytes,ETrue); |
134 iEndpointWriters[aEndpointNumber-1]->WriteInPartsUsingPatternL(aDataPattern,aNumBytesPerWrite,aTotalNumBytes,ETrue); |
153 OstTraceFunctionExit1( CINTERFACESETTINGBASE_REPEATEDWRITESPECIFIEDDATATOENDPOINTL_EXIT, this ); |
|
154 } |
135 } |
155 |
136 |
156 void CInterfaceSettingBase::WriteCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber) |
137 void CInterfaceSettingBase::WriteCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber) |
157 { |
138 { |
158 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITECACHEDENDPOINTDATATOENDPOINTL_ENTRY, this ); |
139 LOG_FUNC |
159 |
140 |
160 iEndpointWriters[aWriteEndpointNumber-1]->Write(iEndpointReaders[aReadEndpointNumber-1]->Buffer(), ETrue); |
141 iEndpointWriters[aWriteEndpointNumber-1]->Write(iEndpointReaders[aReadEndpointNumber-1]->Buffer(), ETrue); |
161 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITECACHEDENDPOINTDATATOENDPOINTL_EXIT, this ); |
|
162 } |
142 } |
163 |
143 |
164 void CInterfaceSettingBase::CancelWriteDataToEndpointL(TUint16 aEndpointNumber) |
144 void CInterfaceSettingBase::CancelWriteDataToEndpointL(TUint16 aEndpointNumber) |
165 { |
145 { |
166 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CANCELWRITEDATATOENDPOINTL_ENTRY, this ); |
146 LOG_FUNC |
167 // Access the correct writer for the given endpoint |
147 // Access the correct writer for the given endpoint |
168 // and cancel any outstanding write. This will not of course work for 'synchronous' writes. |
148 // and cancel any outstanding write. This will not of course work for 'synchronous' writes. |
169 iEndpointWriters[aEndpointNumber-1]->Cancel(); |
149 iEndpointWriters[aEndpointNumber-1]->Cancel(); |
170 OstTraceFunctionExit1( CINTERFACESETTINGBASE_CANCELWRITEDATATOENDPOINTL_EXIT, this ); |
|
171 } |
150 } |
172 |
151 |
173 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber) |
152 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber) |
174 { |
153 { |
175 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOENDPOINTL_ENTRY, this ); |
154 LOG_FUNC |
176 // Access the correct writer for the given endpoint |
155 // Access the correct writer for the given endpoint |
177 // and write the data to the host |
156 // and write the data to the host |
178 iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternL(aDataPattern,aNumBytes,ETrue); |
157 iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternL(aDataPattern,aNumBytes,ETrue); |
179 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOENDPOINTL_EXIT, this ); |
|
180 } |
158 } |
181 |
159 |
182 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToAndHaltEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber) |
160 void CInterfaceSettingBase::WriteSynchronousSpecifiedDataToAndHaltEndpointL(const TDesC8& aDataPattern, const TUint aNumBytes, TUint16 aEndpointNumber) |
183 { |
161 { |
184 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOANDHALTENDPOINTL_ENTRY, this ); |
162 LOG_FUNC |
185 // Access the correct writer for the given endpoint |
163 // Access the correct writer for the given endpoint |
186 // and write the data to the host |
164 // and write the data to the host |
187 iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternAndHaltL(aDataPattern,aNumBytes); |
165 iEndpointWriters[aEndpointNumber-1]->WriteSynchronousUsingPatternAndHaltL(aDataPattern,aNumBytes); |
188 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSSPECIFIEDDATATOANDHALTENDPOINTL_EXIT, this ); |
|
189 } |
166 } |
190 |
167 |
191 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber) |
168 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber) |
192 { |
169 { |
193 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_ENTRY, this ); |
170 LOG_FUNC |
194 |
171 |
195 //Attempt to write the complete cached buffer by starting at zero and choosing the max length posible |
172 //Attempt to write the complete cached buffer by starting at zero and choosing the max length posible |
196 WriteSynchronousCachedEndpointDataToEndpointL(aReadEndpointNumber, aWriteEndpointNumber, 0, KMaxTInt); |
173 WriteSynchronousCachedEndpointDataToEndpointL(aReadEndpointNumber, aWriteEndpointNumber, 0, KMaxTInt); |
197 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_EXIT, this ); |
|
198 } |
174 } |
199 |
175 |
200 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber, TUint aStartPoint, TUint aLength) |
176 void CInterfaceSettingBase::WriteSynchronousCachedEndpointDataToEndpointL(const TUint16 aReadEndpointNumber,TUint16 aWriteEndpointNumber, TUint aStartPoint, TUint aLength) |
201 { |
177 { |
202 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_ENTRY_DUP01, this ); |
178 LOG_FUNC |
203 // Access the correct writer for the given endpoint |
179 // Access the correct writer for the given endpoint |
204 // Access the 'source' endpoint buffer. This contains data from that endpoint's last read. |
180 // Access the 'source' endpoint buffer. This contains data from that endpoint's last read. |
205 // Write this data to the host using 'write' endpoint. |
181 // Write this data to the host using 'write' endpoint. |
206 |
182 |
207 // Check data |
183 // Check data |
215 } |
191 } |
216 |
192 |
217 // Do the 'Write' |
193 // Do the 'Write' |
218 // Note we need a synchronous 'Write' here |
194 // Note we need a synchronous 'Write' here |
219 iEndpointWriters[aWriteEndpointNumber-1]->WriteSynchronous(iEndpointReaders[aReadEndpointNumber-1]->Buffer().Mid(aStartPoint, aLength), ETrue); |
195 iEndpointWriters[aWriteEndpointNumber-1]->WriteSynchronous(iEndpointReaders[aReadEndpointNumber-1]->Buffer().Mid(aStartPoint, aLength), ETrue); |
220 OstTraceFunctionExit1( CINTERFACESETTINGBASE_WRITESYNCHRONOUSCACHEDENDPOINTDATATOENDPOINTL_EXIT_DUP01, this ); |
|
221 } |
196 } |
222 |
197 |
223 TBool CInterfaceSettingBase::CachedEndpointResultL(const TUint16 aEndpointNumber) |
198 TBool CInterfaceSettingBase::CachedEndpointResultL(const TUint16 aEndpointNumber) |
224 { |
199 { |
225 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CACHEDENDPOINTRESULTL_ENTRY, this ); |
200 LOG_FUNC |
226 // Access endpoint buffer containing data from the endpoint's last read |
201 // Access endpoint buffer containing data from the endpoint's last read |
227 // and validate with the supplied data pattern |
202 // and validate with the supplied data pattern |
228 |
203 |
229 return iEndpointReaders[aEndpointNumber-1]->IsValid(); |
204 return iEndpointReaders[aEndpointNumber-1]->IsValid(); |
230 } |
205 } |
231 |
206 |
232 TInt CInterfaceSettingBase::NumBytesReadSoFarL(const TUint16 aEndpointNumber) |
207 TInt CInterfaceSettingBase::NumBytesReadSoFarL(const TUint16 aEndpointNumber) |
233 { |
208 { |
234 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_NUMBYTESREADSOFARL_ENTRY, this ); |
209 LOG_FUNC |
235 // Access endpoint buffer containing data from the endpoint's last read |
210 // Access endpoint buffer containing data from the endpoint's last read |
236 // and validate with the supplied data pattern |
211 // and validate with the supplied data pattern |
237 |
212 |
238 return iEndpointReaders[aEndpointNumber-1]->NumBytesReadSoFar(); |
213 return iEndpointReaders[aEndpointNumber-1]->NumBytesReadSoFar(); |
239 } |
214 } |
240 |
215 |
241 TInt CInterfaceSettingBase::NumBytesWrittenSoFarL(const TUint16 aEndpointNumber) |
216 TInt CInterfaceSettingBase::NumBytesWrittenSoFarL(const TUint16 aEndpointNumber) |
242 { |
217 { |
243 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_NUMBYTESWRITTENSOFARL_ENTRY, this ); |
218 LOG_FUNC |
244 // Access endpoint buffer containing data from the endpoint's last read |
219 // Access endpoint buffer containing data from the endpoint's last read |
245 // and validate with the supplied data pattern |
220 // and validate with the supplied data pattern |
246 |
221 |
247 return iEndpointWriters[aEndpointNumber-1]->NumBytesWrittenSoFar(); |
222 return iEndpointWriters[aEndpointNumber-1]->NumBytesWrittenSoFar(); |
248 } |
223 } |
249 |
224 |
250 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aNumBytes, const TUint16 aEndpointNumber) |
225 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aNumBytes, const TUint16 aEndpointNumber) |
251 { |
226 { |
252 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_ENTRY, this ); |
227 LOG_FUNC |
253 // Access endpoint buffer containing data from the endpoint's last read |
228 // Access endpoint buffer containing data from the endpoint's last read |
254 // and validate with the supplied data pattern |
229 // and validate with the supplied data pattern |
255 |
230 |
256 return ValidateCachedEndpointDataL(aDataPattern, 0, aNumBytes, aEndpointNumber); |
231 return ValidateCachedEndpointDataL(aDataPattern, 0, aNumBytes, aEndpointNumber); |
257 } |
232 } |
258 |
233 |
259 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes, const TUint16 aEndpointNumber) |
234 TBool CInterfaceSettingBase::ValidateCachedEndpointDataL(const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes, const TUint16 aEndpointNumber) |
260 { |
235 { |
261 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_ENTRY_DUP01, this ); |
236 LOG_FUNC |
262 __ASSERT_DEBUG(aDataPattern.Length()!=0, User::Panic(_L("Trying to validate with ZERO LENGTH STRING"), KErrArgument)); |
237 __ASSERT_DEBUG(aDataPattern.Length()!=0, User::Panic(_L("Trying to validate with ZERO LENGTH STRING"), KErrArgument)); |
263 |
238 |
264 //Check data in endpoint buffer |
239 //Check data in endpoint buffer |
265 TPtr8 dataToValidate(iEndpointReaders[aEndpointNumber-1]->Buffer()); |
240 TPtr8 dataToValidate(iEndpointReaders[aEndpointNumber-1]->Buffer()); |
266 User::LeaveIfError(dataToValidate.MaxLength() == 0); |
241 User::LeaveIfError(dataToValidate.MaxLength() == 0); |
273 TUint numEndBytes = aNumBytes - startEndPoint;//fullRepeats*aDataPattern.Length() - numStartBytes; |
248 TUint numEndBytes = aNumBytes - startEndPoint;//fullRepeats*aDataPattern.Length() - numStartBytes; |
274 if(numStartBytes) |
249 if(numStartBytes) |
275 { |
250 { |
276 if(dataToValidate.Left(numStartBytes).Compare(aDataPattern.Mid(startPoint, numStartBytes)) != 0) |
251 if(dataToValidate.Left(numStartBytes).Compare(aDataPattern.Mid(startPoint, numStartBytes)) != 0) |
277 { |
252 { |
278 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL, "ROUND TRIP VALIDATION: Start Bytes Match Failure"); |
253 RDebug::Printf("ROUND TRIP VALIDATION: Start Bytes Match Failure"); |
279 OstTrace1(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP01, "ROUND TRIP VALIDATION: numStartBytes = %d", numStartBytes); |
254 RDebug::Printf("ROUND TRIP VALIDATION: numStartBytes = %d", numStartBytes); |
280 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP02, "Start of sent data ..."); |
255 RDebug::Printf("Start of sent data ..."); |
281 const TPtrC8& midDataPattern = aDataPattern.Mid(startPoint, numStartBytes); |
256 RDebug::RawPrint(aDataPattern.Mid(startPoint, numStartBytes)); |
282 OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP52, "", midDataPattern.Ptr(), midDataPattern.Length()); |
257 RDebug::Printf("\n"); |
283 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP03, "\n"); |
258 RDebug::Printf("ROUND TRIP VALIDATION: Start of returned data ..."); |
284 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP04, "ROUND TRIP VALIDATION: Start of returned data ..."); |
259 RDebug::RawPrint(dataToValidate.Left(numStartBytes)); |
285 const TPtrC8& leftDataToValidate = dataToValidate.Left(numStartBytes); |
260 RDebug::Printf("\n"); |
286 OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP54, "", leftDataToValidate.Ptr(), leftDataToValidate.Length()); |
|
287 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP05, "\n"); |
|
288 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT, this, EFalse ); |
|
289 return EFalse; |
261 return EFalse; |
290 } |
262 } |
291 } |
263 } |
292 if(numEndBytes) |
264 if(numEndBytes) |
293 { |
265 { |
294 if(dataToValidate.Mid(startEndPoint,numEndBytes).Compare(aDataPattern.Left(numEndBytes)) != 0) |
266 if(dataToValidate.Mid(startEndPoint,numEndBytes).Compare(aDataPattern.Left(numEndBytes)) != 0) |
295 { |
267 { |
296 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP06, "ROUND TRIP VALIDATION: End Bytes Match Failure"); |
268 RDebug::Printf("ROUND TRIP VALIDATION: End Bytes Match Failure"); |
297 OstTraceExt2(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP07, "ROUND TRIP VALIDATION: startEndPoint = %u, numEndBytes = %u", startEndPoint, numEndBytes); |
269 RDebug::Printf("ROUND TRIP VALIDATION: startEndPoint = %d, numEndBytes = %d", startEndPoint, numEndBytes); |
298 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP08, "End of sent data ..."); |
270 RDebug::Printf("End of sent data ..."); |
299 const TPtrC8& leftDataPattern = aDataPattern.Left(numEndBytes); |
271 RDebug::RawPrint(aDataPattern.Left(numEndBytes)); |
300 OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP58, "", leftDataPattern.Ptr(), leftDataPattern.Length()); |
272 RDebug::Printf("\n"); |
301 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP09, "\n"); |
273 RDebug::Printf("ROUND TRIP VALIDATION: End of returned data ..."); |
302 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP10, "ROUND TRIP VALIDATION: End of returned data ..."); |
274 RDebug::RawPrint(dataToValidate.Mid(startEndPoint,numEndBytes)); |
303 const TPtrC8& midDataToValidate = dataToValidate.Mid(startEndPoint,numEndBytes); |
275 RDebug::Printf("\n"); |
304 OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP60, "", midDataToValidate.Ptr(), midDataToValidate.Length()); |
|
305 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP11, "\n"); |
|
306 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT_DUP01, this, EFalse ); |
|
307 return EFalse; |
276 return EFalse; |
308 } |
277 } |
309 } |
278 } |
310 for(TInt i=0; i<fullRepeats; i++) |
279 for(TInt i=0; i<fullRepeats; i++) |
311 { |
280 { |
312 if(dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()).Compare(aDataPattern) != 0) |
281 if(dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()).Compare(aDataPattern) != 0) |
313 { |
282 { |
314 OstTrace1(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP12, "ROUND TRIP VALIDATION: Repeated Bytes Match Failure, Repeat %d",i); |
283 RDebug::Printf("ROUND TRIP VALIDATION: Repeated Bytes Match Failure, Repeat %d",i); |
315 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP13, "sent data middle block ..."); |
284 RDebug::Printf("sent data middle block ..."); |
316 OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP53, "", aDataPattern.Ptr(), aDataPattern.Length()); |
285 RDebug::RawPrint(aDataPattern); |
317 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP14, "\n"); |
286 RDebug::Printf("\n"); |
318 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP15, "ROUND TRIP VALIDATION: Middle block of returned data ..."); |
287 RDebug::Printf("ROUND TRIP VALIDATION: Middle block of returned data ..."); |
319 const TPtrC8& midDataToValidate = dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length()); |
288 RDebug::RawPrint(dataToValidate.Mid(numStartBytes + i*aDataPattern.Length(),aDataPattern.Length())); |
320 OstTraceData(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP55, "", midDataToValidate.Ptr(), midDataToValidate.Length()); |
289 RDebug::Printf("\n"); |
321 OstTrace0(TRACE_NORMAL, CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_DUP16, "\n"); |
|
322 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT_DUP02, this, EFalse ); |
|
323 return EFalse; //from 'for' loop |
290 return EFalse; //from 'for' loop |
324 } |
291 } |
325 } |
292 } |
326 OstTraceFunctionExitExt( CINTERFACESETTINGBASE_VALIDATECACHEDENDPOINTDATAL_EXIT_DUP03, this, ETrue ); |
|
327 return ETrue; |
293 return ETrue; |
328 } |
294 } |
329 |
295 |
330 |
296 |
331 void CInterfaceSettingBase::ReadDataFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber) |
297 void CInterfaceSettingBase::ReadDataFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber) |
332 { |
298 { |
333 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_READDATAFROMENDPOINTL_ENTRY, this ); |
299 LOG_FUNC |
334 // Access the correct readerer for the given endpoint |
300 // Access the correct readerer for the given endpoint |
335 // and prepare to read the data to be sent by the host |
301 // and prepare to read the data to be sent by the host |
336 iEndpointReaders[aEndpointNumber-1]->ReadL(aNumBytes); |
302 iEndpointReaders[aEndpointNumber-1]->ReadL(aNumBytes); |
337 OstTraceFunctionExit1( CINTERFACESETTINGBASE_READDATAFROMENDPOINTL_EXIT, this ); |
|
338 } |
303 } |
339 |
304 |
340 void CInterfaceSettingBase::CancelAnyReadDataFromEndpointL(TUint16 aEndpointNumber) |
305 void CInterfaceSettingBase::CancelAnyReadDataFromEndpointL(TUint16 aEndpointNumber) |
341 { |
306 { |
342 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_CANCELANYREADDATAFROMENDPOINTL_ENTRY, this ); |
307 LOG_FUNC |
343 // Access the correct writer for the given endpoint |
308 // Access the correct writer for the given endpoint |
344 // and cancel any outstanding write. This will not of course work for 'synchronous' writes. |
309 // and cancel any outstanding write. This will not of course work for 'synchronous' writes. |
345 iEndpointReaders[aEndpointNumber-1]->Cancel(); |
310 iEndpointReaders[aEndpointNumber-1]->Cancel(); |
346 OstTraceFunctionExit1( CINTERFACESETTINGBASE_CANCELANYREADDATAFROMENDPOINTL_EXIT, this ); |
|
347 } |
311 } |
348 |
312 |
349 void CInterfaceSettingBase::ReadDataFromAndHaltEndpointL(TUint aNumBytes, TUint16 aEndpointNumber) |
313 void CInterfaceSettingBase::ReadDataFromAndHaltEndpointL(TUint aNumBytes, TUint16 aEndpointNumber) |
350 { |
314 { |
351 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_READDATAFROMANDHALTENDPOINTL_ENTRY, this ); |
315 LOG_FUNC |
352 // Access the correct reader for the given endpoint |
316 // Access the correct reader for the given endpoint |
353 // and prepare to read the data to be sent by the host |
317 // and prepare to read the data to be sent by the host |
354 iEndpointReaders[aEndpointNumber-1]->ReadAndHaltL(aNumBytes); |
318 iEndpointReaders[aEndpointNumber-1]->ReadAndHaltL(aNumBytes); |
355 OstTraceFunctionExit1( CINTERFACESETTINGBASE_READDATAFROMANDHALTENDPOINTL_EXIT, this ); |
|
356 } |
319 } |
357 |
320 |
358 void CInterfaceSettingBase::RepeatedReadAndValidateFromEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerRead, TUint aTotalNumBytes, TUint16 aEndpointNumber) |
321 void CInterfaceSettingBase::RepeatedReadAndValidateFromEndpointL(const TDesC8& aDataPattern, TUint aNumBytesPerRead, TUint aTotalNumBytes, TUint16 aEndpointNumber) |
359 { |
322 { |
360 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_REPEATEDREADANDVALIDATEFROMENDPOINTL_ENTRY, this ); |
323 LOG_FUNC |
361 // Access the correct reader for the given endpoint |
324 // Access the correct reader for the given endpoint |
362 // and prepare to read the data to be sent by the host |
325 // and prepare to read the data to be sent by the host |
363 // using multiple 'Reads' |
326 // using multiple 'Reads' |
364 iEndpointReaders[aEndpointNumber-1]->RepeatedReadAndValidateL(aDataPattern, aNumBytesPerRead, aTotalNumBytes); |
327 iEndpointReaders[aEndpointNumber-1]->RepeatedReadAndValidateL(aDataPattern, aNumBytesPerRead, aTotalNumBytes); |
365 OstTraceFunctionExit1( CINTERFACESETTINGBASE_REPEATEDREADANDVALIDATEFROMENDPOINTL_EXIT, this ); |
|
366 } |
328 } |
367 |
329 |
368 void CInterfaceSettingBase::ReadDataUntilShortFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber) |
330 void CInterfaceSettingBase::ReadDataUntilShortFromEndpointL(TUint aNumBytes, TUint16 aEndpointNumber) |
369 { |
331 { |
370 OstTraceFunctionEntryExt( CINTERFACESETTINGBASE_READDATAUNTILSHORTFROMENDPOINTL_ENTRY, this ); |
332 LOG_FUNC |
371 // Access the correct reader for the given endpoint |
333 // Access the correct reader for the given endpoint |
372 // and prepare to read the data to be sent by the host |
334 // and prepare to read the data to be sent by the host |
373 iEndpointReaders[aEndpointNumber-1]->ReadUntilShortL(aNumBytes); |
335 iEndpointReaders[aEndpointNumber-1]->ReadUntilShortL(aNumBytes); |
374 OstTraceFunctionExit1( CINTERFACESETTINGBASE_READDATAUNTILSHORTFROMENDPOINTL_EXIT, this ); |
336 } |
375 } |
337 } |
376 } |
338 |
377 |
339 |
378 |
|