65 CMmDataPortHandler* aMmDataPortHandler, |
65 CMmDataPortHandler* aMmDataPortHandler, |
66 const RComm& aDataPort ) |
66 const RComm& aDataPort ) |
67 { |
67 { |
68 |
68 |
69 TFLOGSTRING("TSY: CDataPortWriter::NewL"); |
69 TFLOGSTRING("TSY: CDataPortWriter::NewL"); |
70 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_NEWL, "CDataPortWriter::NewL" ); |
70 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_NEWL_TD, "CDataPortWriter::NewL" ); |
71 |
71 |
72 CDataPortWriter* writer = new ( ELeave ) CDataPortWriter(); |
72 CDataPortWriter* writer = new ( ELeave ) CDataPortWriter(); |
73 CleanupStack::PushL( writer ); |
73 CleanupStack::PushL( writer ); |
74 |
74 |
75 writer->iDataPortHandler = aMmDataPortHandler; |
75 writer->iDataPortHandler = aMmDataPortHandler; |
92 CDataPortWriter::CDataPortWriter() |
92 CDataPortWriter::CDataPortWriter() |
93 : CActive( EPriorityStandard ), iDataToDpPtr( NULL, 0 ) |
93 : CActive( EPriorityStandard ), iDataToDpPtr( NULL, 0 ) |
94 { |
94 { |
95 //None |
95 //None |
96 TFLOGSTRING("TSY: CDataPortWriter::CDataPortWriter"); |
96 TFLOGSTRING("TSY: CDataPortWriter::CDataPortWriter"); |
97 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_CDATAPORTWRITER, "CDataPortWriter::CDataPortWriter" ); |
97 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_CDATAPORTWRITER_TD, "CDataPortWriter::CDataPortWriter" ); |
98 |
98 |
99 } |
99 } |
100 |
100 |
101 // ---------------------------------------------------------------------------- |
101 // ---------------------------------------------------------------------------- |
102 // CDataPortWriter::ConstructL |
102 // CDataPortWriter::ConstructL |
105 // |
105 // |
106 void CDataPortWriter::ConstructL() |
106 void CDataPortWriter::ConstructL() |
107 { |
107 { |
108 |
108 |
109 TFLOGSTRING("TSY: CDataPortWriter::ConstructL"); |
109 TFLOGSTRING("TSY: CDataPortWriter::ConstructL"); |
110 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_CONSTRUCTL, "CDataPortWriter::ConstructL" ); |
110 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_CONSTRUCTL_TD, "CDataPortWriter::ConstructL" ); |
111 |
111 |
112 // initialisation of menber variables |
112 // initialisation of menber variables |
113 iWriteCompleted = ETrue; |
113 iWriteCompleted = ETrue; |
114 iContinueWrite = ETrue; |
114 iContinueWrite = ETrue; |
115 iWriteBuffer = new ( ELeave ) CArrayPtrSeg<HBufC8>( |
115 iWriteBuffer = new ( ELeave ) CArrayPtrSeg<HBufC8>( |
154 // |
154 // |
155 void CDataPortWriter::Init() |
155 void CDataPortWriter::Init() |
156 { |
156 { |
157 |
157 |
158 TFLOGSTRING("TSY: CDataPortWriter::Init Modem initialisation"); |
158 TFLOGSTRING("TSY: CDataPortWriter::Init Modem initialisation"); |
159 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_INIT, "CDataPortWriter::Init" ); |
159 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_INIT_TD, "CDataPortWriter::Init" ); |
160 |
160 |
161 // Initalise modem |
161 // Initalise modem |
162 TBuf8<KDataBufLength> ATString; |
162 TBuf8<KDataBufLength> ATString; |
163 |
163 |
164 // Common Initialisations |
164 // Common Initialisations |
179 void CDataPortWriter::AppendCommandL( |
179 void CDataPortWriter::AppendCommandL( |
180 TLastAtCommandSent aCommand ) |
180 TLastAtCommandSent aCommand ) |
181 { |
181 { |
182 |
182 |
183 TFLOGSTRING("TSY: CDataPortWriter::AppendCommandL"); |
183 TFLOGSTRING("TSY: CDataPortWriter::AppendCommandL"); |
184 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_APPENDCOMMANDL, "CDataPortWriter::AppendCommandL" ); |
184 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_APPENDCOMMANDL_TD, "CDataPortWriter::AppendCommandL" ); |
185 |
185 |
186 iAtCommandBuffer->AppendL( aCommand ); |
186 iAtCommandBuffer->AppendL( aCommand ); |
187 } |
187 } |
188 |
188 |
189 // ---------------------------------------------------------------------------- |
189 // ---------------------------------------------------------------------------- |
194 // |
194 // |
195 CArrayFixFlat<TUint>* CDataPortWriter::GetAtBuffer() |
195 CArrayFixFlat<TUint>* CDataPortWriter::GetAtBuffer() |
196 { |
196 { |
197 |
197 |
198 TFLOGSTRING("TSY: CDataPortWriter::GetAtBuffer"); |
198 TFLOGSTRING("TSY: CDataPortWriter::GetAtBuffer"); |
199 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_GETATBUFFER, "CDataPortWriter::GetAtBuffer" ); |
199 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_GETATBUFFER_TD, "CDataPortWriter::GetAtBuffer" ); |
200 |
200 |
201 return iAtCommandBuffer; |
201 return iAtCommandBuffer; |
202 } |
202 } |
203 |
203 |
204 // ---------------------------------------------------------------------------- |
204 // ---------------------------------------------------------------------------- |
211 const TDesC8& aData, |
211 const TDesC8& aData, |
212 TLastAtCommandSent aCommand ) |
212 TLastAtCommandSent aCommand ) |
213 { |
213 { |
214 |
214 |
215 TFLOGSTRING("TSY: CDataPortWriter::Write"); |
215 TFLOGSTRING("TSY: CDataPortWriter::Write"); |
216 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_WRITE, "CDataPortWriter::Write" ); |
216 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_WRITE_TD, "CDataPortWriter::Write" ); |
217 |
217 |
218 // We are writing data so set the flag to ETrue. |
218 // We are writing data so set the flag to ETrue. |
219 iContinueWrite = ETrue; |
219 iContinueWrite = ETrue; |
220 |
220 |
221 #ifdef TF_LOGGING_ENABLED |
221 #ifdef TF_LOGGING_ENABLED |
230 data16bit.Copy( aData.Left( aData.Length() ) ); |
230 data16bit.Copy( aData.Left( aData.Length() ) ); |
231 } |
231 } |
232 |
232 |
233 TFLOGSTRING2("TSY: CDataPortWriter::Write - Stored into FIFO buffer: %S", &data16bit ); |
233 TFLOGSTRING2("TSY: CDataPortWriter::Write - Stored into FIFO buffer: %S", &data16bit ); |
234 |
234 |
235 OstTraceExt1( TRACE_NORMAL, DUP1_CDATAPORTWRITER_WRITE, "CDataPortWriter::Write;Stored into FIFO buffer=%S", data16bit ); |
235 OstTraceExt1( TRACE_NORMAL, DUP1_CDATAPORTWRITER_WRITE_TD, "CDataPortWriter::Write;Stored into FIFO buffer=%S", data16bit ); |
236 #endif // TF_LOGGING_ENABLED |
236 #endif // TF_LOGGING_ENABLED |
237 |
237 |
238 HBufC8* tmp = NULL; |
238 HBufC8* tmp = NULL; |
239 TInt commandError( KErrNone ); |
239 TInt commandError( KErrNone ); |
240 |
240 |
280 data16bit.Copy( aData.Left( aData.Length() ) ); |
280 data16bit.Copy( aData.Left( aData.Length() ) ); |
281 } |
281 } |
282 |
282 |
283 TFLOGSTRING2("TSY: CDataPortWriter::Write - From FIFO buffer: %S", &data16bit); |
283 TFLOGSTRING2("TSY: CDataPortWriter::Write - From FIFO buffer: %S", &data16bit); |
284 |
284 |
285 OstTraceExt1( TRACE_NORMAL, DUP2_CDATAPORTWRITER_WRITE, "CDataPortWriter::Write;From FIFO buffer=%S", data16bit ); |
285 OstTraceExt1( TRACE_NORMAL, DUP2_CDATAPORTWRITER_WRITE_TD, "CDataPortWriter::Write;From FIFO buffer=%S", data16bit ); |
286 #endif // TF_LOGGING_ENABLED |
286 #endif // TF_LOGGING_ENABLED |
287 |
287 |
288 if ( !IsActive() ) |
288 if ( !IsActive() ) |
289 { |
289 { |
290 SetActive(); |
290 SetActive(); |
317 // |
317 // |
318 void CDataPortWriter::RunL() |
318 void CDataPortWriter::RunL() |
319 { |
319 { |
320 |
320 |
321 TFLOGSTRING("TSY: CDataPortWriter::RunL"); |
321 TFLOGSTRING("TSY: CDataPortWriter::RunL"); |
322 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_RUNL, "CDataPortWriter::RunL" ); |
322 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_RUNL_TD, "CDataPortWriter::RunL" ); |
323 |
323 |
324 #ifdef TF_LOGGING_ENABLED |
324 #ifdef TF_LOGGING_ENABLED |
325 |
325 |
326 TBuf< KDataBufLength > data16bit; |
326 TBuf< KDataBufLength > data16bit; |
327 data16bit.AppendNum( iStatus.Int() ); |
327 data16bit.AppendNum( iStatus.Int() ); |
328 |
328 |
329 TFLOGSTRING2("TSY: CDataPortWriter::RunL - iStatus: %S", &data16bit); |
329 TFLOGSTRING2("TSY: CDataPortWriter::RunL - iStatus: %S", &data16bit); |
330 OstTrace1( TRACE_NORMAL, DUP2_CDATAPORTWRITER_RUNL, "CDataPortWriter::RunL;iStatus: %d", iStatus.Int() ); |
330 OstTrace1( TRACE_NORMAL, DUP2_CDATAPORTWRITER_RUNL_TD, "CDataPortWriter::RunL;iStatus: %d", iStatus.Int() ); |
331 #endif // TF_LOGGING_ENABLED |
331 #endif // TF_LOGGING_ENABLED |
332 |
332 |
333 if ( KRequestPending != iStatus.Int() ) |
333 if ( KRequestPending != iStatus.Int() ) |
334 { |
334 { |
335 // If write buffer has data, delete first element. |
335 // If write buffer has data, delete first element. |
350 data16bit.Copy( iWriteBuffer->At( 0 )->Left( |
350 data16bit.Copy( iWriteBuffer->At( 0 )->Left( |
351 iWriteBuffer->At( 0 )->Length() ) ); |
351 iWriteBuffer->At( 0 )->Length() ) ); |
352 } |
352 } |
353 |
353 |
354 TFLOGSTRING2("TSY: CDataPortWriter::RunL - AT command deleted from FIFO buffer: %S", &data16bit); |
354 TFLOGSTRING2("TSY: CDataPortWriter::RunL - AT command deleted from FIFO buffer: %S", &data16bit); |
355 OstTraceExt1( TRACE_NORMAL, DUP1_CDATAPORTWRITER_RUNL, "CDataPortWriter::RunL;AT command deleted from FIFO buffer=%S", data16bit ); |
355 OstTraceExt1( TRACE_NORMAL, DUP1_CDATAPORTWRITER_RUNL_TD, "CDataPortWriter::RunL;AT command deleted from FIFO buffer=%S", data16bit ); |
356 #endif // TF_LOGGING_ENABLED |
356 #endif // TF_LOGGING_ENABLED |
357 |
357 |
358 if ( iWriteBuffer->At( 0 ) ) |
358 if ( iWriteBuffer->At( 0 ) ) |
359 { |
359 { |
360 // Delete the data from heap |
360 // Delete the data from heap |
383 TInt CDataPortWriter::RunError( |
383 TInt CDataPortWriter::RunError( |
384 TInt aError ) |
384 TInt aError ) |
385 { |
385 { |
386 |
386 |
387 TFLOGSTRING2("TSY: CDataPortWriter::RunError %d", aError); |
387 TFLOGSTRING2("TSY: CDataPortWriter::RunError %d", aError); |
388 OstTrace1( TRACE_NORMAL, CDATAPORTWRITER_RUNERROR, "CDataPortWriter::RunError;aError=%d", aError ); |
388 OstTrace1( TRACE_NORMAL, CDATAPORTWRITER_RUNERROR_TD, "CDataPortWriter::RunError;aError=%d", aError ); |
389 |
389 |
390 // Line object completes client requests in case of an error. |
390 // Line object completes client requests in case of an error. |
391 iDataPortHandler->HandleDataPortError( aError ); |
391 iDataPortHandler->HandleDataPortError( aError ); |
392 // Cancel writes if active. |
392 // Cancel writes if active. |
393 Cancel(); |
393 Cancel(); |
424 // |
424 // |
425 void CDataPortWriter::WriteNextL() |
425 void CDataPortWriter::WriteNextL() |
426 { |
426 { |
427 |
427 |
428 TFLOGSTRING("TSY: CDataPortWriter::WriteNextL - Write next command from FIFO"); |
428 TFLOGSTRING("TSY: CDataPortWriter::WriteNextL - Write next command from FIFO"); |
429 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_WRITENEXTL, "CDataPortWriter::WriteNextL, Write next command from FIFO" ); |
429 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_WRITENEXTL_TD, "CDataPortWriter::WriteNextL, Write next command from FIFO" ); |
430 |
430 |
431 if ( !IsActive() ) |
431 if ( !IsActive() ) |
432 { |
432 { |
433 iWriteCompleted = ETrue; |
433 iWriteCompleted = ETrue; |
434 User::LeaveIfError( iStatus.Int() ); |
434 User::LeaveIfError( iStatus.Int() ); |
462 data16bit.Copy( iDataToDpPtr.Left( iDataToDpPtr.Length() ) ); |
462 data16bit.Copy( iDataToDpPtr.Left( iDataToDpPtr.Length() ) ); |
463 } |
463 } |
464 |
464 |
465 TFLOGSTRING2("TSY: CDataPortWriter::WriteNextL - AT command: %S", &data16bit); |
465 TFLOGSTRING2("TSY: CDataPortWriter::WriteNextL - AT command: %S", &data16bit); |
466 |
466 |
467 OstTraceExt1( TRACE_NORMAL, DUP1_CDATAPORTWRITER_WRITENEXTL, "CDataPortWriter::WriteNextL;AT command=%S", data16bit ); |
467 OstTraceExt1( TRACE_NORMAL, DUP1_CDATAPORTWRITER_WRITENEXTL_TD, "CDataPortWriter::WriteNextL;AT command=%S", data16bit ); |
468 #endif //TF_LOGGING_ENABLED |
468 #endif //TF_LOGGING_ENABLED |
469 |
469 |
470 // Set active as write is pending |
470 // Set active as write is pending |
471 if ( !IsActive() ) |
471 if ( !IsActive() ) |
472 { |
472 { |
487 // |
487 // |
488 void CDataPortWriter::DoCancel() |
488 void CDataPortWriter::DoCancel() |
489 { |
489 { |
490 |
490 |
491 TFLOGSTRING("CDataPortWriter::DoCancel"); |
491 TFLOGSTRING("CDataPortWriter::DoCancel"); |
492 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_DOCANCEL, "CDataPortWriter::DoCancel" ); |
492 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_DOCANCEL_TD, "CDataPortWriter::DoCancel" ); |
493 |
493 |
494 // Stop writing into DP |
494 // Stop writing into DP |
495 iContinueWrite = EFalse; |
495 iContinueWrite = EFalse; |
496 iDataPort.WriteCancel(); |
496 iDataPort.WriteCancel(); |
497 iWriteCompleted = ETrue; |
497 iWriteCompleted = ETrue; |
505 // |
505 // |
506 void CDataPortWriter::BlockWrite() |
506 void CDataPortWriter::BlockWrite() |
507 { |
507 { |
508 |
508 |
509 TFLOGSTRING("TSY: CDataPortWriter::BlockWrite - Blocking writes to DP"); |
509 TFLOGSTRING("TSY: CDataPortWriter::BlockWrite - Blocking writes to DP"); |
510 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_BLOCKWRITE, "CDataPortWriter::BlockWrite" ); |
510 OstTrace0( TRACE_NORMAL, CDATAPORTWRITER_BLOCKWRITE_TD, "CDataPortWriter::BlockWrite" ); |
511 |
511 |
512 // Stop writing into DP until DP reader has flushed RX buffer |
512 // Stop writing into DP until DP reader has flushed RX buffer |
513 iContinueWrite = EFalse; |
513 iContinueWrite = EFalse; |
514 iWriteCompleted = EFalse; |
514 iWriteCompleted = EFalse; |
515 } |
515 } |
525 const RComm& aDataPort, |
525 const RComm& aDataPort, |
526 CDataPortWriter* aDataPortWriter ) |
526 CDataPortWriter* aDataPortWriter ) |
527 { |
527 { |
528 |
528 |
529 TFLOGSTRING("TSY: CDataPortReader::NewL"); |
529 TFLOGSTRING("TSY: CDataPortReader::NewL"); |
530 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_NEWL, "CDataPortReader::NewL" ); |
530 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_NEWL_TD, "CDataPortReader::NewL" ); |
531 |
531 |
532 CDataPortReader* reader = new ( ELeave ) CDataPortReader(); |
532 CDataPortReader* reader = new ( ELeave ) CDataPortReader(); |
533 CleanupStack::PushL( reader ); |
533 CleanupStack::PushL( reader ); |
534 |
534 |
535 reader->iDataPortHandler = aDataPortHandler; |
535 reader->iDataPortHandler = aDataPortHandler; |
552 CDataPortReader::CDataPortReader() |
552 CDataPortReader::CDataPortReader() |
553 : CActive( EPriorityStandard ) |
553 : CActive( EPriorityStandard ) |
554 { |
554 { |
555 |
555 |
556 TFLOGSTRING("TSY: CDataPortReader::CDataPortReader"); |
556 TFLOGSTRING("TSY: CDataPortReader::CDataPortReader"); |
557 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_CDATAPORTREADER, "CDataPortReader::CDataPortReader" ); |
557 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_CDATAPORTREADER_TD, "CDataPortReader::CDataPortReader" ); |
558 |
558 |
559 // initialisation of meneber variables |
559 // initialisation of meneber variables |
560 iModemInitComplete = EFalse; |
560 iModemInitComplete = EFalse; |
561 iContinueRead = ETrue; |
561 iContinueRead = ETrue; |
562 iReaAllComplete = ETrue; |
562 iReaAllComplete = ETrue; |
584 // |
584 // |
585 void CDataPortReader::DoCancel() |
585 void CDataPortReader::DoCancel() |
586 { |
586 { |
587 |
587 |
588 TFLOGSTRING("CDataPortReader::DoCancel"); |
588 TFLOGSTRING("CDataPortReader::DoCancel"); |
589 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_DOCANCEL, "CDataPortReader::DoCancel" ); |
589 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_DOCANCEL_TD, "CDataPortReader::DoCancel" ); |
590 |
590 |
591 // Stop reading from DP |
591 // Stop reading from DP |
592 iContinueRead = EFalse; |
592 iContinueRead = EFalse; |
593 iDataPort.ReadCancel(); |
593 iDataPort.ReadCancel(); |
594 } |
594 } |
601 // |
601 // |
602 void CDataPortReader::Read() |
602 void CDataPortReader::Read() |
603 { |
603 { |
604 |
604 |
605 TFLOGSTRING("TSY: CDataPortReader::Read Start reading"); |
605 TFLOGSTRING("TSY: CDataPortReader::Read Start reading"); |
606 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_READ, "CDataPortReader::Read" ); |
606 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_READ_TD, "CDataPortReader::Read" ); |
607 |
607 |
608 iContinueRead = ETrue; |
608 iContinueRead = ETrue; |
609 // If already active, don't make a new request |
609 // If already active, don't make a new request |
610 if ( !IsActive() ) |
610 if ( !IsActive() ) |
611 { |
611 { |
625 // |
625 // |
626 void CDataPortReader::ReadAll() |
626 void CDataPortReader::ReadAll() |
627 { |
627 { |
628 |
628 |
629 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Read all data from DP"); |
629 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Read all data from DP"); |
630 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_READALL, "CDataPortReader::ReadAll, Read all data from DP" ); |
630 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_READALL_TD, "CDataPortReader::ReadAll, Read all data from DP" ); |
631 |
631 |
632 iContinueRead = ETrue; |
632 iContinueRead = ETrue; |
633 |
633 |
634 // First get remaining data length in DP |
634 // First get remaining data length in DP |
635 TInt dataLen = iDataPort.QueryReceiveBuffer(); |
635 TInt dataLen = iDataPort.QueryReceiveBuffer(); |
639 if ( ( 0 < dataLen ) && ( EFalse != iModemInitComplete ) ) |
639 if ( ( 0 < dataLen ) && ( EFalse != iModemInitComplete ) ) |
640 { |
640 { |
641 |
641 |
642 TFLOGSTRING2("TSY: CDataPortReader::ReadAll - Data remaining: %d", |
642 TFLOGSTRING2("TSY: CDataPortReader::ReadAll - Data remaining: %d", |
643 dataLen ); |
643 dataLen ); |
644 OstTrace1( TRACE_NORMAL, DUP1_CDATAPORTREADER_READALL, "CDataPortReader::ReadAll;Data remaining=%d", dataLen ); |
644 OstTrace1( TRACE_NORMAL, DUP1_CDATAPORTREADER_READALL_TD, "CDataPortReader::ReadAll;Data remaining=%d", dataLen ); |
645 // Block DP writer, so that it does not generate more |
645 // Block DP writer, so that it does not generate more |
646 // responses from modem. Continue when RX buffer is empty. |
646 // responses from modem. Continue when RX buffer is empty. |
647 iDataPortWriter->BlockWrite(); |
647 iDataPortWriter->BlockWrite(); |
648 // Set read all complete flag to false |
648 // Set read all complete flag to false |
649 iReaAllComplete = EFalse; |
649 iReaAllComplete = EFalse; |
650 // If already active, don't make a new request. Wait for RunL |
650 // If already active, don't make a new request. Wait for RunL |
651 if ( !IsActive() ) |
651 if ( !IsActive() ) |
652 { |
652 { |
653 |
653 |
654 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Starting to read remaining data (flushing)"); |
654 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Starting to read remaining data (flushing)"); |
655 OstTrace0( TRACE_NORMAL, DUP2_CDATAPORTREADER_READALL, "CDataPortReader::ReadAll, Starting to read remaining data (flushing)" ); |
655 OstTrace0( TRACE_NORMAL, DUP2_CDATAPORTREADER_READALL_TD, "CDataPortReader::ReadAll, Starting to read remaining data (flushing)" ); |
656 |
656 |
657 iResp.SetLength( 0 ); |
657 iResp.SetLength( 0 ); |
658 iDataPort.Read( iStatus, iResp ); |
658 iDataPort.Read( iStatus, iResp ); |
659 SetActive(); |
659 SetActive(); |
660 } |
660 } |
661 else |
661 else |
662 { |
662 { |
663 |
663 |
664 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Read still pending!"); |
664 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Read still pending!"); |
665 OstTrace0( TRACE_NORMAL, DUP3_CDATAPORTREADER_READALL, "CDataPortReader::ReadAll, Read still pending!" ); |
665 OstTrace0( TRACE_NORMAL, DUP3_CDATAPORTREADER_READALL_TD, "CDataPortReader::ReadAll, Read still pending!" ); |
666 } |
666 } |
667 } |
667 } |
668 else |
668 else |
669 { |
669 { |
670 |
670 |
671 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Init going or no data in RX"); |
671 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Init going or no data in RX"); |
672 OstTrace0( TRACE_NORMAL, DUP4_CDATAPORTREADER_READALL, "CDataPortReader::ReadAll, Init going or no data in RX" ); |
672 OstTrace0( TRACE_NORMAL, DUP4_CDATAPORTREADER_READALL_TD, "CDataPortReader::ReadAll, Init going or no data in RX" ); |
673 if ( 0 >= dataLen ) |
673 if ( 0 >= dataLen ) |
674 { |
674 { |
675 // Set read all complete flag to true, there is no data waiting |
675 // Set read all complete flag to true, there is no data waiting |
676 iReaAllComplete = ETrue; |
676 iReaAllComplete = ETrue; |
677 } |
677 } |
680 // Read data if not already |
680 // Read data if not already |
681 if ( !IsActive() ) |
681 if ( !IsActive() ) |
682 { |
682 { |
683 |
683 |
684 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Start normal reading"); |
684 TFLOGSTRING("TSY: CDataPortReader::ReadAll - Start normal reading"); |
685 OstTrace0( TRACE_NORMAL, DUP5_CDATAPORTREADER_READALL, "CDataPortReader::ReadAll, Start normal reading" ); |
685 OstTrace0( TRACE_NORMAL, DUP5_CDATAPORTREADER_READALL_TD, "CDataPortReader::ReadAll, Start normal reading" ); |
686 |
686 |
687 iResp.SetLength( 0 ); |
687 iResp.SetLength( 0 ); |
688 iDataPort.Read( iStatus, iResp ); |
688 iDataPort.Read( iStatus, iResp ); |
689 SetActive(); |
689 SetActive(); |
690 } |
690 } |
700 // |
700 // |
701 void CDataPortReader::ReadCancel() |
701 void CDataPortReader::ReadCancel() |
702 { |
702 { |
703 |
703 |
704 TFLOGSTRING("TSY: CDataPortReader::ReadCancel"); |
704 TFLOGSTRING("TSY: CDataPortReader::ReadCancel"); |
705 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_READCANCEL, "CDataPortReader::ReadCancel" ); |
705 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_READCANCEL_TD, "CDataPortReader::ReadCancel" ); |
706 |
706 |
707 // Stop reading from DP |
707 // Stop reading from DP |
708 iContinueRead = EFalse; |
708 iContinueRead = EFalse; |
709 iDataPort.ReadCancel(); |
709 iDataPort.ReadCancel(); |
710 } |
710 } |
717 // |
717 // |
718 void CDataPortReader::ModemInitComplete() |
718 void CDataPortReader::ModemInitComplete() |
719 { |
719 { |
720 |
720 |
721 TFLOGSTRING("TSY: CDataPortReader::ModemInitComplete"); |
721 TFLOGSTRING("TSY: CDataPortReader::ModemInitComplete"); |
722 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_MODEMINITCOMPLETE, "CDataPortReader::ModemInitComplete" ); |
722 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_MODEMINITCOMPLETE_TD, "CDataPortReader::ModemInitComplete" ); |
723 |
723 |
724 iModemInitComplete = ETrue; |
724 iModemInitComplete = ETrue; |
725 } |
725 } |
726 |
726 |
727 // ---------------------------------------------------------------------------- |
727 // ---------------------------------------------------------------------------- |
732 // |
732 // |
733 void CDataPortReader::RunL() |
733 void CDataPortReader::RunL() |
734 { |
734 { |
735 |
735 |
736 TFLOGSTRING("TSY: CDataPortReader::RunL"); |
736 TFLOGSTRING("TSY: CDataPortReader::RunL"); |
737 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_RUNL, "CDataPortReader::RunL" ); |
737 OstTrace0( TRACE_NORMAL, CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL" ); |
738 |
738 |
739 #ifdef TF_LOGGING_ENABLED |
739 #ifdef TF_LOGGING_ENABLED |
740 |
740 |
741 TBuf< KDataBufLength > data16bit; |
741 TBuf< KDataBufLength > data16bit; |
742 data16bit.AppendNum( iStatus.Int() ); |
742 data16bit.AppendNum( iStatus.Int() ); |
743 |
743 |
744 TFLOGSTRING2("TSY: CDataPortReader::RunL - iStatus:%S", &data16bit); |
744 TFLOGSTRING2("TSY: CDataPortReader::RunL - iStatus:%S", &data16bit); |
745 OstTrace1( TRACE_NORMAL, DUP1_CDATAPORTREADER_RUNL, "CDataPortReader::RunL;iStatus=%d", iStatus.Int() ); |
745 OstTrace1( TRACE_NORMAL, DUP1_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL;iStatus=%d", iStatus.Int() ); |
746 #endif // TF_LOGGING_ENABLED |
746 #endif // TF_LOGGING_ENABLED |
747 |
747 |
748 // KErrNone and KErrCancel are ok, others mean real error |
748 // KErrNone and KErrCancel are ok, others mean real error |
749 TInt ret( iStatus.Int() ); |
749 TInt ret( iStatus.Int() ); |
750 if ( KErrNone == ret || KErrCancel == ret ) |
750 if ( KErrNone == ret || KErrCancel == ret ) |
762 { |
762 { |
763 data16bit.Copy( iResp.Left( iResp.Length() ) ); |
763 data16bit.Copy( iResp.Left( iResp.Length() ) ); |
764 } |
764 } |
765 const TDesC16 help = data16bit; |
765 const TDesC16 help = data16bit; |
766 TFLOGSTRING2("TSY: CDataPortReader::Read Data: %S", &data16bit); |
766 TFLOGSTRING2("TSY: CDataPortReader::Read Data: %S", &data16bit); |
767 OstTraceExt1( TRACE_NORMAL, DUP2_CDATAPORTREADER_RUNL, "CDataPortReader::RunL;data16bit=%S", help ); |
767 OstTraceExt1( TRACE_NORMAL, DUP2_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL;data16bit=%S", help ); |
768 #endif // TF_LOGGING_ENABLED |
768 #endif // TF_LOGGING_ENABLED |
769 |
769 |
770 // If flushing the dataport and modem from last connection, |
770 // If flushing the dataport and modem from last connection, |
771 // continue until RX buffer is empty |
771 // continue until RX buffer is empty |
772 if ( EFalse == iReaAllComplete ) |
772 if ( EFalse == iReaAllComplete ) |
785 if ( 0 < dataLen ) |
785 if ( 0 < dataLen ) |
786 { |
786 { |
787 |
787 |
788 TFLOGSTRING2("TSY: CDataPortReader::RunL - Data remaining: %d", dataLen ); |
788 TFLOGSTRING2("TSY: CDataPortReader::RunL - Data remaining: %d", dataLen ); |
789 |
789 |
790 OstTrace1( TRACE_NORMAL, DUP3_CDATAPORTREADER_RUNL, "CDataPortReader::RunL;Data remaining=%d", dataLen ); |
790 OstTrace1( TRACE_NORMAL, DUP3_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL;Data remaining=%d", dataLen ); |
791 } |
791 } |
792 else |
792 else |
793 { |
793 { |
794 |
794 |
795 TFLOGSTRING("TSY: CDataPortReader::RunL - RX buffer empty, normal read continuing"); |
795 TFLOGSTRING("TSY: CDataPortReader::RunL - RX buffer empty, normal read continuing"); |
796 OstTrace0( TRACE_NORMAL, DUP4_CDATAPORTREADER_RUNL, "CDataPortReader::RunL, RX buffer empty, normal read continuing" ); |
796 OstTrace0( TRACE_NORMAL, DUP4_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL, RX buffer empty, normal read continuing" ); |
797 |
797 |
798 iReaAllComplete = ETrue; |
798 iReaAllComplete = ETrue; |
799 // Request next write from iDataPortWriter |
799 // Request next write from iDataPortWriter |
800 iDataPortWriter->WriteNextL(); |
800 iDataPortWriter->WriteNextL(); |
801 } |
801 } |
835 |
835 |
836 if ( EFalse == iContinueRead ) |
836 if ( EFalse == iContinueRead ) |
837 { |
837 { |
838 |
838 |
839 TFLOGSTRING("TSY: CDataPortReader::RunL - Cancel reading"); |
839 TFLOGSTRING("TSY: CDataPortReader::RunL - Cancel reading"); |
840 OstTrace0( TRACE_NORMAL, DUP5_CDATAPORTREADER_RUNL, "CDataPortReader::RunL, Cancel reading" ); |
840 OstTrace0( TRACE_NORMAL, DUP5_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL, Cancel reading" ); |
841 |
841 |
842 iDataPort.ReadCancel(); |
842 iDataPort.ReadCancel(); |
843 } |
843 } |
844 else if ( !IsActive() ) |
844 else if ( !IsActive() ) |
845 { |
845 { |
846 |
846 |
847 TFLOGSTRING("TSY: CDataPortReader::RunL - Continue reading"); |
847 TFLOGSTRING("TSY: CDataPortReader::RunL - Continue reading"); |
848 OstTrace0( TRACE_NORMAL, DUP6_CDATAPORTREADER_RUNL, "CDataPortReader::RunL, Continue reading" ); |
848 OstTrace0( TRACE_NORMAL, DUP6_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL, Continue reading" ); |
849 // Make the reader read again... |
849 // Make the reader read again... |
850 iStatus = KRequestPending; |
850 iStatus = KRequestPending; |
851 iDataPort.Read( iStatus, iResp ); |
851 iDataPort.Read( iStatus, iResp ); |
852 SetActive(); |
852 SetActive(); |
853 } |
853 } |
854 } |
854 } |
855 else if ( !IsActive() && iContinueRead ) |
855 else if ( !IsActive() && iContinueRead ) |
856 { |
856 { |
857 |
857 |
858 TFLOGSTRING("TSY: CDataPortReader::RunL - Continue reading"); |
858 TFLOGSTRING("TSY: CDataPortReader::RunL - Continue reading"); |
859 OstTrace0( TRACE_NORMAL, DUP7_CDATAPORTREADER_RUNL, "CDataPortReader::RunL, Continue reading" ); |
859 OstTrace0( TRACE_NORMAL, DUP7_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL, Continue reading" ); |
860 // Make the reader read again... |
860 // Make the reader read again... |
861 iStatus = KRequestPending; |
861 iStatus = KRequestPending; |
862 iDataPort.Read( iStatus, iResp ); |
862 iDataPort.Read( iStatus, iResp ); |
863 SetActive(); |
863 SetActive(); |
864 } |
864 } |
868 // end using dataport. |
868 // end using dataport. |
869 else if ( KErrInUse == ret ) |
869 else if ( KErrInUse == ret ) |
870 { |
870 { |
871 |
871 |
872 TFLOGSTRING("TSY: CDataPortReader::RunL - Dataport used by other client"); |
872 TFLOGSTRING("TSY: CDataPortReader::RunL - Dataport used by other client"); |
873 OstTrace0( TRACE_NORMAL, DUP8_CDATAPORTREADER_RUNL, "CDataPortReader::RunL, Dataport used by other client" ); |
873 OstTrace0( TRACE_NORMAL, DUP8_CDATAPORTREADER_RUNL_TD, "CDataPortReader::RunL, Dataport used by other client" ); |
874 } |
874 } |
875 // These will make the next call object creation fail in |
875 // These will make the next call object creation fail in |
876 // CMmLineTsy::OpenNewObjectL as we can't handle these errors in TSY. |
876 // CMmLineTsy::OpenNewObjectL as we can't handle these errors in TSY. |
877 else |
877 else |
878 { |
878 { |
889 TInt CDataPortReader::RunError( |
889 TInt CDataPortReader::RunError( |
890 TInt aError ) |
890 TInt aError ) |
891 { |
891 { |
892 |
892 |
893 TFLOGSTRING2("TSY: CDataPortReader::RunError %d", aError); |
893 TFLOGSTRING2("TSY: CDataPortReader::RunError %d", aError); |
894 OstTrace1( TRACE_NORMAL, CDATAPORTREADER_RUNERROR, "CDataPortReader::RunError;aError=%d", aError ); |
894 OstTrace1( TRACE_NORMAL, CDATAPORTREADER_RUNERROR_TD, "CDataPortReader::RunError;aError=%d", aError ); |
895 |
895 |
896 iDataPortHandler->HandleDataPortError( aError ); |
896 iDataPortHandler->HandleDataPortError( aError ); |
897 |
897 |
898 return KErrNone; |
898 return KErrNone; |
899 } |
899 } |