private void InitializeInterruptDriver()
 {
     try
     {
         _interruptDriver = new LibGpiodDriver(0);
     }
     catch (PlatformNotSupportedException)
     {
         _interruptDriver = new InterruptSysFsDriver(this);
     }
 }
        protected override void Dispose(bool disposing)
        {
            if (_registerViewPointer != null)
            {
                Interop.munmap((IntPtr)_registerViewPointer, 0);
                _registerViewPointer = null;
            }

            if (_interruptDriver != null)
            {
                _interruptDriver.Dispose();
                _interruptDriver = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Static factory method
        /// </summary>
        /// <returns>An instance of GpioDriver, depending on which one fits</returns>
        // TODO: remove try catch after https://github.com/dotnet/corefx/issues/32015 deployed
        public static UnixDriver Create()
        {
            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                throw new PlatformNotSupportedException(nameof(UnixDriver) + " is only supported on Linux/Unix");
            }

            UnixDriver driver = null;

            try
            {
                driver = new LibGpiodDriver();
            }
            catch (PlatformNotSupportedException)
            {
                driver = new SysFsDriver();
            }

            return(driver);
        }