Пример #1
0
        // private void setSnbutton_Click(object sender, EventArgs e)
        public int setSnbutton_Click()
        {
            /*Form3 f3= new Form3();
             * f3.Show();
             * String Snstr = f3.Sn;*/
            int    flag  = 0;
            string Snstr = setSncomboBox.Text;

            try
            {
                if (serialPort1.IsOpen)
                {
                    Sn = 2;
                    serialPort1.Write(Snstr + "\r");
                    CanMessageSendTextBox.Clear();
                    flag = 1;
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = 2;
                return(flag);
            }
        }
Пример #2
0
 private void closeCanToolbutton_Click(object sender, EventArgs e)
 {
     try
     {
         if (serialPort1.IsOpen)
         {
             Close = 2;
             serialPort1.Write("C\r");
             CanMessageSendTextBox.Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #3
0
        // private void closeCanToolbutton_Click(object sender, EventArgs e)
        public int closeCanToolbutton_Click()
        {
            int flag = 0;

            try
            {
                if (serialPort1.IsOpen)
                {
                    Close = 2;
                    serialPort1.Write("C\r");
                    CanMessageSendTextBox.Clear();
                    flag = 1;
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = 2;
                return(flag);
            }
        }
Пример #4
0
        // private void SendButton_Click(object sender, EventArgs e)
        public int SendButton_Click()
        {
            int flag = 0;

            try
            {
                if (serialPort1.IsOpen)
                {
                    //serialPort1.WriteLine(CanMessageSendTextBox.Text);
                    serialPort1.WriteLine("t35881122334455667788\rt32081122334455667788\rt36081122334455667788\rt32181122334455667788\r");
                    CanMessageSendTextBox.Clear();
                    flag = 1;
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = 2;
                return(flag);
            }
        }
Пример #5
0
        private void setSnbutton_Click(object sender, EventArgs e)
        {
            /*Form3 f3= new Form3();
             * f3.Show();
             * String Snstr = f3.Sn;*/

            string Snstr = setSncomboBox.Text;

            try
            {
                if (serialPort1.IsOpen)
                {
                    Sn = 2;
                    serialPort1.Write(Snstr + "\r");
                    CanMessageSendTextBox.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #6
0
        // private void getversionbutton_Click(object sender, EventArgs e)
        public int getversionbutton_Click()
        {
            int flag = 0;

            try
            {
                if (serialPort1.IsOpen)
                {
                    version = 2;
                    serialPort1.Write("V\r");
                    CanMessageSendTextBox.Clear();
                    flag = 1;
                    return(flag);
                }
                flag = 2;
                return(flag);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                flag = 3;
                return(flag);
            }
        }
Пример #7
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (serialPort1.IsOpen)
                {
                    //serialPort1.WriteLine(CanMessageSendTextBox.Text);
                    //serialPort1.Write("t35881122334455667788\rt32081122334455667788\rt36081122334455667788\rt32181122334455667788\r");
                    //serialPort1.Write("t0648A802B70000000000\r");
                    serialPort1.Write("t0648E812270000000000\r");

                    /*byte[] bsTest = new byte[1];
                     * bsTest[0] = 0x07;
                     * string t = System.Text.Encoding.Default.GetString(bsTest);
                     *
                     * serialPort1.Write(t);*/
                    CanMessageSendTextBox.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }