コード例 #1
0
        const int T_THREAD    = 20;  // milliSec
        #endregion

        void ConfigCommunication()
        {
            // m_SerPort = new SerialPort("COM4", 115200, Parity.None, 8, StopBits.One);
            // m_SerPort = new SerialPort("COM3");
            m_SerPort = new SerialPort("COM8", 500000, Parity.None, 8, StopBits.One);
            //m_SerPort = new SerialPort("COM8", 115200, Parity.None, 8, StopBits.One);
            m_SerPort.ReadBufferSize = 20 * 1024;
            m_SerPort.Open();
            ph       = new SvIdProtocolHandler3(m_SerPort, this);
            ph._scal = Scaling.None; // MaxI16 = +/-1.0
            // ph = new HPerfProtocolHandler(m_SerPort, this);
        }
コード例 #2
0
        const int T_THREAD    = 20;  // milliSec
        #endregion

        void ConfigCommunication()
        {
            string com = "COM8";

            try
            {
                com = File.ReadAllText("COM.txt");
            }
            catch { }

            ComForm comForm;

            do
            {
                comForm = new ComForm(com);

                try
                {
                    //m_SerPort = new SerialPort("COM4", 115200, Parity.None, 8, StopBits.One);
                    m_SerPort = new SerialPort(comForm.COM);

                    m_SerPort.ReadBufferSize = 20 * 1024;
                    m_SerPort.Open();
                    ph       = new SvIdProtocolHandler3(m_SerPort, this);
                    ph._scal = Scaling.None; // MaxI16 = +/-1.0
                                             // ph = new HPerfProtocolHandler(m_SerPort, this);
                    return;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

                if (comForm.ShowDialog() == DialogResult.Cancel)
                {
                    Application.Exit();
                }

                try
                {
                    File.WriteAllText("COM.txt", comForm.COM);
                }
                catch { }
            } while (true);
        }