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