public UnixNativeSerial() { m_Dll = new SerialUnix(); m_Handle = m_Dll.serial_init(); if (m_Handle.Equals(IntPtr.Zero)) { throw new PlatformNotSupportedException("Can't initialise platform library"); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; /// <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (m_IsDisposed) return; if (disposing) { if (IsOpen) Close(); m_Handle.Dispose(); m_Dll = null; m_StopRunning.Dispose(); m_StopRunning = null; m_IsDisposed = true; } }
public UnixNativeSerial() { m_Dll = new SerialUnix(); m_Handle = m_Dll.serial_init(); if (m_Handle.IsInvalid) { throw new PlatformNotSupportedException("Can't initialise platform library"); } m_HandlePtr = m_Handle.DangerousGetHandle(); #if NETSTANDARD15 // On NetStandard 1.5, we must have proper exception handling try { // These methods were first added in libnserial 1.1 m_Dll.netfx_errno(0); } catch (System.EntryPointNotFoundException) { throw new PlatformNotSupportedException("Must have libnserial 1.1.0 or later on .NET Standard 1.5"); } #endif }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; /// <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_IsDisposed) { if (disposing) { if (IsOpen) { Close(); } } if (!m_Handle.Equals(IntPtr.Zero)) { m_Dll.serial_terminate(m_Handle); m_Handle = IntPtr.Zero; m_Dll = null; } m_IsDisposed = true; } }