private void SetDriverState(SerialRS485 rs485) { SafeUnixHandle handle = null; try { handle = UnsafeNativeMethods.Open(PortName, UnsafeNativeMethods.O_RDWR | UnsafeNativeMethods.O_NOCTTY); if (UnsafeNativeMethods.IoCtl(handle, UnsafeNativeMethods.TIOCSRS485, ref rs485) == -1) { throw new UnixIOException(); } } finally { handle?.Close(); } }
private SerialRS485 GetDriverState() { var rs485 = new SerialRS485(); SafeUnixHandle handle = null; try { handle = UnsafeNativeMethods.Open(PortName, UnsafeNativeMethods.O_RDWR | UnsafeNativeMethods.O_NOCTTY); if (UnsafeNativeMethods.IoCtl(handle, UnsafeNativeMethods.TIOCGRS485, ref rs485) == -1) { throw new UnixIOException(); } } finally { handle?.Close(); } return(rs485); }