public bool Open(string portName, int baudRate, PInvokeParity parity, int dataBits, PInvokeStopBits stopBits) { return(_interalProvider.Open(portName, baudRate, parity, dataBits, stopBits)); }
public bool Open(string portName, int baudRate, PInvokeParity parity, int dataBits, PInvokeStopBits stopBits) { if (!IsOpen) { _portName = portName; _port = new SerialPort(_portName, baudRate, (Parity)(int)parity, dataBits, (StopBits)(int)stopBits); bool ret = false; try { _port.Open(); ret = true; } catch (ArgumentException) { } catch (UnauthorizedAccessException) { } catch (IOException) { } catch (InvalidOperationException) { } return(ret); } return(false); }
/// <summary> /// Open serial port on Linux-like OSs /// </summary> /// <param name="portName">Name of serial port to be opened</param> /// <param name="baudRate">Ignored</param> /// <param name="parity">Ignored</param> /// <param name="dataBits">Ignored</param> /// <param name="stopBits">Ignored</param> /// <returns>true if port opening succeeded</returns> public bool Open(string portName, int baudRate, PInvokeParity parity, int dataBits, PInvokeStopBits stopBits) { _portName = portName; var nums = Regex.Matches(_portName, @"\d{3}"); if (nums.Count == 2 && byte.TryParse(nums[0].Value, out _busNo) && byte.TryParse(nums[1].Value, out _addressNo) ) { return(OpenSerialPort(_busNo, _addressNo)); } return(false); }
public SerialPortDataSource(string sourceName, BaudRates baudRate, PInvokeStopBits stopBits) { SourceName = sourceName; BaudRate = baudRate; StopBits = stopBits; }