44 if(IsActive()) |
44 if(IsActive()) |
45 { |
45 { |
46 RDebug::Print(_L(": CSimplexRead::StartL Warning - Already active\n")); |
46 RDebug::Print(_L(": CSimplexRead::StartL Warning - Already active\n")); |
47 return; |
47 return; |
48 } |
48 } |
49 //iBuffer.SetMax(); |
|
50 iCommPort->ReadOneOrMore(iStatus, iBuffer); |
49 iCommPort->ReadOneOrMore(iStatus, iBuffer); |
51 SetActive(); |
50 SetActive(); |
52 } |
51 } |
53 |
52 |
54 void CSimplexRead::RunL() |
53 void CSimplexRead::RunL() |
55 { |
54 { |
56 #ifdef _DEBUG |
55 #ifdef _DEBUG |
57 RDebug::Print(_L(": CSimplexRead::RunL - iStatus:%d iBuffer.Length:%d TotalAmount Left:%d\n"),iStatus.Int(),iBuffer.Length(),iTotalAmount); |
56 RDebug::Print(_L(": CSimplexRead::RunL - iStatus:%d iBuffer.Length:%d TotalAmount Left:%d\n"),iStatus.Int(),iBuffer.Length(),iTotalAmount); |
58 #endif |
57 #endif |
59 //RDebug::Print(_L(">%S<\n"),&iBuffer); |
|
60 //Notify Duplex object |
|
61 iDuplex.NotifyRead(iStatus.Int(),iBuffer.Length(), iBuffer); |
58 iDuplex.NotifyRead(iStatus.Int(),iBuffer.Length(), iBuffer); |
62 } |
59 } |
63 |
60 |
64 void CSimplexRead::DoCancel(void) |
61 void CSimplexRead::DoCancel(void) |
65 { |
62 { |
588 iIsRunning = ETrue; |
579 iIsRunning = ETrue; |
589 TInt ignoreErr; |
580 TInt ignoreErr; |
590 TRAP(ignoreErr, iUsbConfigChangeNotifier->StartL()); |
581 TRAP(ignoreErr, iUsbConfigChangeNotifier->StartL()); |
591 TRAP(ignoreErr, iSerialSignalChangeNotifier->StartL()); |
582 TRAP(ignoreErr, iSerialSignalChangeNotifier->StartL()); |
592 TRAP(ignoreErr, iUsbSignalChangeNotifier->StartL()); |
583 TRAP(ignoreErr, iUsbSignalChangeNotifier->StartL()); |
593 // iUsbFControlNotifier->StartL(); |
|
594 |
584 |
595 TRAP(ignoreErr, iUsbToSerial->StartL()); |
585 TRAP(ignoreErr, iUsbToSerial->StartL()); |
596 TRAP(ignoreErr, iSerialToUsb->StartL()); |
586 TRAP(ignoreErr, iSerialToUsb->StartL()); |
597 #ifdef _DEBUG |
587 #ifdef _DEBUG |
598 RDebug::Print(_L(": CActiveConsole::Start() done")); |
588 RDebug::Print(_L(": CActiveConsole::Start() done")); |
699 default: |
689 default: |
700 TheWindow.Write(_L(": Invalid Key pressed\n")); |
690 TheWindow.Write(_L(": Invalid Key pressed\n")); |
701 } |
691 } |
702 } |
692 } |
703 |
693 |
704 /* |
|
705 LOCAL_C TInt RateToInt(TBps aRate) |
|
706 { |
|
707 switch (aRate) |
|
708 { |
|
709 case EBps115200: return 115200; |
|
710 case EBps57600: return 57600; |
|
711 case EBps38400: return 38400; |
|
712 case EBps19200: return 19200; |
|
713 case EBps9600: return 9600; |
|
714 case EBps7200: return 7200; |
|
715 case EBps4800: return 4800; |
|
716 case EBps3600: return 3600; |
|
717 case EBps2400: return 2400; |
|
718 case EBps2000: return 2000; |
|
719 case EBps1800: return 1800; |
|
720 case EBps1200: return 1200; |
|
721 case EBps600: return 600; |
|
722 case EBps300: return 300; |
|
723 case EBps150: return 150; |
|
724 case EBps134: return 134; |
|
725 case EBps110: return 110; |
|
726 case EBps75: return 75; |
|
727 case EBps50: return 50; |
|
728 default: return -1; |
|
729 } |
|
730 } |
|
731 |
|
732 LOCAL_C void ConfigString(TDes &aBuf, const TCommNotificationV01 &aConfig) |
|
733 { |
|
734 // Config |
|
735 aBuf.Format(_L(" %d "), RateToInt(aConfig.iRate)); |
|
736 switch (aConfig.iParity) |
|
737 { |
|
738 case EParityEven: aBuf.Append(_L("E")); break; |
|
739 case EParityOdd: aBuf.Append(_L("O")); break; |
|
740 case EParityNone: aBuf.Append(_L("N")); break; |
|
741 default: break; |
|
742 } |
|
743 switch (aConfig.iDataBits) |
|
744 { |
|
745 case EData5: aBuf.Append(_L("5")); break; |
|
746 case EData6: aBuf.Append(_L("6")); break; |
|
747 case EData7: aBuf.Append(_L("7")); break; |
|
748 case EData8: aBuf.Append(_L("8")); break; |
|
749 default: break; |
|
750 } |
|
751 if (aConfig.iStopBits==EStop1) |
|
752 aBuf.Append(_L("1 ")); |
|
753 else |
|
754 aBuf.Append(_L("2 ")); |
|
755 |
|
756 aBuf.Append(_L("Use:")); |
|
757 if (aConfig.iHandshake==0) |
|
758 aBuf.Append(_L("NoControl ")); |
|
759 if (aConfig.iHandshake&(KConfigObeyXoff|KConfigSendXoff)) |
|
760 aBuf.Append(_L("XonXoff ")); |
|
761 if (aConfig.iHandshake&KConfigObeyCTS) |
|
762 aBuf.Append(_L("CTS/RTS ")); |
|
763 if (aConfig.iHandshake&KConfigObeyDSR) |
|
764 aBuf.Append(_L("DSR/DTR ")); |
|
765 if (aConfig.iHandshake&KConfigWriteBufferedComplete) |
|
766 aBuf.Append(_L("Early ")); |
|
767 //|KConfigObeyDCD|KConfigFailDCD|)) |
|
768 |
|
769 // if (aConfig.iBreak==TEiger::EBreakOn) |
|
770 // aBuf.Append(_L("Brk ")); |
|
771 // if (aConfig.iFifo==EFifoEnable) |
|
772 // aBuf.Append(_L("Fifo ")); |
|
773 } |
|
774 |
|
775 LOCAL_C void PrintCaps() |
|
776 { |
|
777 TCommCaps2 caps; |
|
778 TheUsbPort.Caps(caps); |
|
779 TUint notifycaps = caps().iNotificationCaps; |
|
780 RDebug::Print(_L("Capabilities:\n")); |
|
781 if (notifycaps&KNotifySignalsChangeSupported) |
|
782 RDebug::Print(_L("Notify Signals Change supported\n")); |
|
783 if (notifycaps&KNotifyRateChangeSupported) |
|
784 RDebug::Print(_L("Notify Rate Change supported\n")); |
|
785 if (notifycaps&KNotifyDataFormatChangeSupported) |
|
786 RDebug::Print(_L("Notify Data Format Change supported\n")); |
|
787 if (notifycaps&KNotifyHandshakeChangeSupported) |
|
788 RDebug::Print(_L("Notify Handshake Change supported\n")); |
|
789 if (notifycaps&KNotifyBreakSupported) |
|
790 RDebug::Print(_L("Notify Break supported\n")); |
|
791 if (notifycaps&KNotifyFlowControlChangeSupported) |
|
792 RDebug::Print(_L("Notify Flow Control Change supported\n")); |
|
793 if (notifycaps&KNotifyDataAvailableSupported) |
|
794 RDebug::Print(_L("Notify Data Available supported\n")); |
|
795 if (notifycaps&KNotifyOutputEmptySupported) |
|
796 RDebug::Print(_L("Notify Output Empty supported\n")); |
|
797 RDebug::Print(_L("\n")); |
|
798 if ((caps().iRoleCaps)&KCapsRoleSwitchSupported) |
|
799 RDebug::Print(_L("Role switching is supported\n")); |
|
800 RDebug::Print(_L("\n")); |
|
801 if ((caps().iFlowControlCaps)&KCapsFlowControlStatusSupported) |
|
802 RDebug::Print(_L("Retrieve flow control status is supported\n")); |
|
803 } |
|
804 */ |
|
805 LOCAL_C void DoInitL() |
694 LOCAL_C void DoInitL() |
806 { |
695 { |
807 // Do the necessary initialisation of the C32, 2 comm ports, USB stuff. |
696 // Do the necessary initialisation of the C32, 2 comm ports, USB stuff. |
808 // Load Device Drivers |
697 // Load Device Drivers |
809 TInt r; |
698 TInt r; |
899 RDebug::Print(_L("E32Main: Failed to Open Serial Comm Port. Error = %d"), r); |
788 RDebug::Print(_L("E32Main: Failed to Open Serial Comm Port. Error = %d"), r); |
900 User::Panic(_L("T_TERM"), EOpenErr); |
789 User::Panic(_L("T_TERM"), EOpenErr); |
901 } |
790 } |
902 RDebug::Print(_L("E32Main: Opened Serial Comm Port")); |
791 RDebug::Print(_L("E32Main: Opened Serial Comm Port")); |
903 |
792 |
904 // Print the caps |
|
905 //PrintCaps(); |
|
906 |
793 |
907 RDebug::Print(_L("E32Main: Reading Serial Comm Port config")); |
794 RDebug::Print(_L("E32Main: Reading Serial Comm Port config")); |
908 TheSerialPort.Config(TheSerialConfigBuf); // get config |
795 TheSerialPort.Config(TheSerialConfigBuf); // get config |
909 RDebug::Print(_L("E32Main: Reading Usb Comm Port config")); |
796 RDebug::Print(_L("E32Main: Reading Usb Comm Port config")); |
910 TheUsbPort.Config(TheUsbConfigBuf); // get config |
797 TheUsbPort.Config(TheUsbConfigBuf); // get config |
911 |
798 |
912 TBuf<80> buf; |
799 TBuf<80> buf; |
913 buf.FillZ(); |
800 buf.FillZ(); |
914 //ConfigString(buf, TheUsbConfig); |
|
915 RDebug::Print(_L("E32Main: Old USB Port Settings")); |
801 RDebug::Print(_L("E32Main: Old USB Port Settings")); |
916 RDebug::Print(buf); |
802 RDebug::Print(buf); |
917 RDebug::Print(_L("")); |
803 RDebug::Print(_L("")); |
918 buf.FillZ(); |
804 buf.FillZ(); |
919 //ConfigString(buf, TheSerialConfig); |
|
920 RDebug::Print(_L("E32Main: Old Serial Port Settings")); |
805 RDebug::Print(_L("E32Main: Old Serial Port Settings")); |
921 RDebug::Print(buf); |
806 RDebug::Print(buf); |
922 RDebug::Print(_L("")); |
807 RDebug::Print(_L("")); |
923 |
808 |
924 TCommConfig serialConfig; |
809 TCommConfig serialConfig; |