mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-07-21 10:15:34 -04:00
PlutoSDR device handling: fixed Tx channels
This commit is contained in:
parent
3e05abb52d
commit
4536680adf
@ -34,7 +34,8 @@ DevicePlutoSDRBox::DevicePlutoSDRBox(const std::string& uri) :
|
|||||||
m_devRx(0),
|
m_devRx(0),
|
||||||
m_devTx(0),
|
m_devTx(0),
|
||||||
m_chnRx0(0),
|
m_chnRx0(0),
|
||||||
m_chnTx0(0),
|
m_chnTx0i(0),
|
||||||
|
m_chnTx0q(0),
|
||||||
m_rxBuf(0),
|
m_rxBuf(0),
|
||||||
m_txBuf(0),
|
m_txBuf(0),
|
||||||
m_xoInitial(0)
|
m_xoInitial(0)
|
||||||
@ -273,14 +274,35 @@ bool DevicePlutoSDRBox::openTx()
|
|||||||
{
|
{
|
||||||
if (!m_valid) { return false; }
|
if (!m_valid) { return false; }
|
||||||
|
|
||||||
if (!m_chnTx0) {
|
if (!m_chnTx0i) {
|
||||||
m_chnTx0 = iio_device_find_channel(m_devTx, "voltage0", true);
|
m_chnTx0i = iio_device_find_channel(m_devTx, "voltage0", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_chnTx0) {
|
if (m_chnTx0i) {
|
||||||
iio_channel_enable(m_chnTx0);
|
iio_channel_enable(m_chnTx0i);
|
||||||
const struct iio_data_format *df = iio_channel_get_data_format(m_chnTx0);
|
const struct iio_data_format *df = iio_channel_get_data_format(m_chnTx0i);
|
||||||
qDebug("DevicePlutoSDRBox::openTx: length: %u bits: %u shift: %u signed: %s be: %s with_scale: %s scale: %lf repeat: %u",
|
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->length,
|
||||||
df->bits,
|
df->bits,
|
||||||
df->shift,
|
df->shift,
|
||||||
@ -291,7 +313,7 @@ bool DevicePlutoSDRBox::openTx()
|
|||||||
df->repeat);
|
df->repeat);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "DevicePlutoSDRBox::openTx: failed" << std::endl;
|
std::cerr << "DevicePlutoSDRBox::openTx: failed to open Q channel" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +325,8 @@ void DevicePlutoSDRBox::closeRx()
|
|||||||
|
|
||||||
void DevicePlutoSDRBox::closeTx()
|
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)
|
struct iio_buffer *DevicePlutoSDRBox::createRxBuffer(unsigned int size, bool cyclic)
|
||||||
@ -428,12 +451,22 @@ char* DevicePlutoSDRBox::txBufferEnd()
|
|||||||
char* DevicePlutoSDRBox::txBufferFirst()
|
char* DevicePlutoSDRBox::txBufferFirst()
|
||||||
{
|
{
|
||||||
if (m_txBuf) {
|
if (m_txBuf) {
|
||||||
return (char *) iio_buffer_first(m_txBuf, m_chnTx0);
|
return (char *) iio_buffer_first(m_txBuf, m_chnTx0i);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
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)
|
bool DevicePlutoSDRBox::getRxSampleRates(SampleRates& sampleRates)
|
||||||
{
|
{
|
||||||
std::string srStr;
|
std::string srStr;
|
||||||
|
@ -78,7 +78,8 @@ public:
|
|||||||
ssize_t getRxSampleSize();
|
ssize_t getRxSampleSize();
|
||||||
ssize_t getTxSampleSize();
|
ssize_t getTxSampleSize();
|
||||||
struct iio_channel *getRxChannel0() { return m_chnRx0; }
|
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 rxBufferRefill();
|
||||||
ssize_t txBufferPush();
|
ssize_t txBufferPush();
|
||||||
std::ptrdiff_t rxBufferStep();
|
std::ptrdiff_t rxBufferStep();
|
||||||
@ -87,6 +88,7 @@ public:
|
|||||||
std::ptrdiff_t txBufferStep();
|
std::ptrdiff_t txBufferStep();
|
||||||
char* txBufferEnd();
|
char* txBufferEnd();
|
||||||
char* txBufferFirst();
|
char* txBufferFirst();
|
||||||
|
void txChannelConvert(int16_t *dst, int16_t *src);
|
||||||
bool getRxSampleRates(SampleRates& sampleRates);
|
bool getRxSampleRates(SampleRates& sampleRates);
|
||||||
bool getTxSampleRates(SampleRates& sampleRates);
|
bool getTxSampleRates(SampleRates& sampleRates);
|
||||||
void setSampleRate(uint32_t sampleRate);
|
void setSampleRate(uint32_t sampleRate);
|
||||||
@ -106,7 +108,8 @@ private:
|
|||||||
struct iio_device *m_devRx;
|
struct iio_device *m_devRx;
|
||||||
struct iio_device *m_devTx;
|
struct iio_device *m_devTx;
|
||||||
struct iio_channel *m_chnRx0;
|
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_rxBuf;
|
||||||
struct iio_buffer *m_txBuf;
|
struct iio_buffer *m_txBuf;
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user