/// <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); }
/// <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)); } }