示例#1
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     try
     {
         this.ReadDataBase();
         if (com.ComState == false)
         {
             com.ClosePort();
             string port     = ini.ReadIni("Config", "Port");
             string baudRate = ini.ReadIni("Config", "BaudRate");
             SimpleLogHelper.Instance.WriteLog(LogType.Info, "打开串口:" + com.OpenPort(port, baudRate));
         }
     }
     catch (Exception ex)
     {
         SimpleLogHelper.Instance.WriteLog(LogType.Info, ex);
     }
 }
示例#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();
        }