[hamradio-commits] [soapyrtlsdr] 01/08: New upstream version 0.2.4
Andreas E. Bombe
aeb at moszumanska.debian.org
Sun Aug 6 22:44:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
aeb pushed a commit to branch master
in repository soapyrtlsdr.
commit 93ac14b1fae904638a7cdd92ef0e69fb082226d4
Author: Andreas Bombe <aeb at debian.org>
Date: Tue Jun 27 03:13:36 2017 +0200
New upstream version 0.2.4
---
Changelog.txt | 15 ++++
README.md | 6 +-
Settings.cpp | 17 +++++
SoapyRTLSDR.hpp | 18 +++--
Streaming.cpp | 86 +++++++++++++++-------
debian/changelog | 12 +++
debian/control | 4 +-
...r.install => soapysdr0.6-module-rtlsdr.install} | 0
8 files changed, 122 insertions(+), 36 deletions(-)
diff --git a/Changelog.txt b/Changelog.txt
index 4daf2de..c1bf264 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,18 @@
+Release 0.2.4 (2017-06-15)
+==========================
+
+- readStream - also drop remainder buffer on reset
+- Fixed configuration input for num async buffers
+
+Release 0.2.3 (2017-04-29)
+==========================
+
+- Added support for frequency correction API
+- Separate buffer count for ring buffer and usb
+- Larger buffer size - same as rtl defaults
+- Use atomics for ring buffer implementation
+- Use Format string constants for stream types
+
Release 0.2.2 (2016-09-01)
==========================
diff --git a/README.md b/README.md
index 8bcdd8f..0df1a85 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,15 @@
# Soapy SDR module for RTL-SDR
-##Build Status
+## Build Status
- Travis: [](https://travis-ci.org/pothosware/SoapyRTLSDR)
-##Dependencies
+## Dependencies
* SoapySDR - https://github.com/pothosware/SoapySDR/wiki
* librtl-sdr - http://sdr.osmocom.org/trac/wiki/rtl-sdr
-##Documentation
+## Documentation
* https://github.com/pothosware/SoapyRTLSDR/wiki
diff --git a/Settings.cpp b/Settings.cpp
index ccef7be..442eb2b 100644
--- a/Settings.cpp
+++ b/Settings.cpp
@@ -2,6 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2015 Charles J. Cliffe
+ * Copyright (c) 2015-2017 Josh Blum
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -197,6 +198,22 @@ bool SoapyRTLSDR::hasDCOffsetMode(const int direction, const size_t channel) con
return false;
}
+bool SoapyRTLSDR::hasFrequencyCorrection(const int direction, const size_t channel) const
+{
+ return true;
+}
+
+void SoapyRTLSDR::setFrequencyCorrection(const int direction, const size_t channel, const double value)
+{
+ ppm = int(value);
+ rtlsdr_set_freq_correction(dev, ppm);
+}
+
+double SoapyRTLSDR::getFrequencyCorrection(const int direction, const size_t channel) const
+{
+ return double(ppm);
+}
+
/*******************************************************************
* Gain API
******************************************************************/
diff --git a/SoapyRTLSDR.hpp b/SoapyRTLSDR.hpp
index 47164df..e89218e 100644
--- a/SoapyRTLSDR.hpp
+++ b/SoapyRTLSDR.hpp
@@ -2,6 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2015 Charles J. Cliffe
+ * Copyright (c) 2015-2017 Josh Blum
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -31,13 +32,14 @@
#include <thread>
#include <mutex>
#include <condition_variable>
+#include <atomic>
typedef enum rtlsdrRXFormat
{
RTL_RX_FORMAT_FLOAT32, RTL_RX_FORMAT_INT16, RTL_RX_FORMAT_INT8
} rtlsdrRXFormat;
-#define DEFAULT_BUFFER_LENGTH 16384
+#define DEFAULT_BUFFER_LENGTH (16 * 32 * 512)
#define DEFAULT_NUM_BUFFERS 15
#define BYTES_PER_SAMPLE 2
@@ -133,6 +135,12 @@ public:
bool hasDCOffsetMode(const int direction, const size_t channel) const;
+ bool hasFrequencyCorrection(const int direction, const size_t channel) const;
+
+ void setFrequencyCorrection(const int direction, const size_t channel, const double value);
+
+ double getFrequencyCorrection(const int direction, const size_t channel) const;
+
/*******************************************************************
* Gain API
******************************************************************/
@@ -218,7 +226,7 @@ private:
rtlsdr_tuner tunerType;
uint32_t sampleRate, centerFrequency;
int ppm, directSamplingMode;
- size_t numBuffers, bufferLength;
+ size_t numBuffers, bufferLength, asyncBuffs;
bool iqSwap, agcMode, offsetMode;
double IFGain[6], tunerGain;
@@ -239,12 +247,12 @@ public:
std::vector<std::vector<signed char> > _buffs;
size_t _buf_head;
size_t _buf_tail;
- size_t _buf_count;
+ std::atomic<size_t> _buf_count;
signed char *_currentBuff;
- bool _overflowEvent;
+ std::atomic<bool> _overflowEvent;
size_t _currentHandle;
size_t bufferedElems;
- bool resetBuffer;
+ std::atomic<bool> resetBuffer;
static int rtl_count;
static std::vector<SoapySDR::Kwargs> rtl_devices;
diff --git a/Streaming.cpp b/Streaming.cpp
index 134a218..43d61c9 100644
--- a/Streaming.cpp
+++ b/Streaming.cpp
@@ -2,6 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2015 Charles J. Cliffe
+ * Copyright (c) 2015-2017 Josh Blum
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +25,7 @@
#include "SoapyRTLSDR.hpp"
#include <SoapySDR/Logger.hpp>
+#include <SoapySDR/Formats.hpp>
#include <algorithm> //min
#include <climits> //SHRT_MAX
#include <cstring> // memcpy
@@ -32,9 +34,9 @@
std::vector<std::string> SoapyRTLSDR::getStreamFormats(const int direction, const size_t channel) const {
std::vector<std::string> formats;
- formats.push_back("CS8");
- formats.push_back("CS16");
- formats.push_back("CF32");
+ formats.push_back(SOAPY_SDR_CS8);
+ formats.push_back(SOAPY_SDR_CS16);
+ formats.push_back(SOAPY_SDR_CF32);
return formats;
}
@@ -46,7 +48,7 @@ std::string SoapyRTLSDR::getNativeStreamFormat(const int direction, const size_t
}
fullScale = 128;
- return "CS8";
+ return SOAPY_SDR_CS8;
}
SoapySDR::ArgInfoList SoapyRTLSDR::getStreamArgsInfo(const int direction, const size_t channel) const {
@@ -59,7 +61,7 @@ SoapySDR::ArgInfoList SoapyRTLSDR::getStreamArgsInfo(const int direction, const
SoapySDR::ArgInfo bufflenArg;
bufflenArg.key = "bufflen";
- bufflenArg.value = "16384";
+ bufflenArg.value = std::to_string(DEFAULT_BUFFER_LENGTH);
bufflenArg.name = "Buffer Size";
bufflenArg.description = "Number of bytes per buffer, multiples of 512 only.";
bufflenArg.units = "bytes";
@@ -69,14 +71,24 @@ SoapySDR::ArgInfoList SoapyRTLSDR::getStreamArgsInfo(const int direction, const
SoapySDR::ArgInfo buffersArg;
buffersArg.key = "buffers";
- buffersArg.value = "15";
- buffersArg.name = "Buffer Count";
- buffersArg.description = "Number of buffers per read.";
+ buffersArg.value = std::to_string(DEFAULT_NUM_BUFFERS);
+ buffersArg.name = "Ring buffers";
+ buffersArg.description = "Number of buffers in the ring.";
buffersArg.units = "buffers";
buffersArg.type = SoapySDR::ArgInfo::INT;
streamArgs.push_back(buffersArg);
+ SoapySDR::ArgInfo asyncbuffsArg;
+ asyncbuffsArg.key = "asyncBuffs";
+ asyncbuffsArg.value = "0";
+ asyncbuffsArg.name = "Async buffers";
+ asyncbuffsArg.description = "Number of async usb buffers (advanced).";
+ asyncbuffsArg.units = "buffers";
+ asyncbuffsArg.type = SoapySDR::ArgInfo::INT;
+
+ streamArgs.push_back(asyncbuffsArg);
+
return streamArgs;
}
@@ -94,14 +106,12 @@ static void _rx_callback(unsigned char *buf, uint32_t len, void *ctx)
void SoapyRTLSDR::rx_async_operation(void)
{
//printf("rx_async_operation\n");
- rtlsdr_read_async(dev, &_rx_callback, this, numBuffers, bufferLength);
+ rtlsdr_read_async(dev, &_rx_callback, this, asyncBuffs, bufferLength);
//printf("rx_async_operation done!\n");
}
void SoapyRTLSDR::rx_callback(unsigned char *buf, uint32_t len)
{
- std::unique_lock<std::mutex> lock(_buf_mutex);
-
//printf("_rx_callback %d _buf_head=%d, numBuffers=%d\n", len, _buf_head, _buf_tail);
//overflow condition: the caller is not reading fast enough
@@ -118,8 +128,15 @@ void SoapyRTLSDR::rx_callback(unsigned char *buf, uint32_t len)
//increment the tail pointer
_buf_tail = (_buf_tail + 1) % numBuffers;
+
+ //increment buffers available under lock
+ //to avoid race in acquireReadBuffer wait
+ {
+ std::lock_guard<std::mutex> lock(_buf_mutex);
_buf_count++;
+ }
+
//notify readStream()
_buf_cond.notify_one();
}
@@ -146,17 +163,17 @@ SoapySDR::Stream *SoapyRTLSDR::setupStream(
}
//check the format
- if (format == "CF32")
+ if (format == SOAPY_SDR_CF32)
{
SoapySDR_log(SOAPY_SDR_INFO, "Using format CF32.");
rxFormat = RTL_RX_FORMAT_FLOAT32;
}
- else if (format == "CS16")
+ else if (format == SOAPY_SDR_CS16)
{
SoapySDR_log(SOAPY_SDR_INFO, "Using format CS16.");
rxFormat = RTL_RX_FORMAT_INT16;
}
- else if (format == "CS8") {
+ else if (format == SOAPY_SDR_CS8) {
SoapySDR_log(SOAPY_SDR_INFO, "Using format CS8.");
rxFormat = RTL_RX_FORMAT_INT8;
}
@@ -203,12 +220,12 @@ SoapySDR::Stream *SoapyRTLSDR::setupStream(
}
}
-
- if (args.count("buflen") != 0)
+ bufferLength = DEFAULT_BUFFER_LENGTH;
+ if (args.count("bufflen") != 0)
{
try
{
- int bufferLength_in = std::stoi(args.at("buflen"));
+ int bufferLength_in = std::stoi(args.at("bufflen"));
if (bufferLength_in > 0)
{
bufferLength = bufferLength_in;
@@ -218,6 +235,7 @@ SoapySDR::Stream *SoapyRTLSDR::setupStream(
}
SoapySDR_logf(SOAPY_SDR_DEBUG, "RTL-SDR Using buffer length %d", bufferLength);
+ numBuffers = DEFAULT_NUM_BUFFERS;
if (args.count("buffers") != 0)
{
try
@@ -232,6 +250,19 @@ SoapySDR::Stream *SoapyRTLSDR::setupStream(
}
SoapySDR_logf(SOAPY_SDR_DEBUG, "RTL-SDR Using %d buffers", numBuffers);
+ asyncBuffs = 0;
+ if (args.count("asyncBuffs") != 0)
+ {
+ try
+ {
+ int asyncBuffs_in = std::stoi(args.at("asyncBuffs"));
+ if (asyncBuffs_in > 0)
+ {
+ asyncBuffs = asyncBuffs_in;
+ }
+ }
+ catch (const std::invalid_argument &){}
+ }
if (tunerType == RTLSDR_TUNER_E4000) {
IFGain[0] = 6;
IFGain[1] = 9;
@@ -308,6 +339,13 @@ int SoapyRTLSDR::readStream(
long long &timeNs,
const long timeoutUs)
{
+ //drop remainder buffer on reset
+ if (resetBuffer and bufferedElems != 0)
+ {
+ bufferedElems = 0;
+ this->releaseReadBuffer(stream, _currentHandle);
+ }
+
//this is the user's buffer for channel 0
void *buff0 = buffs[0];
@@ -422,15 +460,12 @@ int SoapyRTLSDR::acquireReadBuffer(
long long &timeNs,
const long timeoutUs)
{
- std::unique_lock <std::mutex> lock(_buf_mutex);
-
//reset is issued by various settings
//to drain old data out of the queue
if (resetBuffer)
{
//drain all buffers from the fifo
- _buf_head = (_buf_head + _buf_count) % numBuffers;
- _buf_count = 0;
+ _buf_head = (_buf_head + _buf_count.exchange(0)) % numBuffers;
resetBuffer = false;
_overflowEvent = false;
}
@@ -439,17 +474,17 @@ int SoapyRTLSDR::acquireReadBuffer(
if (_overflowEvent)
{
//drain the old buffers from the fifo
- _buf_head = (_buf_head + _buf_count) % numBuffers;
- _buf_count = 0;
+ _buf_head = (_buf_head + _buf_count.exchange(0)) % numBuffers;
_overflowEvent = false;
SoapySDR::log(SOAPY_SDR_SSI, "O");
return SOAPY_SDR_OVERFLOW;
}
//wait for a buffer to become available
- while (_buf_count == 0)
+ if (_buf_count == 0)
{
- _buf_cond.wait_for(lock, std::chrono::microseconds(timeoutUs));
+ std::unique_lock <std::mutex> lock(_buf_mutex);
+ _buf_cond.wait_for(lock, std::chrono::microseconds(timeoutUs), [this]{return _buf_count != 0;});
if (_buf_count == 0) return SOAPY_SDR_TIMEOUT;
}
@@ -468,6 +503,5 @@ void SoapyRTLSDR::releaseReadBuffer(
const size_t handle)
{
//TODO this wont handle out of order releases
- std::unique_lock <std::mutex> lock(_buf_mutex);
_buf_count--;
}
diff --git a/debian/changelog b/debian/changelog
index 553e101..7357d0b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
+soapyrtlsdr (0.2.4-1) unstable; urgency=low
+
+ * Release 0.2.4 (2017-06-15)
+
+ -- Josh Blum <josh at pothosware.com> Thu, 15 Jun 2017 17:48:13 -0000
+
+soapyrtlsdr (0.2.3-1) unstable; urgency=low
+
+ * Release 0.2.3 (2017-04-29)
+
+ -- Josh Blum <josh at pothosware.com> Sat, 29 Apr 2017 15:04:19 -0000
+
soapyrtlsdr (0.2.2) unstable; urgency=low
* Release 0.2.2 (2016-09-01)
diff --git a/debian/control b/debian/control
index 37f5f68..042a1b0 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,7 @@ Homepage: https://github.com/pothosware/SoapyRTLSDR/wiki
Vcs-Git: https://github.com/pothosware/SoapyRTLSDR.git
Vcs-Browser: https://github.com/pothosware/SoapyRTLSDR
-Package: soapysdr0.5-2-module-rtlsdr
+Package: soapysdr0.6-module-rtlsdr
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
@@ -25,7 +25,7 @@ Description: RTL-SDR device support for SoapySDR
Package: soapysdr-module-rtlsdr
Architecture: all
-Depends: soapysdr0.5-2-module-rtlsdr, ${misc:Depends}
+Depends: soapysdr0.6-module-rtlsdr, ${misc:Depends}
Description: RTL-SDR device support for SoapySDR (default version)
The Soapy RTL-SDR project provides a SoapySDR hardware support module.
Using this, any program using SoapySDR to interface to software
diff --git a/debian/soapysdr0.5-2-module-rtlsdr.install b/debian/soapysdr0.6-module-rtlsdr.install
similarity index 100%
rename from debian/soapysdr0.5-2-module-rtlsdr.install
rename to debian/soapysdr0.6-module-rtlsdr.install
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/soapyrtlsdr.git
More information about the pkg-hamradio-commits
mailing list