예제 #1
0
        public unsafe void Start()
        {
            if (_isStreaming)
            {
                throw new ApplicationException("Start() Already running");
            }

            PlutoSDRControllerDialog gui = _plutoSDRIO.GUI;

            _gui.samplerateComboBox.Enabled = false;

            if (_dev == null)
            {
                createContext();
            }

            configureReceiver();

            Device lpc = _ctx.get_device("cf-ad9361-lpc");

            if (lpc == null)
            {
                throw new ApplicationException("Device cf-ad9361-lpc not found!");
            }

            _rx0_i = IIOHelper.FindChannel(lpc, "voltage0");
            _rx0_q = IIOHelper.FindChannel(lpc, "voltage1");

            _rx0_i.enable();
            _rx0_q.enable();

            if (_buf != null)
            {
                _buf.Dispose();
            }
            _buf = new IOBuffer(lpc, _readLength, false);
            if (_buf == null)
            {
                throw new ApplicationException("Could not initialize I/Q sample buffer");
            }

            // new sync interface
            _sampleThread          = new Thread(ReceiveSamples_sync);
            _sampleThread.Name     = "PlutoSDR_samples_rx";
            _sampleThread.Priority = ThreadPriority.Highest;
            _isStreaming           = true;
            _sampleThread.Start();
            bool ready = false;

            while (!ready)
            {
                lock (syncLock)
                {
                    ready = _RXConfigured;
                }
            }
        }
예제 #2
0
        public bool createContext()
        {
            _gui.deviceUriTextbox.Enabled = false;
            _gui.connectButton.Enabled    = false;

            try
            {
                //MessageBox.Show(_gui.deviceUriTextbox.Text);
                _ctx = new iio.Context(_gui.deviceUriTextbox.Text);

                _gui.libiioVersionLabel.Text = _ctx.backend_version.git_tag;
                _dev = _ctx.get_device("ad9361-phy");

                if (_dev == null)
                {
                    throw new ApplicationException("Cannot open device ad9361-phy");
                }

                // check if the frequency range was extended
                try
                {
                    // try to tune the LO to 100 MHz (outside of the AD9363 tuning range)
                    IIOHelper.SetAttribute(_dev, "altvoltage0", "frequency", "100000000", false);
                    IIOHelper.SetAttribute(_dev, "altvoltage0", "frequency", _centerFrequency.ToString(), false);
                }
                catch (Exception ex)
                {
                    MinFrequency     = 325000000L;
                    MaxFrequency     = 3800000000L;
                    _centerFrequency = MinFrequency;
                }

                Utils.SaveSetting("PlutoSDRURI", _gui.deviceUriTextbox.Text);

                _gui.receiverPanel.Enabled = true;

                _gui.contextDetailsLabel.Text = _ctx.description;


                return(true);
            }
            catch (Exception ex)
            {
                _gui.deviceUriTextbox.Enabled = true;
                _gui.connectButton.Enabled    = true;
                throw ex;
            }
        }