public BladeRFControllerDialog(BladeRFIO owner) { InitializeComponent(); _owner = owner; InitSampleRates(); InitBandwidths(); InitXB200Filters(); InitGainSettings(); var devices = DeviceDisplay.GetActiveDevices(); deviceComboBox.Items.Clear(); if (devices != null) { deviceComboBox.Items.AddRange(devices); } samplerateComboBox.SelectedIndex = Utils.GetIntSetting("BladeRFSampleRate", 3); samplingModeComboBox.SelectedIndex = Utils.GetIntSetting("BladeRFSamplingMode", (int)bladerf_sampling.BLADERF_SAMPLING_INTERNAL); //rxVga1GainTrackBar.Value = Utils.GetIntSetting("BladeRFVGA1Gain", 20); gainTrackBar.Value = Utils.GetIntSetting("BladeRFVGA2Gain", 20); //lnaGainTrackBar.Value = Utils.GetIntSetting("BladeRFLNAGain", (int) bladerf_lna_gain.BLADERF_LNA_GAIN_MID); fpgaTextBox.Text = Utils.GetStringSetting("BladeRFFPGA", ""); bandwidthComboBox.SelectedIndex = Utils.GetIntSetting("BladeRFBandwidth", 0); agcMode.SelectedIndex = Utils.GetIntSetting("BladeRFAGC", 0); xb200Checkbox.Checked = Utils.GetBooleanSetting("BladeRFXB200Enabled"); xb200FilterCombobox.SelectedIndex = Utils.GetIntSetting("BladeRFXB200Filter", 0); labelVersion.Text = "libbladerf " + NativeMethods.bladerf_version().describe; //rxVga1gainLabel.Text = rxVga1GainTrackBar.Value + " dB"; gainLabel.Text = gainTrackBar.Value + " dB"; gainLabel.Text = String.Format("{0} dB", 3 * (gainTrackBar.Value - 1));; _initialized = true; }
public static unsafe DeviceDisplay[] GetActiveDevices() { IntPtr _tmp; bladerf_devinfo* devlist; int count = NativeMethods.bladerf_get_device_list(out _tmp); if (_tmp == IntPtr.Zero) { return null; } DeviceDisplay[] result = new DeviceDisplay[count]; devlist = (bladerf_devinfo*)_tmp; for (int i = 0; i < count; i++) { int bus = (int)(devlist[i].usb_bus); int address = (int)(devlist[i].usb_addr); string backend = NativeMethods.backend_to_str(devlist[i].backend); string serial = new String(devlist[i].serial, 0, 32, System.Text.Encoding.ASCII); string name = String.Format("BladeRF ({0}) SN#{1}..{2} ({3}:{4})", backend, serial.Substring(0, 4), serial.Substring(27, 4), bus, address); result[i] = new DeviceDisplay { Index = i, Name = name, Serial = serial, Address = address, Bus = bus, Backend = backend }; } NativeMethods.bladerf_free_device_list(_tmp); return result; }