コード例 #1
0
 private void InitCKPower(string comPortName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
 {
     try
     {
         if (cKPower == null)
         {
             cKPower = new SerialPortOperation(comPortName, baudRate, parity, dataBits, stopBits);
             cKPower.DataReceived += new SerialPortOperation.SerialPortDataReceiveEventArgs(CK_DataReceived);
         }
     }
     catch (Exception ex)
     {
         err = $"串口{comPortName}打开异常,{ex.ToString()}";
     }
 }
コード例 #2
0
 public void CloseExposure()
 {
     byte[] bt = SerialPortOperation.StringToBtyes("#ISPW=808501");
     _serialPort.Write(bt, 0, bt.Length);
     Thread.Sleep(10);
     byte[] bt1 = SerialPortOperation.StringToBtyes("#ISPW=044180");
     _serialPort.Write(bt1, 0, bt1.Length);
     Thread.Sleep(10);
     byte[] bt2 = SerialPortOperation.StringToBtyes("#ISPW=044200");
     _serialPort.Write(bt2, 0, bt2.Length);
     Thread.Sleep(10);
     byte[] bt3 = SerialPortOperation.StringToBtyes("#ISPW=837000");
     _serialPort.Write(bt3, 0, bt3.Length);
     Thread.Sleep(10);
     byte[] bt4 = SerialPortOperation.StringToBtyes("#ISPW=150100");
     _serialPort.Write(bt4, 0, bt4.Length);
     Thread.Sleep(10);
     byte[] bt5 = SerialPortOperation.StringToBtyes("#ISPW=270300");
     _serialPort.Write(bt5, 0, bt5.Length);
 }