Пример #1
0
        public void Start(SamplesAvailableDelegate callback)
        {
            m_callback       = callback;
            m_host           = m_gui.Hostname;
            m_port           = m_gui.Port;
            m_socket         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            m_socket.NoDelay = true;
            m_socket.Connect(m_host, m_port);

            var dongleInfo = new byte[DongleInfoLength];

            var length = m_socket.Receive(dongleInfo, 0, DongleInfoLength, SocketFlags.None);

            if (length > 0)
            {
                ParseDongleInfo(dongleInfo);
            }

            SendCommand(CMD_SET_SAMPLE_RATE, (uint)m_sampleRate);
            SendCommand(CMD_SET_FREQ_COR, m_frequencyCorrection);
            SendCommand(CMD_SET_FREQ, (uint)m_frequency);
            SendCommand(CMD_SET_AGC_MODE, (uint)(m_useRtlAGC ? 1 : 0));
            SendCommand(CMD_SET_SAMPLING_MODE, (m_rtlSamplingMode));
            SendCommand(CMD_SET_OFFSET_TUNING, m_offsetTuning ? 1 : 0);
            SendCommand(CMD_SET_TUNER_GAIN_MODE, (uint)(m_useTunerAGC ? 0 : m_useTunerAGCE4K));
            SendCommand(CMD_SET_TUNER_GAIN_INDEX, (m_tunerGainIndex));

            m_sampleThread = new Thread(RecieveSamples);
            m_sampleThread.Start();

            Utils.SaveSetting("RTLTcpHost", m_host);
            Utils.SaveSetting("RTLTcpPort", m_port);
        }
Пример #2
0
        private unsafe void PushIQData(Complex *samples, int count)
        {
            ComplexSamplesEventArgs e = new ComplexSamplesEventArgs
            {
                Buffer         = samples,
                Length         = count,
                DroppedSamples = (uint)((int)this._droppedBuffers * count)
            };

            this._droppedBuffers = 0u;
            if (this._autoGainDecibels != 0)
            {
                float b = (float)Math.Pow(10.0, (double)((float)(double)this._autoGainDecibels * -0.05f));
                for (int i = 0; i < count; i++)
                {
                    Complex *intPtr  = samples + i;
                    *        intPtr *= b;
                }
            }
            SamplesAvailableDelegate <ComplexSamplesEventArgs> samplesAvailable = this.SamplesAvailable;

            if (samplesAvailable != null)
            {
                samplesAvailable(this, e);
            }
        }
Пример #3
0
        public void Stop()
        {
            Console.WriteLine("Stop");
            int  v4l2_r;
            int  type = V4L2_BUF_TYPE_SDR_CAPTURE;
            int *ptr  = &type;

            streaming = false;

            // stop streaming
            //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_STREAMOFF, (IntPtr)ptr);
            v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_STREAMOFF, (IntPtr)ptr);
            Console.WriteLine("v4l2_ioctl CMD64_VIDIOC_STREAMOFF r = {0}", v4l2_r);

            // v4l2_munmap buffers
            for (int i = (int)n_buffers - 1; i >= 0; i--)
            {
                //NativeMethods.v4l2_munmap(mmap_start[i], mmap_length[i]);
                NativeMethods.munmap(mmap_start[i], mmap_length[i]);
//				NativeMethods.v4l2_munmap(mmap[i].start, mmap[i].length);
                Console.WriteLine("v4l2_munmap = {0}", i);
            }

            if (_sampleThread != null)
            {
                _sampleThread.Join();
                _sampleThread = null;
            }

            _callback = null;
        }
Пример #4
0
        public void Start(SamplesAvailableDelegate callback)
        {
            _callback  = callback;
            _host      = _gui.Hostname;
            _port      = _gui.Port;
            _s         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _s.NoDelay = true;
            _s.Connect(_host, _port);

            var dongleInfo = new byte[DongleInfoLength];

            var length = _s.Receive(dongleInfo, 0, DongleInfoLength, SocketFlags.None);

            if (length > 0)
            {
                ParseDongleInfo(dongleInfo);
            }

            SendCommand(CMD_SET_SAMPLE_RATE, (uint)_sampleRate);
            SendCommand(CMD_SET_FREQ, (uint)_frequency);
            SendCommand(CMD_SET_TUNER_AMP, (uint)(_useTunerAMP ? 1 : 0));
            SendCommand(CMD_SET_TUNER_VGA_GAIN, _tunerGainVGA);
            SendCommand(CMD_SET_TUNER_LNA_GAIN, _tunerGainLNA);
            SendCommand(CMD_SET_TUNER_IF, _tunerIF);

            _sampleThread = new Thread(RecieveSamples);
            _sampleThread.Start();

            Utils.SaveSetting("HRFTCPHost", _host);
            Utils.SaveSetting("HRFTCPPort", _port);
        }
Пример #5
0
        public void Start(SamplesAvailableDelegate callback)
        {
            _callback  = callback;
            _host      = _gui.Hostname;
            _port      = _gui.Port;
            _s         = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _s.NoDelay = true;
            _s.Connect(_host, _port);

            var dongleInfo = new byte[DongleInfoLength];

            var length = _s.Receive(dongleInfo, 0, DongleInfoLength, SocketFlags.None);

            if (length > 0)
            {
                ParseDongleInfo(dongleInfo);
            }

            SendCommand(CMD_SET_SAMPLE_RATE, (uint)_sampleRate);
            SendCommand(CMD_SET_FREQ_COR, _frequencyCorrection);
            SendCommand(CMD_SET_FREQ, (uint)_frequency);
            SendCommand(CMD_SET_AGC_MODE, (uint)(_useRtlAGC ? 1 : 0));
            SendCommand(CMD_SET_TUNER_GAIN_MODE, (uint)(_useTunerAGC ? 0 : 1));
            SendCommand(CMD_SET_TUNER_GAIN_INDEX, (_tunerGainIndex));

            _sampleThread = new Thread(RecieveSamples);
            _sampleThread.Start();

            Utils.SaveSetting("RTLTcpHost", _host);
            Utils.SaveSetting("RTLTcpPort", _port);
        }
Пример #6
0
        private void Client_FFTAvailable(object sender, ByteSamplesEventArgs e)
        {
            SamplesAvailableDelegate <ByteSamplesEventArgs> fFTAvailable = this.FFTAvailable;

            if (fFTAvailable != null)
            {
                fFTAvailable(sender, e);
            }
        }
Пример #7
0
        public void Start(SamplesAvailableDelegate cb)
        {
            mInstance = new Callback(native_cb);

            _callback = cb;

            f4sdr_setcb(mInstance);
            f4sdr_open();
        }
Пример #8
0
 public unsafe void Start(SamplesAvailableDelegate callback)
 {
     if (this._client != null && this._client.IsSynchronized)
     {
         this._callback = callback;
         this._client.StartStreaming();
         return;
     }
     throw new ApplicationException("Not connected to a server");
 }
Пример #9
0
 public void Stop()
 {
     Close();
     if (m_sampleThread != null)
     {
         m_sampleThread.Join();
         m_sampleThread = null;
     }
     m_callback = null;
 }
Пример #10
0
 public void Stop()
 {
     Close();
     if (_sampleThread != null)
     {
         _sampleThread.Join();
         _sampleThread = null;
     }
     _callback = null;
 }
Пример #11
0
 public unsafe void Stop()
 {
     lock (this)
     {
         this._callback = null;
     }
     this.Close();
     if (this._sampleThread != null)
     {
         this._sampleThread.Join();
     }
 }
Пример #12
0
        protected unsafe virtual void OnRealSamplesAvailable(float *buffer, int length, ulong droppedSamples)
        {
            SamplesAvailableDelegate <RealSamplesEventArgs> realSamplesAvailable = this.RealSamplesAvailable;

            if (realSamplesAvailable != null)
            {
                RealSamplesEventArgs realSamplesEventArgs = new RealSamplesEventArgs();
                realSamplesEventArgs.Buffer         = buffer;
                realSamplesEventArgs.Length         = length;
                realSamplesEventArgs.DroppedSamples = droppedSamples;
                realSamplesAvailable(this, realSamplesEventArgs);
            }
        }
Пример #13
0
        protected unsafe virtual void OnComplexSamplesAvailable(Complex *buffer, int length, ulong droppedSamples)
        {
            SamplesAvailableDelegate <ComplexSamplesEventArgs> samplesAvailable = this.SamplesAvailable;

            if (samplesAvailable != null)
            {
                ComplexSamplesEventArgs complexSamplesEventArgs = new ComplexSamplesEventArgs();
                complexSamplesEventArgs.Buffer         = buffer;
                complexSamplesEventArgs.Length         = length;
                complexSamplesEventArgs.DroppedSamples = droppedSamples;
                samplesAvailable(this, complexSamplesEventArgs);
            }
        }
Пример #14
0
        private unsafe void ProcessUInt8FFT()
        {
            ByteSamplesEventArgs e = new ByteSamplesEventArgs
            {
                Buffer = (byte *)(void *)this._messageBuffer,
                Length = this._messageSize
            };
            SamplesAvailableDelegate <ByteSamplesEventArgs> fFTAvailable = this.FFTAvailable;

            if (fFTAvailable != null)
            {
                fFTAvailable(this, e);
            }
        }
Пример #15
0
 public unsafe void Start(SamplesAvailableDelegate callback)
 {
     this._callback = callback;
     try
     {
         if (this._device == null)
         {
             this.Open();
         }
         this._device.Start();
         this.SetDeviceFrequency();
     }
     catch
     {
         this.Close();
         throw;
     }
 }
Пример #16
0
 public unsafe void Start(SamplesAvailableDelegate callback)
 {
     lock (this)
     {
         this._callback = callback;
     }
     this._s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     this._s.Connect(this._host, this._port);
     this._sampleThread = new Thread((ThreadStart) delegate
     {
         this.receiveSamples();
     });
     this._sampleThread.Start();
     this.sendCommand(3, this._gainMode);
     this.sendCommand(2, (uint)this._sr);
     this.sendCommand(1, (uint)this._freq);
     this.sendCommand(5, this._fCor);
 }
Пример #17
0
        public void Start(SDRSharp.Radio.SamplesAvailableDelegate callback)
        {
            _callback = callback;
            _hostName = _gui.Host;
            _port     = _gui.Port;
            _is16Bit  = _gui.Use16Bit;

            _lostPacketsCount   = 0;
            _circularBufferHead = 0;
            _circularBufferTail = 0;
            _sampleCount        = 0;

            _sampleBuffer     = UnsafeBuffer.Create(256 * 2, sizeof(Complex));
            _sampleBufferPtr  = (Complex *)_sampleBuffer;
            _workingSamplePtr = _sampleBufferPtr;

            _client = new SdrIpClient();
            _client.Connect(_hostName, _port);
            _client.Samplerate = _sampleRate;
            _client.Frequency  = _frequency;
            _client.Use16Bit   = _is16Bit;

            _udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _udpSocket.ReceiveBufferSize = 65535;
            var remoteIpEndPoint = new IPEndPoint(IPAddress.Any, _port);

            _udpSocket.Bind(remoteIpEndPoint);
            _udpThread          = new Thread(UdpReceiverThread);
            _udpThread.Priority = ThreadPriority.Highest;
            _udpThreadRunning   = true;
            _udpThread.Start();

            _workerThread        = new Thread(WorkerThread);
            _workerThreadRunning = true;
            _workerThread.Start();

            _client.StartStreaming();
            _tuneTimer.Start();

            Utils.SaveSetting("SDRIPHost", _hostName);
            Utils.SaveSetting("SDRIPPort", _port);
            Utils.SaveSetting("SDRIPRateIndex", _gui.SamepleRateIndex);
            Utils.SaveSetting("SDRIPFormatIndex", _gui.SampleFormatIndex);
        }
Пример #18
0
 public void Stop()
 {
     Close();
     if (_sampleThread != null)
     {
         _sampleThread.Join();
         _sampleThread = null;
     }
     _callback = null;           
 }
Пример #19
0
        public void Start(SamplesAvailableDelegate callback)
        {
            _callback = callback;
            _host = _gui.Hostname;
            _port = _gui.Port;
            _s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _s.NoDelay = true;
            _s.Connect(_host, _port);

            var dongleInfo = new byte[DongleInfoLength];

            var length = _s.Receive(dongleInfo, 0, DongleInfoLength, SocketFlags.None);
            if (length > 0)
            {
                ParseDongleInfo(dongleInfo);
            }
            
            SendCommand(CMD_SET_SAMPLE_RATE, (uint)_sampleRate);
            SendCommand(CMD_SET_FREQ_COR, _frequencyCorrection);
            SendCommand(CMD_SET_FREQ, (uint)_frequency);
            SendCommand(CMD_SET_AGC_MODE, (uint)(_useRtlAGC ? 1 : 0));
            SendCommand(CMD_SET_TUNER_GAIN_MODE, (uint)(_useTunerAGC ? 0 : 1));
            SendCommand(CMD_SET_TUNER_GAIN_INDEX, (_tunerGainIndex));

            _sampleThread = new Thread(RecieveSamples);            
            _sampleThread.Start();
            
            Utils.SaveSetting("RTLTcpHost", _host);
            Utils.SaveSetting("RTLTcpPort", _port);
        }
Пример #20
0
 public unsafe void Start(SamplesAvailableDelegate callback)
 {
     this._callback = callback;
       this._hostName = this._gui.Host;
       this._port = this._gui.Port;
       this._is16Bit = this._gui.Use16Bit;
       this._lostPacketsCount = 0L;
       this._circularBufferHead = 0;
       this._circularBufferTail = 0;
       this._sampleCount = 0;
       this._sampleBuffer = UnsafeBuffer.Create(512, sizeof (Complex));
       this._sampleBufferPtr = (Complex*) (void*) this._sampleBuffer;
       this._workingSamplePtr = this._sampleBufferPtr;
       this._client = new SdrIpClient();
       this._client.Connect(this._hostName, this._port);
       this._client.Samplerate = this._sampleRate;
       this._client.Frequency = this._frequency;
       this._client.Use16Bit = this._is16Bit;
       this._udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
       this._udpSocket.ReceiveBufferSize = (int) ushort.MaxValue;
       this._udpSocket.Bind((EndPoint) new IPEndPoint(IPAddress.Any, this._port));
       this._udpThread = new Thread(new ThreadStart(this.UdpReceiverThread));
       this._udpThread.Priority = ThreadPriority.Highest;
       this._udpThreadRunning = true;
       this._udpThread.Start();
       this._workerThread = new Thread(new ThreadStart(this.WorkerThread));
       this._workerThreadRunning = true;
       this._workerThread.Start();
       this._client.StartStreaming();
       this._tuneTimer.Start();
       Utils.SaveSetting("SDRIPHost", this._hostName);
       Utils.SaveSetting("SDRIPPort", (object) this._port);
       Utils.SaveSetting("SDRIPRateIndex", (object) this._gui.SamepleRateIndex);
       Utils.SaveSetting("SDRIPFormatIndex", (object) this._gui.SampleFormatIndex);
 }
 public void Start(SamplesAvailableDelegate callback)
 {
     ExtIO.SamplesAvailable = callback;
     ExtIO.StartHW(ExtIO.GetHWLO());
 }
Пример #22
0
 public unsafe void Start(SamplesAvailableDelegate callback)
 {
     ExtIO.SamplesAvailable = callback;
     ExtIO.StartHW(Math.Max(0, ExtIO.GetHWLO()));
 }
Пример #23
0
 public void Start(SamplesAvailableDelegate callback)
 {
     ExtIO.SamplesAvailable = callback;
     ExtIO.StartHW(ExtIO.GetHWLO());
 }
Пример #24
0
 public void Start(SamplesAvailableDelegate callback)
 {
     this._callback = callback;
       this._host = this._gui.Hostname;
       this._port = this._gui.Port;
       this._s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
       this._s.NoDelay = true;
       this._s.Connect(this._host, this._port);
       byte[] buffer = new byte[12];
       if (this._s.Receive(buffer, 0, 12, SocketFlags.None) > 0)
     this.ParseDongleInfo(buffer);
       this.SendCommand((byte) 2, (uint) this._sampleRate);
       this.SendCommand((byte) 5, this._frequencyCorrection);
       this.SendCommand((byte) 1, (uint) this._frequency);
       this.SendCommand((byte) 8, this._useRtlAGC ? 1U : 0U);
       this.SendCommand((byte) 3, this._useTunerAGC ? 0U : 1U);
       this.SendCommand((byte) 13, this._tunerGainIndex);
       this._sampleThread = new Thread(new ThreadStart(this.RecieveSamples));
       this._sampleThread.Start();
       Utils.SaveSetting("RTLTcpHost", this._host);
       Utils.SaveSetting("RTLTcpPort", (object) this._port);
 }
Пример #25
0
 public void Stop()
 {
     this.Close();
       if (this._sampleThread != null)
       {
     this._sampleThread.Join();
     this._sampleThread = (Thread) null;
       }
       this._callback = (SamplesAvailableDelegate) null;
 }
Пример #26
0
        public void Start(SamplesAvailableDelegate callback)
        {
            _callback = callback;
            _host = _gui.Hostname;
            _port = _gui.Port;
            _s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _s.NoDelay = true;
            _s.Connect(_host, _port);

            var dongleInfo = new byte[DongleInfoLength];

            var length = _s.Receive(dongleInfo, 0, DongleInfoLength, SocketFlags.None);
            if (length > 0)
            {
                ParseDongleInfo(dongleInfo);
            }

            SendCommand(CMD_SET_SAMPLE_RATE, (uint)_sampleRate);
            SendCommand(CMD_SET_FREQ, (uint)_frequency);
            SendCommand(CMD_SET_TUNER_AMP, (uint)(_useTunerAMP ? 1 : 0));
            SendCommand(CMD_SET_TUNER_VGA_GAIN, _tunerGainVGA);
            SendCommand(CMD_SET_TUNER_LNA_GAIN, _tunerGainLNA);
            SendCommand(CMD_SET_TUNER_IF, _tunerIF);

            _sampleThread = new Thread(RecieveSamples);
            _sampleThread.Start();

            Utils.SaveSetting("HRFTCPHost", _host);
            Utils.SaveSetting("HRFTCPPort", _port);
        }
Пример #27
0
        public void Stop()
        {
            Console.WriteLine("Stop");
            int v4l2_r;
            int type = V4L2_BUF_TYPE_SDR_CAPTURE;
            int *ptr = & type;
            streaming = false;

            // stop streaming
            //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_STREAMOFF, (IntPtr)ptr);
            v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_STREAMOFF, (IntPtr)ptr);
            Console.WriteLine("v4l2_ioctl CMD64_VIDIOC_STREAMOFF r = {0}", v4l2_r);

            // v4l2_munmap buffers
            for (int i = (int) n_buffers - 1; i >= 0; i--) {
                //NativeMethods.v4l2_munmap(mmap_start[i], mmap_length[i]);
                NativeMethods.munmap(mmap_start[i], mmap_length[i]);
            //				NativeMethods.v4l2_munmap(mmap[i].start, mmap[i].length);
                Console.WriteLine("v4l2_munmap = {0}", i);
            }

            if (_sampleThread != null)
            {
                _sampleThread.Join();
                _sampleThread = null;
            }

            _callback = null;
        }
Пример #28
0
 public void Start(SamplesAvailableDelegate callback)
 {
 }
Пример #29
0
        public void Start(SamplesAvailableDelegate callback)
        {
            if (string.IsNullOrEmpty(_gui.FileName))
            {
                return;
            }

            if (!File.Exists(_gui.FileName))
            {
                return;
            }

            _requestStop = false;

            SDRSharp.Radio.DSPThreadPool.QueueUserWorkItem(delegate
            {
                _isRunning              = new AutoResetEvent(false);
                const int headerSize    = 32;
                const int maxBufferSize = 4096 * 2;
                var bufferSize          = maxBufferSize;
                var buffer              = new Complex[bufferSize];
                fixed(Complex * ptr     = &buffer[0])
                {
                    using (var strm = File.OpenRead(_gui.FileName))
                        using (var reader = new BinaryReader(strm))
                        {
                            strm.Seek(headerSize, SeekOrigin.Begin); // Skip header
                            var rewind = false;
                            while (true)
                            {
                                var start = DateTime.Now;
                                if (strm.Position > strm.Length - SignalRecorderPlugin.BytesPerSample * bufferSize)
                                {
                                    bufferSize = (int)(strm.Length - strm.Position) / SignalRecorderPlugin.BytesPerSample;
                                    rewind     = true;
                                }

                                for (var n = 0; n < bufferSize; n++)
                                {
                                    switch (SignalRecorderPlugin.BytesPerSample)
                                    {
                                    case 2:
                                        byte r         = reader.ReadByte();
                                        byte i         = reader.ReadByte();
                                        buffer[n].Real = (r * 2 - 1) * SignalRecorderPlugin.MaxDataRange;
                                        buffer[n].Imag = (i * 2 - 1) * SignalRecorderPlugin.MaxDataRange;
                                        break;

                                    case 8:
                                        buffer[n].Real = reader.ReadSingle();
                                        buffer[n].Imag = reader.ReadSingle();
                                        break;
                                    }
                                }

                                if (_requestStop)
                                {
                                    break;
                                }

                                if (bufferSize > 0)
                                {
                                    callback(this, ptr, bufferSize);
                                }

                                var t = DateTime.Now - start;
                                var s = TimeSpan.FromMilliseconds(bufferSize / _gui.SampleRate * 1000);
                                if (s > t)
                                {
                                    Thread.Sleep(s - t);
                                }

                                if (rewind)
                                {
                                    rewind     = false;
                                    bufferSize = maxBufferSize;
                                    strm.Seek(headerSize, SeekOrigin.Begin); // Skip header

                                    if (PowerSpectrumPanel.PowerSpectrum != null)
                                    {
                                        PowerSpectrumPanel.PowerSpectrum.ResetTime();
                                    }
                                }
                            }
                            _isRunning.Set();
                        }
                }
            });
        }
Пример #30
0
        public void Start(SDRSharp.Radio.SamplesAvailableDelegate callback)
        {
            _callback = callback;
            _hostName = _gui.Host;
            _port = _gui.Port;
            _is16Bit = _gui.Use16Bit;

            _lostPacketsCount = 0;
            _circularBufferHead = 0;
            _circularBufferTail = 0;
            _sampleCount = 0;

            _sampleBuffer = UnsafeBuffer.Create(256 * 2, sizeof(Complex));
            _sampleBufferPtr = (Complex*)_sampleBuffer;
            _workingSamplePtr = _sampleBufferPtr;

            _client = new SdrIpClient();
            _client.Connect(_hostName, _port);
            _client.Samplerate = _sampleRate;
            _client.Frequency = _frequency;
            _client.Use16Bit = _is16Bit;

            _udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _udpSocket.ReceiveBufferSize = 65535;
            var remoteIpEndPoint = new IPEndPoint(IPAddress.Any, _port);
            _udpSocket.Bind(remoteIpEndPoint);
            _udpThread = new Thread(UdpReceiverThread);
            _udpThread.Priority = ThreadPriority.Highest;
            _udpThreadRunning = true;
            _udpThread.Start();

            _workerThread = new Thread(WorkerThread);
            _workerThreadRunning = true;
            _workerThread.Start();

            _client.StartStreaming();
            _tuneTimer.Start();

            Utils.SaveSetting("SDRIPHost", _hostName);
            Utils.SaveSetting("SDRIPPort", _port);
            Utils.SaveSetting("SDRIPRateIndex", _gui.SamepleRateIndex);
            Utils.SaveSetting("SDRIPFormatIndex", _gui.SampleFormatIndex);
        }
Пример #31
0
        public void Start(SamplesAvailableDelegate callback)
        {
            int v4l2_r;

            Console.WriteLine("Start");
            Samplerate = _sampleRate;             // set sampling rate

            NativeMethods.v4l2_requestbuffers req = new NativeMethods.v4l2_requestbuffers();
            req.count  = 10;            // nbuffers to driver
            req.type   = V4L2_BUF_TYPE_SDR_CAPTURE;
            req.memory = V4L2_MEMORY_MMAP;
            //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req);
            v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req);
            Console.WriteLine("CMD64_VIDIOC_REQBUFS v4l2_ioctl r = {0} req.count = {1}", v4l2_r, req.count);


            // v4l2_mmap buffers
            mmap_start  = new IntPtr [req.count];
            mmap_length = new UInt32 [req.count];
//			mmap = new Mmap [req.count];

            for (n_buffers = 0; n_buffers < req.count; n_buffers++)
            {
                buf.type   = V4L2_BUF_TYPE_SDR_CAPTURE;
                buf.memory = V4L2_MEMORY_MMAP;
                buf.index  = n_buffers;

                //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf);
                v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf);

//				mmap[n_buffers].length = buf.length;
//				mmap[n_buffers].start = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset);
                mmap_length[n_buffers] = buf.length;
                //mmap_start[n_buffers] = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset);
                mmap_start[n_buffers] = NativeMethods.mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset);
                Console.WriteLine("CMD64_VIDIOC_QUERYBUF v4l2_ioctl r = {0} mmap_start[n_buffers] = {1}", v4l2_r, mmap_start[n_buffers]);
            }

            //Exchange a buffer with the driver
            for (uint i = 0; i < n_buffers; i++)
            {
                //CLEAR(buf);
                buf.type   = V4L2_BUF_TYPE_SDR_CAPTURE;
                buf.memory = V4L2_MEMORY_MMAP;
                buf.index  = i;
                //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf);
                v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf);
                Console.WriteLine("CMD64_VIDIOC_QBUF v4l2_ioctl r = {0} buf.index = {1}", v4l2_r, buf.index);
            }

            // start streaming
            int  type = V4L2_BUF_TYPE_SDR_CAPTURE;
            int *ptr  = &type;

            //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr);
            v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr);
            Console.WriteLine("CMD64_VIDIOC_STREAMON v4l2_ioctl r = {0}", v4l2_r);

            _callback = callback;

            // set device parameters here

            streaming = true;

            _sampleThread = new Thread(ReceiveData);
            _sampleThread.Start();
        }
Пример #32
0
 public void Start(SamplesAvailableDelegate callback)
 {
 }
Пример #33
0
        public void Start(SamplesAvailableDelegate callback)
        {
            int v4l2_r;
            Console.WriteLine("Start");
            Samplerate = _sampleRate; // set sampling rate

            NativeMethods.v4l2_requestbuffers req = new NativeMethods.v4l2_requestbuffers();
            req.count = 10; // nbuffers to driver
            req.type = V4L2_BUF_TYPE_SDR_CAPTURE;
            req.memory = V4L2_MEMORY_MMAP;
            //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req);
            v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_REQBUFS, ref req);
            Console.WriteLine("CMD64_VIDIOC_REQBUFS v4l2_ioctl r = {0} req.count = {1}", v4l2_r, req.count);

            // v4l2_mmap buffers
            mmap_start = new IntPtr [req.count];
            mmap_length = new UInt32 [req.count];
            //			mmap = new Mmap [req.count];

            for (n_buffers = 0; n_buffers < req.count; n_buffers++) {
                buf.type = V4L2_BUF_TYPE_SDR_CAPTURE;
                buf.memory = V4L2_MEMORY_MMAP;
                buf.index = n_buffers;

                //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf);
                v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QUERYBUF, ref buf);

            //				mmap[n_buffers].length = buf.length;
            //				mmap[n_buffers].start = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset);
                mmap_length[n_buffers] = buf.length;
                //mmap_start[n_buffers] = NativeMethods.v4l2_mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset);
                mmap_start[n_buffers] = NativeMethods.mmap(IntPtr.Zero, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset);
                Console.WriteLine("CMD64_VIDIOC_QUERYBUF v4l2_ioctl r = {0} mmap_start[n_buffers] = {1}", v4l2_r, mmap_start[n_buffers]);
            }

            //Exchange a buffer with the driver
            for (uint i = 0; i < n_buffers; i++) {
                //CLEAR(buf);
                buf.type = V4L2_BUF_TYPE_SDR_CAPTURE;
                buf.memory = V4L2_MEMORY_MMAP;
                buf.index = i;
                //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf);
                v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_QBUF, ref buf);
                Console.WriteLine("CMD64_VIDIOC_QBUF v4l2_ioctl r = {0} buf.index = {1}", v4l2_r, buf.index);
            }

            // start streaming
            int type = V4L2_BUF_TYPE_SDR_CAPTURE;
            int *ptr = & type;
            //v4l2_r = NativeMethods.v4l2_ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr);
            v4l2_r = NativeMethods.ioctl(_fd, CMD64_VIDIOC_STREAMON, (IntPtr)ptr);
            Console.WriteLine("CMD64_VIDIOC_STREAMON v4l2_ioctl r = {0}", v4l2_r);

            _callback = callback;

            // set device parameters here

            streaming = true;

            _sampleThread = new Thread(ReceiveData);
            _sampleThread.Start();
        }