{"id":13578034,"url":"https://github.com/nandortoth/rtlsdr-manager","last_synced_at":"2025-10-23T16:48:17.970Z","repository":{"id":53549453,"uuid":"133151390","full_name":"nandortoth/rtlsdr-manager","owner":"nandortoth","description":".NET Core library to manage RTL-SDR devices","archived":false,"fork":false,"pushed_at":"2020-01-19T06:46:57.000Z","size":178,"stargazers_count":45,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T08:03:52.668Z","etag":null,"topics":["dotnet-core","r820t","rtl-sdr","rtl2832u","software-defined-radio"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nandortoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-12T14:00:28.000Z","updated_at":"2025-02-25T17:44:18.000Z","dependencies_parsed_at":"2022-09-11T08:22:54.459Z","dependency_job_id":null,"html_url":"https://github.com/nandortoth/rtlsdr-manager","commit_stats":null,"previous_names":["nandortoth/rtlsdrmanager-dotnet-core"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandortoth%2Frtlsdr-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandortoth%2Frtlsdr-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandortoth%2Frtlsdr-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nandortoth%2Frtlsdr-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nandortoth","download_url":"https://codeload.github.com/nandortoth/rtlsdr-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247359260,"owners_count":20926394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet-core","r820t","rtl-sdr","rtl2832u","software-defined-radio"],"created_at":"2024-08-01T15:01:26.473Z","updated_at":"2025-10-23T16:48:17.964Z","avatar_url":"https://github.com/nandortoth.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# RTL-SDR Manager Library for .NET\n\n[![NuGet Version](https://img.shields.io/nuget/v/RtlSdrManager.svg)](https://www.nuget.org/packages/RtlSdrManager/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/RtlSdrManager.svg)](https://www.nuget.org/packages/RtlSdrManager/)\n[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE.md)\n[![.NET Version](https://img.shields.io/badge/.NET-9.0-purple.svg)](https://dotnet.microsoft.com/download)\n\nA modern, high-performance .NET library for managing RTL-SDR devices with support for async operations, multiple tuner types, and advanced features like KerberosSDR.\n\n## ✨ Features\n\n- 🚀 **Async/Await Support** - Non-blocking sample reading with concurrent queue buffering\n- 🎛️ **Multiple Tuner Support** - E4000, R820T/R828D, FC0012, FC0013, FC2580\n- 🔧 **Advanced Configuration** - Gain control, frequency correction, direct sampling, bias tee\n- 📡 **KerberosSDR Ready** - Frequency dithering and GPIO control for coherent SDR arrays\n- 🔒 **Type-Safe API** - Strongly-typed frequency values with unit conversions\n- 💾 **Cross-Platform** - Works on Windows, Linux, and macOS\n- ⚡ **High Performance** - LibraryImport P/Invoke for optimal native interop\n- 🛡️ **Production Ready** - Proper exception handling, disposal patterns, and null safety\n- 🔇 **Console Output Control** - Suppress or capture native library diagnostic messages\n\n## 📦 Installation\n\n### Via NuGet Package Manager\n\n```bash\n# .NET CLI\ndotnet add package RtlSdrManager\n\n# Package Manager Console (Visual Studio)\nInstall-Package RtlSdrManager\n\n# PackageReference (in .csproj)\n\u003cPackageReference Include=\"RtlSdrManager\" Version=\"0.5.0\" /\u003e\n```\n\n### Prerequisites\n\nYou must have the `librtlsdr` native library installed on your system:\n\n**Windows:**\n```powershell\n# Using Chocolatey\nchoco install rtl-sdr\n\n# Or download from: https://github.com/osmocom/rtl-sdr/releases\n```\n\n**Linux (Ubuntu/Debian):**\n```bash\nsudo apt-get install librtlsdr-dev\n```\n\n**macOS:**\n```bash\nbrew install librtlsdr\n```\n\n## 🚀 Quick Start\n\n### Basic Usage\n\n```csharp\nusing RtlSdrManager;\nusing RtlSdrManager.Modes;\n\n// Get the singleton device manager\nvar manager = RtlSdrDeviceManager.Instance;\n\n// Check available devices\nConsole.WriteLine($\"Found {manager.CountDevices} RTL-SDR device(s)\");\n\n// Open the first device with a friendly name\nmanager.OpenManagedDevice(0, \"my-rtl-sdr\");\n\n// Configure the device\nvar device = manager[\"my-rtl-sdr\"];\ndevice.CenterFrequency = Frequency.FromMHz(1090);  // ADS-B frequency\ndevice.SampleRate = Frequency.FromMHz(2);\ndevice.TunerGainMode = TunerGainModes.AGC;\ndevice.AGCMode = AGCModes.Enabled;\ndevice.ResetDeviceBuffer();\n\nConsole.WriteLine($\"Tuner: {device.TunerType}\");\nConsole.WriteLine($\"Center Frequency: {device.CenterFrequency.MHz} MHz\");\n```\n\n### Console Output Suppression\n\nBy default, the library suppresses all console output from `librtlsdr` (like \"Found Rafael Micro R820T tuner\" and \"[R82XX] PLL not locked!\") by redirecting native stdout/stderr file descriptors to `/dev/null` (Unix/macOS) or `NUL` (Windows). You can control this behavior globally or per-device:\n\n```csharp\n// Global default for new devices (default is true)\nRtlSdrDeviceManager.SuppressLibraryConsoleOutput = false;\n\n// Open a device - it inherits the global setting\nmanager.OpenManagedDevice(0, \"my-rtl-sdr\");\nvar device = manager[\"my-rtl-sdr\"];\n\n// Control suppression per-device at runtime\ndevice.SuppressLibraryConsoleOutput = false;  // Show messages for this device\ndevice.SampleRate = Frequency.FromMHz(2);      // Will show librtlsdr output\n\ndevice.SuppressLibraryConsoleOutput = true;   // Hide messages again\ndevice.SampleRate = Frequency.FromMHz(2.4);    // Silent\n```\n\n**Note:** Each device has its own `SuppressLibraryConsoleOutput` property that is initialized from the global setting when opened, but can be changed independently. The suppression works at the native file descriptor level to catch all output from the native library.\n\n### Synchronous Sample Reading\n\n```csharp\n// Read samples synchronously (blocking)\nvar samples = device.ReadSamples(256 * 1024);\n\nforeach (var sample in samples)\n{\n    // Process I/Q samples\n    Console.WriteLine($\"I: {sample.I}, Q: {sample.Q}\");\n}\n```\n\n### Asynchronous Sample Reading\n\n```csharp\n// Configure async buffer\ndevice.MaxAsyncBufferSize = 512 * 1024;\ndevice.DropSamplesOnFullBuffer = true;\n\n// Start async reading in background\ndevice.StartReadSamplesAsync();\n\n// Option 1: Event-based (recommended for real-time processing)\ndevice.SamplesAvailable += (sender, args) =\u003e\n{\n    var samples = device.GetSamplesFromAsyncBuffer(args.SampleCount);\n    // Process samples in real-time\n};\n\n// Option 2: Manual polling (for custom processing logic)\nwhile (running)\n{\n    if (device.AsyncBuffer.TryDequeue(out var data))\n    {\n        // Process data\n        Console.WriteLine($\"Received {data.Samples.Length} samples\");\n    }\n    else\n    {\n        await Task.Delay(100);\n    }\n}\n\n// Stop reading when done\ndevice.StopReadSamplesAsync();\n\n// Clean up\nmanager.CloseManagedDevice(\"my-rtl-sdr\");\n```\n\n### Manual Gain Control\n\n```csharp\n// Switch to manual gain mode\ndevice.TunerGainMode = TunerGainModes.Manual;\n\n// Get supported gain values\nvar gains = device.SupportedTunerGains;\nConsole.WriteLine($\"Supported gains: {string.Join(\", \", gains)} dB\");\n\n// Set specific gain\ndevice.TunerGain = 42.1; // dB\n\n// Or use convenience methods\ndevice.SetMaximumTunerGain();\ndevice.SetMinimumTunerGain();\n```\n\n### Frequency Operations\n\n```csharp\n// Create frequencies with different units\nvar freq1 = Frequency.FromHz(1090_000_000);\nvar freq2 = Frequency.FromKHz(1090_000);\nvar freq3 = Frequency.FromMHz(1090);\nvar freq4 = Frequency.FromGHz(1.09);\n\n// Convert between units\nConsole.WriteLine($\"{freq1.Hz} Hz\");\nConsole.WriteLine($\"{freq1.KHz} KHz\");\nConsole.WriteLine($\"{freq1.MHz} MHz\");\nConsole.WriteLine($\"{freq1.GHz} GHz\");\n\n// Arithmetic operations\nvar shifted = freq1 + Frequency.FromKHz(100); // Add 100 KHz offset\nvar doubled = freq1 * 2;\n\n// Comparison\nif (freq1 \u003e Frequency.FromMHz(100))\n{\n    Console.WriteLine(\"Above 100 MHz\");\n}\n```\n\n### Advanced Features\n\n#### Bias Tee (for powering external LNAs)\n\n```csharp\n// Enable bias tee on GPIO 0 (most common)\ndevice.SetBiasTee(BiasTeeModes.Enabled);\n\n// For R820T tuners, specify GPIO pin\ndevice.SetBiasTeeGPIO(gpio: 0, BiasTeeModes.Enabled);\n```\n\n#### Direct Sampling (HF reception)\n\n```csharp\n// Enable direct sampling on I-ADC\ndevice.DirectSamplingMode = DirectSamplingModes.I_ADC;\n\n// Or on Q-ADC\ndevice.DirectSamplingMode = DirectSamplingModes.Q_ADC;\n\n// Disable\ndevice.DirectSamplingMode = DirectSamplingModes.Disabled;\n```\n\n#### Frequency Correction (PPM)\n\n```csharp\n// Set frequency correction in PPM\ndevice.FrequencyCorrection = 10; // +10 PPM\n```\n\n#### KerberosSDR Support\n\n```csharp\n// Enable KerberosSDR mode (required for these features)\ndevice.KerberosSDRMode = KerberosSDRModes.Enabled;\n\n// Enable frequency dithering (for R820T only)\ndevice.FrequencyDitheringMode = FrequencyDitheringModes.Enabled;\n\n// Control GPIO pins directly\ndevice.SetGPIO(gpio: 1, GPIOModes.Enabled);\n```\n\n## 📚 Documentation\n\nFor more detailed information and advanced usage scenarios:\n\n- [**Basic Setup**](docs/BASIC_SETUP.md) - Getting started with device initialization\n- [**Device Management**](docs/DEVICE_MANAGEMENT.md) - Managing multiple RTL-SDR devices\n- [**Manual Gain Control**](docs/MANUAL_GAIN_CONTROL.md) - Configuring tuner gain settings\n- [**Direct Sampling**](docs/DIRECT_SAMPLING.md) - Using direct sampling modes for HF\n- [**Frequency Correction**](docs/FREQUENCY_CORRECTION.md) - PPM frequency correction\n- [**Bias Tee**](docs/BIAS_TEE.md) - Enabling bias tee for powering external LNAs\n- [**KerberosSDR**](docs/KERBEROS_SDR.md) - Advanced features for KerberosSDR arrays\n\n### Sample Applications\n\nCheck out the [`samples/`](samples/) directory for complete working examples:\n\n- **Demo1** - Event-based async sample reading\n- **Demo2** - Manual polling from async buffer\n- **Demo3** - Synchronous sample reading\n- **Demo4** - Device information and configuration\n\n## 🔧 Building from Source\n\n### Requirements\n\n- .NET 9.0 SDK or later\n- librtlsdr native library\n\n### Build Commands\n\n```bash\n# Clone the repository\ngit clone https://github.com/nandortoth/rtlsdr-manager.git\ncd rtlsdr-manager\n\n# Build the entire solution\ndotnet build\n\n# Run tests (if available)\ndotnet test\n\n# Create NuGet packages\ndotnet pack --configuration Release\n\n# Or use the convenience script\n./build.sh\n```\n\n### Build Output\n\nThe build process creates:\n- **NuGet packages** → `artifacts/packages/`\n- **Library binaries** → `artifacts/binaries/RtlSdrManager/`\n- **Sample binaries** → `artifacts/binaries/Samples/`\n\n### Running Samples\n\n```bash\n# Using the convenience script\n./runsample.sh\n\n# Or manually\ndotnet run --project samples/RtlSdrManager.Samples\n```\n\n## 🏗️ Architecture\n\n```\nRtlSdrManager/\n├── src/\n│   └── RtlSdrManager/           # Main library\n│       ├── Exceptions/          # Custom exception types\n│       ├── Hardware/            # Hardware type definitions\n│       ├── Interop/             # P/Invoke wrappers\n│       └── Modes/               # Enumeration types\n├── samples/\n│   └── RtlSdrManager.Samples/   # Example applications\n└── docs/                        # Documentation\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit issues, fork the repository, and create pull requests.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nPlease ensure your code:\n- Follows the EditorConfig style guidelines\n- Builds without warnings\n- Includes XML documentation for public APIs\n- Includes unit tests for new features (when applicable)\n\n## 📋 System Requirements\n\n- **.NET Runtime:** 9.0 or later\n- **Operating System:** Windows, Linux, macOS\n- **Hardware:** RTL-SDR compatible device (RTL2832U-based)\n- **Native Library:** librtlsdr installed on the system\n\n## 📝 Supported Devices\n\nThis library supports RTL-SDR devices with the following tuners:\n\n| Tuner | Frequency Range | Notes |\n|-------|----------------|-------|\n| **Elonics E4000** | 52-1100 MHz, 1250-2200 MHz | No longer manufactured |\n| **Rafael Micro R820T** | 24-1766 MHz | Most common, excellent performance |\n| **Rafael Micro R828D** | 24-1766 MHz | Similar to R820T |\n| **Fitipower FC0012** | 22-948.6 MHz | Basic performance |\n| **Fitipower FC0013** | 22-1100 MHz | Basic performance |\n| **FCI FC2580** | 146-308 MHz, 438-924 MHz | Good performance |\n\n## 📜 License\n\nThis project is licensed under the **GNU General Public License v3.0 or later** - see the [LICENSE.md](LICENSE.md) file for details.\n\n```\nRTL-SDR Manager Library for .NET\nCopyright (C) 2018-2025 Nandor Toth\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n```\n\n## 🔗 Links\n\n- **NuGet Package:** https://www.nuget.org/packages/RtlSdrManager/\n- **GitHub Repository:** https://github.com/nandortoth/rtlsdr-manager\n- **Issue Tracker:** https://github.com/nandortoth/rtlsdr-manager/issues\n- **Changelog:** [CHANGELOG.md](CHANGELOG.md)\n- **librtlsdr:** https://github.com/osmocom/rtl-sdr\n\n## 🙏 Acknowledgments\n\n- [Osmocom rtl-sdr project](https://osmocom.org/projects/rtl-sdr/wiki) for the excellent native library\n- [KerberosSDR project](https://github.com/rtlsdrblog/rtl-sdr-kerberos) for coherent SDR extensions\n- All contributors and users of this library\n\n## 📊 Project Status\n\n- ✅ **Stable** - Production ready\n- ✅ **Actively Maintained** - Regular updates and bug fixes\n- ✅ **.NET 9.0** - Modern .NET with latest features\n- ✅ **Cross-Platform** - Windows, Linux, macOS support\n\n---\n\n**Made with ❤️ by [Nandor Toth](https://github.com/nandortoth)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnandortoth%2Frtlsdr-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnandortoth%2Frtlsdr-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnandortoth%2Frtlsdr-manager/lists"}