Beispiel #1
0
 public CDisplaycommTL(DisplayConfigTL settings)
 {
     this.settings      = settings;
     port               = new SerialPort();
     port.BaudRate      = 9600;
     port.PortName      = settings.Comport;
     port.DataBits      = 8;
     port.StopBits      = StopBits.One;
     port.Parity        = Parity.None;
     port.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
     _setdisplaytype    = settings.DisplayType;
     try
     {
         port.Open();
         Speed = settings.DisplaySpeed;
         System.Threading.Thread.Sleep(100);
         CDisplayDataTL data = new CDisplayDataTL(settings);
         //data.DispType = settings.DisplayType;
         //data.Speed = settings.DisplaySpeed;
         data.dispcommand = DisplayCommand.displaymode;
         byte[] senddata = data.ToByte();
         port.Write(senddata, 0, senddata.Length);
     }
     catch
     {
         System.Windows.Forms.MessageBox.Show("无法打开串口" + settings.Comport + "!");
     }
 }
Beispiel #2
0
        public void ShowText(string txt)
        {
            CDisplayDataTL data = new CDisplayDataTL(settings);

            //data.DispType = settings.DisplayType;
            // data.Speed = settings.DisplaySpeed;
            data.dispcommand = DisplayCommand.show;
            data.DisplayText = txt;
            byte[] senddata = data.ToByte();
            try
            {
                port.Write(senddata, 0, senddata.Length);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("串口通讯故障!");
            }
        }