日期:2014-05-17  浏览次数:21104 次

serialPort 收不到数据


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;

namespace People_s_Hospital
{
    public partial class Home : Form
    {
        
        public Home()
        {
            
            InitializeComponent();
        }

        #region 打开关闭串口
        /// <summary>
        /// 打开串口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Openbutton_Click(object sender, EventArgs e)
        {
            LinkserialPort.Close();
            try
            {
                if (!LinkserialPort.IsOpen)
                {
                    com_State();
                }
                else
                {
                    MessageBox.Show("您已经开始采集数据了!", "错误提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 关闭串口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Stopbutton_Click(object sender, EventArgs&