protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();

            cs.SetStandard(ShareOption.ComPort, 9600, Handshake.none, Parity.none);
            return(cs);
        }
        protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();

            cs.SetStandard(WorkstationDAL.Model.clsShareOption.ComPort, 115200, Handshake.none, Parity.none);
            return(cs);
        }
Exemple #3
0
        protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();

            //string path = AppDomain.CurrentDomain.BaseDirectory + settingFileName;
            //FileInfo file = new FileInfo(path);
            //if (file.Exists)
            //{
            //    cs = CommBase.CommBaseSettings.LoadFromXML(file.OpenRead());
            //}
            //else
            //{
            cs.SetStandard(ShareOption.ComPort, 19200, Handshake.none, Parity.odd);
            clsDY5000LD.CommBaseSettings set = cs;
            set.autoReopen            = false;
            set.sendTimeoutMultiplier = 10;
            set.sendTimeoutConstant   = 1000;
            set.rxLowWater            = 100;
            set.rxHighWater           = 100;
            set.rxQueue       = 0;
            set.txQueue       = 0;
            set.useDTR        = JH.CommBase.CommBase.HSOutput.none;
            set.useRTS        = JH.CommBase.CommBase.HSOutput.none;
            set.checkAllSends = true;
            //}
            return(cs);
        }
Exemple #4
0
            protected override CommBaseSettings CommSettings()
            {
                CommBaseSettings cb = new CommBaseSettings();

                cb.SetStandard("COM" + mComPort.ToString() + ":", 4800, CommBase.Handshake.none);
                //cb.checkAllSends = true;

                return(cb);
            }
Exemple #5
0
 private void allDefaultsLinkLabel_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
 {
     m_settings            = new CommBaseSettings();
     m_settings.port       = Project.gpsPortSettings.port;
     m_settings.baudRate   = Project.gpsPortSettings.baudRate;
     m_settings.parity     = Parity.none;
     m_settings.autoReopen = true;
     FillValues();
 }
        protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();

            cs.SetStandard(ShareOption.ComPort, 9600, Handshake.none, Parity.none); //Parity.odd;
            clsDY723PC.CommBaseSettings set = cs;
            set.autoReopen = true;

            return(cs);
        }
Exemple #7
0
        protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();

            cs.SetStandard(ShareOption.ComPort, 9600, Handshake.none, Parity.none);
            cs.sendTimeoutMultiplier = 100;
            cs.sendTimeoutConstant   = 1000;
            cs.rxLowWater            = 256;
            cs.rxHighWater           = 256;
            cs.txWhenRxXoff          = false;
            return(cs);
        }
Exemple #8
0
        public DlgPortSettings()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            m_settings = Project.gpsPortSettings;

            FillASCII(comboBoxXon);
            FillASCII(comboBoxXoff);
            Project.setDlgIcon(this);
        }
Exemple #9
0
        protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();
            Handshake        hs;

            switch (handshake)
            {
            case "CtsRts":
                hs = Handshake.CtsRts;
                break;

            case "DsrDtr":
                hs = Handshake.DsrDtr;
                break;

            case "XonXoff":
                hs = Handshake.XonXoff;
                break;

            default:
                hs = Handshake.none;
                break;
            }
            cs.SetStandard(commport, baudrate, hs);
            switch (parity)
            {
            case "Odd":
                cs.parity = Parity.odd;
                break;

            case "Even":
                cs.parity = Parity.even;
                break;

            case "Mark":
                cs.parity = Parity.mark;
                break;

            case "Space":
                cs.parity = Parity.space;
                break;

            default:
                cs.parity = Parity.none;
                break;
            }
            cs.sendTimeoutConstant   = 0;
            cs.sendTimeoutMultiplier = 450;
            return(cs);
        }
Exemple #10
0
        protected override CommBaseSettings CommSettings()
        {
            CommBaseSettings cs = new CommBaseSettings();

            //string path = AppDomain.CurrentDomain.BaseDirectory + settingFileName;
            //FileInfo file = new FileInfo(path);
            //if (file.Exists)
            //{
            //    cs = CommBase.CommBaseSettings.LoadFromXML(file.OpenRead());
            //}
            //else
            //{
            cs.SetStandard(ShareOption.ComPort, 9600, Handshake.none, Parity.none);
            //}
            return(cs);
        }
Exemple #11
0
            protected override CommBaseSettings CommSettings()
            {
                CommBaseSettings cb = new CommBaseSettings();
                cb.SetStandard("COM" + mComPort.ToString() + ":", 4800, CommBase.Handshake.none);
                //cb.checkAllSends = true;

                return cb;
            }
Exemple #12
0
    protected override CommBaseSettings CommSettings()
    {
      CommBaseSettings cs = new CommBaseSettings();
      Handshake hs;
      switch (handshake)
      {
        case "CtsRts":
          hs = Handshake.CtsRts;
          break;
        case "DsrDtr":
          hs = Handshake.DsrDtr;
          break;
        case "XonXoff":
          hs = Handshake.XonXoff;
          break;
        default:
          hs = Handshake.none;
          break;
      }
      cs.SetStandard(commport, baudrate, hs);
      switch (parity)
      {
        case "Odd":
          cs.parity = Parity.odd;
          break;
        case "Even":
          cs.parity = Parity.even;
          break;
        case "Mark":
          cs.parity = Parity.mark;
          break;
        case "Space":
          cs.parity = Parity.space;
          break;
        default:
          cs.parity = Parity.none;
          break;
      }

      return cs;
    }
		public miniterminal(UpdateRxString pUpdStr)
		{
      this.ComSettings = new CommBase.CommBaseSettings();
      pCallBackRxUpdate = pUpdStr;
		}
Exemple #14
0
 public miniterminal(UpdateRxString pUpdStr)
 {
     this.ComSettings  = new CommBase.CommBaseSettings();
     pCallBackRxUpdate = pUpdStr;
 }
Exemple #15
0
		/* I N I T */
		/*----------------------------------------------------------------------------
			%%Function: Init
			%%Qualified: bg._bg:DevComm.Init
			%%Contact: rlittle

			
		----------------------------------------------------------------------------*/
		public void Init()
		{
			m_cbs = new CommBaseSettings();

			m_cbs.SetStandard("COM5:", 9600, CommBase.Handshake.none);
			rgbRxBuffer = new byte[512];
		}
Exemple #16
0
 public bool Open()
 {
     Win32Com.DCB          lpDCB          = new Win32Com.DCB();
     Win32Com.COMMTIMEOUTS lpCommTimeouts = new Win32Com.COMMTIMEOUTS();
     Win32Com.OVERLAPPED   structure      = new Win32Com.OVERLAPPED();
     if (!this.online)
     {
         CommBaseSettings settings = this.CommSettings();
         this.hPort = Win32Com.CreateFile(settings.port, 0xc0000000, 0, IntPtr.Zero, 3, 0x40000000, IntPtr.Zero);
         if (this.hPort == ((IntPtr)(-1)))
         {
             if (Marshal.GetLastWin32Error() == 5L)
             {
                 return(false);
             }
             this.hPort = Win32Com.CreateFile(this.AltName(settings.port), 0xc0000000, 0, IntPtr.Zero, 3, 0x40000000, IntPtr.Zero);
             if (this.hPort == ((IntPtr)(-1)))
             {
                 if (Marshal.GetLastWin32Error() != 5L)
                 {
                     throw new CommPortException("Port Open Failure");
                 }
                 return(false);
             }
         }
         this.online = true;
         lpCommTimeouts.ReadIntervalTimeout        = uint.MaxValue;
         lpCommTimeouts.ReadTotalTimeoutConstant   = 0;
         lpCommTimeouts.ReadTotalTimeoutMultiplier = 0;
         if (settings.sendTimeoutMultiplier == 0)
         {
             if (Environment.OSVersion.Platform == PlatformID.Win32NT)
             {
                 lpCommTimeouts.WriteTotalTimeoutMultiplier = 0;
             }
             else
             {
                 lpCommTimeouts.WriteTotalTimeoutMultiplier = 0x2710;
             }
         }
         else
         {
             lpCommTimeouts.WriteTotalTimeoutMultiplier = settings.sendTimeoutMultiplier;
         }
         lpCommTimeouts.WriteTotalTimeoutConstant = settings.sendTimeoutConstant;
         lpDCB.init((settings.parity == Parity.odd) || (settings.parity == Parity.even), settings.txFlowCTS, settings.txFlowDSR, (int)settings.useDTR, settings.rxGateDSR, !settings.txWhenRxXoff, settings.txFlowX, settings.rxFlowX, (int)settings.useRTS);
         lpDCB.BaudRate = settings.baudRate;
         lpDCB.ByteSize = (byte)settings.dataBits;
         lpDCB.Parity   = (byte)settings.parity;
         lpDCB.StopBits = (byte)settings.stopBits;
         lpDCB.XoffChar = (byte)settings.XoffChar;
         lpDCB.XonChar  = (byte)settings.XonChar;
         if (((settings.rxQueue != 0) || (settings.txQueue != 0)) && !Win32Com.SetupComm(this.hPort, (uint)settings.rxQueue, (uint)settings.txQueue))
         {
             this.ThrowException("Bad queue settings");
         }
         if ((settings.rxLowWater == 0) || (settings.rxHighWater == 0))
         {
             Win32Com.COMMPROP commprop;
             if (!Win32Com.GetCommProperties(this.hPort, out commprop))
             {
                 commprop.dwCurrentRxQueue = 0;
             }
             if (commprop.dwCurrentRxQueue > 0)
             {
                 lpDCB.XoffLim = lpDCB.XonLim = (short)(commprop.dwCurrentRxQueue / 10);
             }
             else
             {
                 lpDCB.XoffLim = (short)(lpDCB.XonLim = 8);
             }
         }
         else
         {
             lpDCB.XoffLim = (short)settings.rxHighWater;
             lpDCB.XonLim  = (short)settings.rxLowWater;
         }
         if (!Win32Com.SetCommState(this.hPort, ref lpDCB))
         {
             this.ThrowException("Bad com settings");
         }
         if (!Win32Com.SetCommTimeouts(this.hPort, ref lpCommTimeouts))
         {
             this.ThrowException("Bad timeout settings");
         }
         this.stateBRK = 0;
         if (settings.useDTR == HSOutput.none)
         {
             this.stateDTR = 0;
         }
         if (settings.useDTR == HSOutput.online)
         {
             this.stateDTR = 1;
         }
         if (settings.useRTS == HSOutput.none)
         {
             this.stateRTS = 0;
         }
         if (settings.useRTS == HSOutput.online)
         {
             this.stateRTS = 1;
         }
         this.checkSends      = settings.checkAllSends;
         structure.Offset     = 0;
         structure.OffsetHigh = 0;
         if (this.checkSends)
         {
             structure.hEvent = this.writeEvent.Handle;
         }
         else
         {
             structure.hEvent = IntPtr.Zero;
         }
         this.ptrUWO = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
         Marshal.StructureToPtr(structure, this.ptrUWO, true);
         this.writeCount          = 0;
         this.empty[0]            = true;
         this.dataQueued          = false;
         this.rxException         = null;
         this.rxExceptionReported = false;
         this.rxThread            = new Thread(new ThreadStart(this.ReceiveThread));//打开串口的同时也打开了接收线程
         this.rxThread.Name       = "CommBaseRx";
         this.rxThread.Priority   = ThreadPriority.AboveNormal;
         this.rxThread.Start();
         this.startEvent.WaitOne(500, false);
         this.auto = false;
         if (this.AfterOpen())
         {
             this.auto = settings.autoReopen;
             return(true);
         }
         this.Close();
     }
     return(false);
 }