From 0fc6d953570f113920fa03015e23a488be869605 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 25 Oct 2016 03:31:36 +0200 Subject: [PATCH] Tx ph.1: fixed read pointer management when getting new samples --- Readme.md | 10 ++++++++++ plugins/samplesink/filesink/filesinkthread.cpp | 12 ++++-------- plugins/samplesink/filesink/filesinkthread.h | 1 - sdrbase/dsp/samplesourcefifo.cpp | 6 ++---- sdrbase/dsp/samplesourcefifo.h | 6 +++--- sdrbase/readme.md | 9 +++++---- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Readme.md b/Readme.md index ba305f8c9..f468dfead 100644 --- a/Readme.md +++ b/Readme.md @@ -27,6 +27,16 @@ These plugins come from the parent code base and have been maintained so that th From version 2 SDRangel can integrate more than one hardware device running concurrently. +

Transmission support

+ +Transmission or signal generation support for eligible devices (BladeRF and HackRF) will be progressively introduced with the following roadmap: + + - Phase 1: version 2.2.0: generation to file (File Sink) with AM modulator with simple sine modulation. Fixed sample rate of 48 kS/s (no interpolation) + - Phase 2: version 2.2.x: full baseband interpolation chain: in AM modulator and Up Channelizer. + - Phase 3: version 2.3.0: FM and SSB modulators with audio file input + - Phase 4: version 2.3.x: Audio (Mic) input support + - phase 5: version 3.0.0: BladeRF and HackRF support including final interpolation stage. +

Airspy

Airspy is supported through the libairspy library that should be installed in your system for proper build of the software and operation support. Add `libairspy-dev` to the list of dependencies to install. diff --git a/plugins/samplesink/filesink/filesinkthread.cpp b/plugins/samplesink/filesink/filesinkthread.cpp index 983349f9d..87c04f781 100644 --- a/plugins/samplesink/filesink/filesinkthread.cpp +++ b/plugins/samplesink/filesink/filesinkthread.cpp @@ -26,7 +26,6 @@ FileSinkThread::FileSinkThread(std::ofstream *samplesStream, SampleSourceFifo* s QThread(parent), m_running(false), m_ofstream(samplesStream), - m_buf(0), m_bufsize(0), m_samplesChunkSize(0), m_sampleFifo(sampleFifo), @@ -43,10 +42,6 @@ FileSinkThread::~FileSinkThread() if (m_running) { stopWork(); } - - if (m_buf != 0) { - free(m_buf); - } } void FileSinkThread::startWork() @@ -132,10 +127,11 @@ void FileSinkThread::tick() m_throttleToggle = !m_throttleToggle; } - SampleVector::iterator beginRead; + SampleVector::iterator readUntil; - m_sampleFifo->readAndSignal(beginRead, m_samplesChunkSize); - m_ofstream->write(reinterpret_cast(&(*beginRead)), m_samplesChunkSize*4); + m_sampleFifo->readAdvance(readUntil, m_samplesChunkSize); + SampleVector::iterator beginRead = readUntil - m_samplesChunkSize; + m_ofstream->write(reinterpret_cast(&(*beginRead)), m_samplesChunkSize*sizeof(Sample)); m_samplesCount += m_samplesChunkSize; } } diff --git a/plugins/samplesink/filesink/filesinkthread.h b/plugins/samplesink/filesink/filesinkthread.h index 2ca252534..a6c186a41 100644 --- a/plugins/samplesink/filesink/filesinkthread.h +++ b/plugins/samplesink/filesink/filesinkthread.h @@ -55,7 +55,6 @@ private: bool m_running; std::ofstream* m_ofstream; - quint8 *m_buf; std::size_t m_bufsize; unsigned int m_samplesChunkSize; SampleSourceFifo* m_sampleFifo; diff --git a/sdrbase/dsp/samplesourcefifo.cpp b/sdrbase/dsp/samplesourcefifo.cpp index d35b3e461..569f48977 100644 --- a/sdrbase/dsp/samplesourcefifo.cpp +++ b/sdrbase/dsp/samplesourcefifo.cpp @@ -50,15 +50,13 @@ void SampleSourceFifo::init() m_init = true; } -void SampleSourceFifo::readAndSignal(SampleVector::iterator& beginRead, unsigned int nbSamples) +void SampleSourceFifo::readAdvance(SampleVector::iterator& readUntil, unsigned int nbSamples) { QMutexLocker mutexLocker(&m_mutex); - assert(nbSamples < m_samplesChunkSize/2); - beginRead = m_data.begin() + m_size + m_ir; m_ir = (m_ir + nbSamples) % m_size; - + readUntil = m_data.begin() + m_size + m_ir; emit dataRead(nbSamples); int i_delta = m_iw - m_ir; diff --git a/sdrbase/dsp/samplesourcefifo.h b/sdrbase/dsp/samplesourcefifo.h index 517b05f81..83ed4ee9f 100644 --- a/sdrbase/dsp/samplesourcefifo.h +++ b/sdrbase/dsp/samplesourcefifo.h @@ -35,10 +35,10 @@ public: void resize(uint32_t size, uint32_t samplesChunkSize); void init(); - /** begin read at current read point for the given length and activate R/W signals */ - void readAndSignal(SampleVector::iterator& beginRead, unsigned int nbSamples); + /** advance read pointer for the given length and activate R/W signals */ + void readAdvance(SampleVector::iterator& readUntil, unsigned int nbSamples); - void getReadIterator(SampleVector::iterator& readUntil); //!< get iterator past the last sample that was read by a read with signal (i.e. current read iterator) + void getReadIterator(SampleVector::iterator& readUntil); //!< get iterator past the last sample of a read advance operation (i.e. current read iterator) void getWriteIterator(SampleVector::iterator& writeAt); //!< get iterator to current item for update - write phase 1 void bumpIndex(SampleVector::iterator& writeAt); //!< copy current item to second buffer and bump write index - write phase 2 diff --git a/sdrbase/readme.md b/sdrbase/readme.md index 6ad74705b..76f2d79da 100644 --- a/sdrbase/readme.md +++ b/sdrbase/readme.md @@ -4,7 +4,7 @@ Starting with version 2 SDRangel supports several sampling devices simultaneously. Each concurrent device is associated to a slot with a set of tabbed windows in the UI. These tabs are marked R0, R1, R2... -The slots are arranged in a stacked fashion so that when a new device is added with the Acquisition -> Add device menu a new slot is allocated in the last position and when a devcie is removed with the Acquisition -> Remove device menu the slot in the last position is deleted. Slot 0 (R0) is created at initialization and cannot be deleted with the menu. +The slots are arranged in a stacked fashion so that when a new device is added with the Acquisition -> Add device menu a new slot is allocated in the last position and when a devcie is removed with the Acquisition -> Remove device menu the slot in the last position is deleted. Slot 0 (R0) receiver slot is created at initialization and cannot be deleted with the menu. The letter "R" in the tab names indicates that the slot is for a receiver (source) device while "T" designates a tramsmitter (sink) device. The tabbed windows are: @@ -32,9 +32,10 @@ The following items are presented hierarchically from left to right: - Exit (shortcut Ctl-Q): Exit the program - View: - Fullscreen (Shortcut F11): Toggle full screen mode - - Acquisition: - - Add device: adds a new sampling device slot to the device stack (last position) - - Remove device: removes the last sampling device slot from thte device stack + - Devices: + - Add source device: adds a new source (receiver) device slot to the device stack (last position) + - Add sink device: adds a new sink (transmitter) device slot to the device stack (last position) + - Remove device: removes the last device slot from thte device stack - Window: presents the list of dockable windows. Check to make it visible. Uncheck to hide. These windows are: - Sampling devices control: control of which sampling devices is used and add channels - Sampling devices: the sampling devices UIs