Example #1
0
        public static DeviceDisplay[] GetActiveDevices()
        {
            uint count  = LibraryWrapper.rtlsdr_get_device_count();
            var  result = new DeviceDisplay[count];

            for (var i = 0u; i < count; i++)
            {
                string name = LibraryWrapper.rtlsdr_get_device_name(i);
                result[i] = new DeviceDisplay {
                    Index = i, Name = name
                };
            }

            return(result);
        }
Example #2
0
        public RtlDevice(uint index)
        {
            Index = index;
            int r = LibraryWrapper.rtlsdr_open(out _dev, Index);

            if (r != 0)
            {
                throw new ApplicationException("Cannot open RTL device. Is the device locked somewhere?");
            }
            int count = _dev == IntPtr.Zero ? 0 : LibraryWrapper.rtlsdr_get_tuner_gains(_dev, null);

            if (count < 0)
            {
                count = 0;
            }
            SupportsOffsetTuning = LibraryWrapper.rtlsdr_set_offset_tuning(_dev, 0) != -2;
            SupportedGains       = new int[count];
            if (count >= 0)
            {
                LibraryWrapper.rtlsdr_get_tuner_gains(_dev, SupportedGains);
            }
            Name      = LibraryWrapper.rtlsdr_get_device_name(Index);
            _gcHandle = GCHandle.Alloc(this);
        }