15 // @internalComponent |
15 // @internalComponent |
16 // |
16 // |
17 // |
17 // |
18 |
18 |
19 #include "hosttransfers.h" |
19 #include "hosttransfers.h" |
|
20 #include "OstTraceDefinitions.h" |
|
21 #ifdef OST_TRACE_COMPILER_IN_USE |
|
22 #include "hostbulktransfersTraces.h" |
|
23 #endif |
20 #include <e32debug.h> |
24 #include <e32debug.h> |
21 |
25 |
22 namespace NUnitTesting_USBDI |
26 namespace NUnitTesting_USBDI |
23 { |
27 { |
24 |
28 |
25 |
29 |
26 CBulkTransfer::CBulkTransfer(RUsbPipe& aPipe,RUsbInterface& aInterface,TInt aMaxTransferSize,MTransferObserver& aObserver,TInt aTransferId) |
30 CBulkTransfer::CBulkTransfer(RUsbPipe& aPipe,RUsbInterface& aInterface,TInt aMaxTransferSize,MTransferObserver& aObserver,TInt aTransferId) |
27 : CBaseTransfer(aPipe,aInterface,aObserver,aTransferId), |
31 : CBaseTransfer(aPipe,aInterface,aObserver,aTransferId), |
28 iTransferDescriptor(aMaxTransferSize) // Allocate the buffer for bulk transfers |
32 iTransferDescriptor(aMaxTransferSize) // Allocate the buffer for bulk transfers |
29 { |
33 { |
|
34 OstTraceFunctionEntryExt( CBULKTRANSFER_CBULKTRANSFER_ENTRY, this ); |
30 |
35 |
31 // Register the transfer descriptor with the interface |
36 // Register the transfer descriptor with the interface |
32 |
37 |
33 TInt err(Interface().RegisterTransferDescriptor(iTransferDescriptor)); |
38 TInt err(Interface().RegisterTransferDescriptor(iTransferDescriptor)); |
34 if(err != KErrNone) |
39 if(err != KErrNone) |
35 { |
40 { |
36 RDebug::Printf("<Error %d> Unable to register transfer descriptor",err); |
41 OstTrace1(TRACE_NORMAL, CBULKTRANSFER_CBULKTRANSFER, "<Error %d> Unable to register transfer descriptor",err); |
37 } |
42 } |
|
43 OstTraceFunctionExit1( CBULKTRANSFER_CBULKTRANSFER_EXIT, this ); |
38 } |
44 } |
39 |
45 |
40 |
46 |
41 CBulkTransfer::~CBulkTransfer() |
47 CBulkTransfer::~CBulkTransfer() |
42 { |
48 { |
43 LOG_FUNC |
49 OstTraceFunctionEntry1( CBULKTRANSFER_CBULKTRANSFER_ENTRY_DUP01, this ); |
44 |
50 |
45 // Cancel the transfer |
51 // Cancel the transfer |
46 |
52 |
47 Cancel(); |
53 Cancel(); |
|
54 OstTraceFunctionExit1( CBULKTRANSFER_CBULKTRANSFER_EXIT_DUP01, this ); |
48 } |
55 } |
49 |
56 |
50 |
57 |
51 TPtrC8 CBulkTransfer::DataPolled() |
58 TPtrC8 CBulkTransfer::DataPolled() |
52 { |
59 { |
|
60 OstTraceFunctionEntry1( CBULKTRANSFER_DATAPOLLED_ENTRY, this ); |
53 return iTransferDescriptor.Buffer(); |
61 return iTransferDescriptor.Buffer(); |
54 } |
62 } |
55 |
63 |
56 |
64 |
57 void CBulkTransfer::TransferIn(TInt aExpectedDataSize) |
65 void CBulkTransfer::TransferIn(TInt aExpectedDataSize) |
58 { |
66 { |
59 LOG_FUNC |
67 OstTraceFunctionEntryExt( CBULKTRANSFER_TRANSFERIN_ENTRY, this ); |
60 |
68 |
61 // Activate the asynchronous transfer |
69 // Activate the asynchronous transfer |
62 |
70 |
63 RDebug::Printf("Activating bulk in transfer"); |
71 OstTrace0(TRACE_NORMAL, CBULKTRANSFER_TRANSFERIN, "Activating bulk in transfer"); |
64 iTransferDescriptor.SaveData(aExpectedDataSize); |
72 iTransferDescriptor.SaveData(aExpectedDataSize); |
65 Pipe().Transfer(iTransferDescriptor,iStatus); |
73 Pipe().Transfer(iTransferDescriptor,iStatus); |
66 SetActive(); |
74 SetActive(); |
|
75 OstTraceFunctionExit1( CBULKTRANSFER_TRANSFERIN_EXIT, this ); |
67 } |
76 } |
68 |
77 |
69 void CBulkTransfer::TransferOut(const TDesC8& aBulkData, TBool aUseZLPIfRequired) |
78 void CBulkTransfer::TransferOut(const TDesC8& aBulkData, TBool aUseZLPIfRequired) |
70 { |
79 { |
71 LOG_FUNC |
80 OstTraceFunctionEntryExt( CBULKTRANSFER_TRANSFEROUT_ENTRY, this ); |
72 |
81 |
73 // Copy the data across |
82 // Copy the data across |
74 if(aBulkData.Length() > iTransferDescriptor.iMaxSize) |
83 if(aBulkData.Length() > iTransferDescriptor.iMaxSize) |
75 { |
84 { |
76 RDebug::Printf("Too much data in bulk transfer. This test suite will now PANIC!"); |
85 OstTrace0(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT, "Too much data in bulk transfer. This test suite will now PANIC!"); |
77 RDebug::Printf("Bytes requested %d, Max allowed %d", aBulkData.Length(), iTransferDescriptor.iMaxSize); |
86 OstTraceExt2(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT_DUP01, "Bytes requested %d, Max allowed %d", aBulkData.Length(), iTransferDescriptor.iMaxSize); |
78 ASSERT(EFalse); |
87 ASSERT(EFalse); |
79 } |
88 } |
80 |
89 |
81 TPtr8 buffer = iTransferDescriptor.WritableBuffer(); |
90 TPtr8 buffer = iTransferDescriptor.WritableBuffer(); |
82 buffer.Copy(aBulkData); |
91 buffer.Copy(aBulkData); |
83 RDebug::Printf("Transfer buffer now has %d bytes to write",buffer.Length()); |
92 OstTrace1(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT_DUP02, "Transfer buffer now has %d bytes to write",buffer.Length()); |
84 iTransferDescriptor.SaveData(buffer.Length()); |
93 iTransferDescriptor.SaveData(buffer.Length()); |
85 if(aUseZLPIfRequired) |
94 if(aUseZLPIfRequired) |
86 { |
95 { |
87 iTransferDescriptor.SetZlpStatus(RUsbTransferDescriptor::ESendZlpIfRequired); |
96 iTransferDescriptor.SetZlpStatus(RUsbTransferDescriptor::ESendZlpIfRequired); |
88 } |
97 } |
91 iTransferDescriptor.SetZlpStatus(RUsbTransferDescriptor::ESuppressZlp); |
100 iTransferDescriptor.SetZlpStatus(RUsbTransferDescriptor::ESuppressZlp); |
92 } |
101 } |
93 |
102 |
94 // Activate the asynchronous transfer |
103 // Activate the asynchronous transfer |
95 |
104 |
96 RDebug::Printf("Activating bulk out transfer"); |
105 OstTrace0(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT_DUP03, "Activating bulk out transfer"); |
97 Pipe().Transfer(iTransferDescriptor,iStatus); |
106 Pipe().Transfer(iTransferDescriptor,iStatus); |
98 SetActive(); |
107 SetActive(); |
|
108 OstTraceFunctionExit1( CBULKTRANSFER_TRANSFEROUT_EXIT, this ); |
99 } |
109 } |
100 |
110 |
101 void CBulkTransfer::TransferOut(const TDesC8& aBulkDataPattern, TUint aNumBytes, TBool aUseZLPIfRequired) |
111 void CBulkTransfer::TransferOut(const TDesC8& aBulkDataPattern, TUint aNumBytes, TBool aUseZLPIfRequired) |
102 { |
112 { |
103 LOG_FUNC |
113 OstTraceFunctionEntryExt( CBULKTRANSFER_TRANSFEROUT_ENTRY_DUP01, this ); |
104 |
114 |
105 TransferOut(aBulkDataPattern, 0, aNumBytes, aUseZLPIfRequired); |
115 TransferOut(aBulkDataPattern, 0, aNumBytes, aUseZLPIfRequired); |
|
116 OstTraceFunctionExit1( CBULKTRANSFER_TRANSFEROUT_EXIT_DUP01, this ); |
106 } |
117 } |
107 |
118 |
108 |
119 |
109 void CBulkTransfer::TransferOut(const TDesC8& aBulkDataPattern, TUint aStartPoint, TUint aNumBytes, TBool aUseZLPIfRequired) |
120 void CBulkTransfer::TransferOut(const TDesC8& aBulkDataPattern, TUint aStartPoint, TUint aNumBytes, TBool aUseZLPIfRequired) |
110 { |
121 { |
111 LOG_FUNC |
122 OstTraceFunctionEntryExt( CBULKTRANSFER_TRANSFEROUT_ENTRY_DUP02, this ); |
112 |
123 |
113 // Copy the data across |
124 // Copy the data across |
114 if(aNumBytes > iTransferDescriptor.iMaxSize) |
125 if(aNumBytes > iTransferDescriptor.iMaxSize) |
115 { |
126 { |
116 RDebug::Printf("Too much data in bulk transfer. This test suite will now PANIC!"); |
127 OstTrace0(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT_DUP10, "Too much data in bulk transfer. This test suite will now PANIC!"); |
117 RDebug::Printf("Bytes requested %d, Max allowed %d", aNumBytes, iTransferDescriptor.iMaxSize); |
128 OstTraceExt2(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT_DUP11, "Bytes requested %d, Max allowed %d", aNumBytes, iTransferDescriptor.iMaxSize); |
118 ASSERT(EFalse); |
129 ASSERT(EFalse); |
119 } |
130 } |
120 if(aBulkDataPattern.Length()<=0) |
131 if(aBulkDataPattern.Length()<=0) |
121 { |
132 { |
122 RDebug::Printf("ZERO LENGTH data pattern used in TransferOut. This test suite will now PANIC!"); |
133 OstTrace0(TRACE_NORMAL, CBULKTRANSFER_TRANSFEROUT_DUP12, "ZERO LENGTH data pattern used in TransferOut. This test suite will now PANIC!"); |
123 ASSERT(EFalse); |
134 ASSERT(EFalse); |
124 } |
135 } |
125 TUint startPoint = aStartPoint%aBulkDataPattern.Length(); |
136 TUint startPoint = aStartPoint%aBulkDataPattern.Length(); |
126 TUint numStartBytes = (aBulkDataPattern.Length() - startPoint)%aBulkDataPattern.Length(); |
137 TUint numStartBytes = (aBulkDataPattern.Length() - startPoint)%aBulkDataPattern.Length(); |
127 TUint fullRepeats = (aNumBytes-numStartBytes)/aBulkDataPattern.Length(); |
138 TUint fullRepeats = (aNumBytes-numStartBytes)/aBulkDataPattern.Length(); |