예제 #1
0
파일: Form1.cs 프로젝트: ntnhan0512/doan2
        public Form1()
        {
            InitializeComponent();

            xbee = new XBEE();

            mySerialPort = new SerialPort("COM2");

            mySerialPort.BaudRate = 9600;
            mySerialPort.Parity = Parity.None;
            mySerialPort.StopBits = StopBits.One;
            mySerialPort.DataBits = 8;
            mySerialPort.Handshake = Handshake.None;

            mySerialPort.DataReceived += new SerialDataReceivedEventHandler(xbee.DataReceivedHandler);
            mySerialPort.Open();

            //timer
            aTimer = new System.Timers.Timer(10000);
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 1000;
            aTimer.Enabled = true;
        }
예제 #2
0
파일: Program.cs 프로젝트: ntnhan0512/doan2
        private static void Main()
        {
            XBEE xbee = new XBEE();

            SerialPort mySerialPort = new SerialPort("COM2");

            mySerialPort.BaudRate = 9600;
            mySerialPort.Parity = Parity.None;
            mySerialPort.StopBits = StopBits.One;
            mySerialPort.DataBits = 8;
            mySerialPort.Handshake = Handshake.None;

            mySerialPort.DataReceived += new SerialDataReceivedEventHandler(xbee.DataReceivedHandler);

            //int b = 0;

            while (true)
            {

                mySerialPort.Open();

                mySerialPort.Close();
            }
        }