示例#1
0
        protected override void OnStart(string[] args)
        {
            string port     = ini.ReadIni("Config", "Port");
            string baudRate = ini.ReadIni("Config", "BaudRate");

            //this.socketServerEx.Listen("6000");
            //this.socketServerEx.NewMessage2Event += SocketServerEx_NewMessage2Event;
            SimpleLogHelper.Instance.WriteLog(LogType.Info, "打开串口:" + com.OpenPort(port, baudRate));
            com.DataReceiveEvent += Com_DataReceiveEvent;
            string Interval = ini.ReadIni("Config", "Interval");

            timer.Interval = int.Parse(Interval);
            timer.Elapsed += Timer_Elapsed;
            timer.Start();
        }
示例#2
0
        private void Send(string data)
        {
            COMMHelper comm = new COMMHelper();
            string     com  = ini.ReadIni("Ini", "COM");

            comm.OpenPort(com, "9600");
            comm.DataReceiveEvent += Comm_DataReceiveEvent;
            comm.SendAsString(data);
            Thread.Sleep(300);
            comm.ClosePort();
        }