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; }
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(); } }