Beispiel #1
0
        public LibGpiodDriver()
        {
            SafeChipIteratorHandle iterator = null;

            try
            {
                iterator = Interop.GetChipIterator();
                if (iterator == null)
                {
                    throw ExceptionHelper.GetIOException(ExceptionResource.NoChipIteratorFound, Marshal.GetLastWin32Error());
                }
            }
            catch (DllNotFoundException)
            {
                throw ExceptionHelper.GetPlatformNotSupportedException(ExceptionResource.LibGpiodNotInstalled);
            }

            _chip = Interop.GetNextChipFromChipIterator(iterator);
            if (_chip == null)
            {
                throw ExceptionHelper.GetIOException(ExceptionResource.NoChipFound, Marshal.GetLastWin32Error());
            }

            _pinNumberToSafeLineHandle = new Dictionary <int, SafeLineHandle>(PinCount);
        }
Beispiel #2
0
        public LibGpiodDriver()
        {
            SafeChipIteratorHandle iterator = Interop.GetChipIterator();

            if (iterator == null)
            {
                throw ExceptionHelper.GetIOException(ExceptionResource.NoChipIteratorFound, Marshal.GetLastWin32Error());
            }

            _chip = Interop.GetNextChipFromChipIterator(iterator);
            if (_chip == null)
            {
                throw ExceptionHelper.GetIOException(ExceptionResource.NoChipFound, Marshal.GetLastWin32Error());
            }

            // Freeing other chips opened
            Interop.FreeChipIteratorNoCloseCurrentChip(iterator);
            _pinNumberToSafeLineHandle = new Dictionary <int, SafeLineHandle>(PinCount);
        }
Beispiel #3
0
 internal static extern SafeChipHandle GetNextChipFromChipIterator(SafeChipIteratorHandle iter);
Beispiel #4
0
 internal static extern void FreeChipIteratorNoCloseCurrentChip(SafeChipIteratorHandle iter);
Beispiel #5
0
 internal static extern SafeChipHandle gpiod_chip_iter_next(SafeChipIteratorHandle iter);
Beispiel #6
0
 internal static extern void gpiod_chip_iter_free_noclose(SafeChipIteratorHandle iter);