Ejemplo n.º 1
0
 /// <summary>
 /// 关闭端口
 /// </summary>
 public void Close()
 {
     PortAPI.ErrorCodes code = Close(Port);
     if (code != PortAPI.ErrorCodes.SIO_OK)
     {
         throw new Exception(GetErrorStr(code));
     }
     IsOpen = false;
     SerialPortChange?.Invoke(this);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 打开端口
        /// </summary>
        public void Open()
        {
            PortAPI.ErrorCodes code = Open(Port);
            if (code == PortAPI.ErrorCodes.SIO_OK)
            {
                IsOpen = true;

                Setioctl();

                SetDataReceived();

                SerialPortChange?.Invoke(this);
            }
            else
            {
                throw new Exception(GetErrorStr(code));
            }
        }