public static DeviceDisplay[] GetActiveDevices() { var count = NativeMethods.rtlsdr_get_device_count(); var result = new DeviceDisplay[count]; for (var i = 0u; i < count; i++) { var name = NativeMethods.rtlsdr_get_device_name(i); result[i] = new DeviceDisplay { Index = i, Name = name }; } return result; }
public static DeviceDisplay[] GetActiveDevices() { var count = NativeMethods.rtlsdr_get_device_count(); var result = new DeviceDisplay[count]; for (var i = 0u; i < count; i++) { var name = NativeMethods.rtlsdr_get_device_name(i); result[i] = new DeviceDisplay { Index = i, Name = name }; } return(result); }
public static DeviceDisplay[] GetActiveDevices() { uint deviceCount = NativeMethods.rtlsdr_get_device_count(); DeviceDisplay[] deviceDisplayArray = new DeviceDisplay[(IntPtr) deviceCount]; for (uint index = 0U; index < deviceCount; ++index) { string deviceName = NativeMethods.rtlsdr_get_device_name(index); deviceDisplayArray[(IntPtr) index] = new DeviceDisplay() { Index = index, Name = deviceName }; } return deviceDisplayArray; }
public void Open() { var devices = DeviceDisplay.GetActiveDevices(); foreach (var device in devices) { try { SelectDevice(device.Index); return; } catch (ApplicationException) { // Just ignore it } } if (devices.Length > 0) { throw new ApplicationException(devices.Length + " compatible devices have been found but are all busy"); } throw new ApplicationException("No compatible devices found"); }
public MainForm() { InitializeComponent(); _dataSet.Columns.Add("ICAO", typeof(string)); _dataSet.Columns.Add("LastUpdate", typeof(DateTime)); _dataSet.Columns.Add("Identification", typeof(string)); _dataSet.Columns.Add("Category", typeof(string)); _dataSet.Columns.Add("Squawk", typeof(string)); _dataSet.Columns.Add("AirborneVelocity", typeof(string)); _dataSet.Columns.Add("SIL", typeof(string)); _dataSet.Columns.Add("SDA", typeof(string)); _dataSet.Columns.Add("BarometricAltitude", typeof(string)); _dataSet.Columns.Add("Lattitude", typeof(string)); _dataSet.Columns.Add("Longitude", typeof(string)); dataGridView1.DataSource = _dataSet; dataGridView1.Columns["LastUpdate"].DefaultCellStyle.Format = "dd/MM/yyyy HH:mm:ss"; dataGridView1.Columns["LastUpdate"].Width = 130; var adsbTranslator = new AdsbTranslator(); adsbTranslator.Statistics = new Statistics(); Text = "ADSB# v" + Assembly.GetExecutingAssembly().GetName().Version; _decoder.FrameReceived += delegate(byte[] frame, int length) { Interlocked.Increment(ref _frameCount); var t = new ModeSTranslator(); t.Statistics = new Statistics(); var modeSMessage = t.Translate(frame, 0, null, false); AdsbTranslator t2 = new AdsbTranslator(); t2.Statistics = new Statistics(); AdsbMessage adsbMessage = t2.Translate(modeSMessage); if (adsbMessage != null) { BeginInvoke(new Action(delegate { Debug.Print(adsbMessage.ToString()); UpdateView(adsbMessage); })); } }; confidenceNumericUpDown_ValueChanged(null, null); timeoutNumericUpDown_ValueChanged(null, null); try { _rtlDevice.Open(); var devices = DeviceDisplay.GetActiveDevices(); deviceComboBox.Items.Clear(); deviceComboBox.Items.AddRange(devices); //_initialized = true; deviceComboBox.SelectedIndex = 0; deviceComboBox_SelectedIndexChanged(null, null); } catch (Exception e) { MessageBox.Show(e.Message); } }