1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

PlutoSDR device handling: fixed Tx channels

This commit is contained in:
f4exb 2017-10-29 03:01:44 +01:00
parent 3e05abb52d
commit 4536680adf
2 changed files with 48 additions and 12 deletions

View File

@ -34,7 +34,8 @@ DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
m_devRx(0),
m_devTx(0),
m_chnRx0(0),
m_chnTx0(0),
m_chnTx0i(0),
m_chnTx0q(0),
m_rxBuf(0),
m_txBuf(0),
m_xoInitial(0)
@ -273,14 +274,35 @@ bool DevicePlutoSDRBox::openTx()
{
if (!m_valid) { return false; }
if (!m_chnTx0) {
m_chnTx0 = iio_device_find_channel(m_devTx, "voltage0", true);
if (!m_chnTx0i) {
m_chnTx0i = iio_device_find_channel(m_devTx, "voltage0", true);
}
if (m_chnTx0) {
iio_channel_enable(m_chnTx0);
const struct iio_data_format *df = iio_channel_get_data_format(m_chnTx0);
qDebug("DevicePlutoSDRBox::openTx: length: %u bits: %u shift: %u signed: %s be: %s with_scale: %s scale: %lf repeat: %u",
if (m_chnTx0i) {
iio_channel_enable(m_chnTx0i);
const struct iio_data_format *df = iio_channel_get_data_format(m_chnTx0i);
qDebug("DevicePlutoSDRBox::openTx: channel I: length: %u bits: %u shift: %u signed: %s be: %s with_scale: %s scale: %lf repeat: %u",
df->length,
df->bits,
df->shift,
df->is_signed ? "true" : "false",
df->is_be ? "true" : "false",
df->with_scale? "true" : "false",
df->scale,
df->repeat);
} else {
std::cerr << "DevicePlutoSDRBox::openTx: failed to open I channel" << std::endl;
return false;
}
if (!m_chnTx0q) {
m_chnTx0q = iio_device_find_channel(m_devTx, "voltage1", true);
}
if (m_chnTx0q) {
iio_channel_enable(m_chnTx0q);
const struct iio_data_format *df = iio_channel_get_data_format(m_chnTx0q);
qDebug("DevicePlutoSDRBox::openTx: channel Q: length: %u bits: %u shift: %u signed: %s be: %s with_scale: %s scale: %lf repeat: %u",
df->length,
df->bits,
df->shift,
@ -291,7 +313,7 @@ bool DevicePlutoSDRBox::openTx()
df->repeat);
return true;
} else {
std::cerr << "DevicePlutoSDRBox::openTx: failed" << std::endl;
std::cerr << "DevicePlutoSDRBox::openTx: failed to open Q channel" << std::endl;
return false;
}
}
@ -303,7 +325,8 @@ void DevicePlutoSDRBox::closeRx()
void DevicePlutoSDRBox::closeTx()
{
if (m_chnTx0) { iio_channel_disable(m_chnTx0); }
if (m_chnTx0i) { iio_channel_disable(m_chnTx0i); }
if (m_chnTx0q) { iio_channel_disable(m_chnTx0q); }
}
struct iio_buffer *DevicePlutoSDRBox::createRxBuffer(unsigned int size, bool cyclic)
@ -428,12 +451,22 @@ char* DevicePlutoSDRBox::txBufferEnd()
char* DevicePlutoSDRBox::txBufferFirst()
{
if (m_txBuf) {
return (char *) iio_buffer_first(m_txBuf, m_chnTx0);
return (char *) iio_buffer_first(m_txBuf, m_chnTx0i);
} else {
return 0;
}
}
void DevicePlutoSDRBox::txChannelConvert(int16_t *dst, int16_t *src)
{
if (m_chnTx0i) {
iio_channel_convert_inverse(m_chnTx0i, &dst[0], &src[0]);
}
if (m_chnTx0q) {
iio_channel_convert_inverse(m_chnTx0q, &dst[1], &src[1]);
}
}
bool DevicePlutoSDRBox::getRxSampleRates(SampleRates& sampleRates)
{
std::string srStr;

View File

@ -78,7 +78,8 @@ public:
ssize_t getRxSampleSize();
ssize_t getTxSampleSize();
struct iio_channel *getRxChannel0() { return m_chnRx0; }
struct iio_channel *getTxChannel0() { return m_chnTx0; }
struct iio_channel *getTxChannel0I() { return m_chnTx0i; }
struct iio_channel *getTxChannel0Q() { return m_chnTx0q; }
ssize_t rxBufferRefill();
ssize_t txBufferPush();
std::ptrdiff_t rxBufferStep();
@ -87,6 +88,7 @@ public:
std::ptrdiff_t txBufferStep();
char* txBufferEnd();
char* txBufferFirst();
void txChannelConvert(int16_t *dst, int16_t *src);
bool getRxSampleRates(SampleRates& sampleRates);
bool getTxSampleRates(SampleRates& sampleRates);
void setSampleRate(uint32_t sampleRate);
@ -106,7 +108,8 @@ private:
struct iio_device *m_devRx;
struct iio_device *m_devTx;
struct iio_channel *m_chnRx0;
struct iio_channel *m_chnTx0;
struct iio_channel *m_chnTx0i;
struct iio_channel *m_chnTx0q;
struct iio_buffer *m_rxBuf;
struct iio_buffer *m_txBuf;
bool m_valid;