mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
PlutoSDR support restored again fixing Rs and Tx living together
This commit is contained in:
parent
2c4a748ebe
commit
c7e7bf3480
@ -17,10 +17,10 @@ if(LIBUSB_FOUND AND LIMESUITE_FOUND)
|
||||
add_subdirectory(limesdroutput)
|
||||
endif(LIBUSB_FOUND AND LIMESUITE_FOUND)
|
||||
|
||||
#find_package(LibIIO)
|
||||
#if(LIBUSB_FOUND AND LIBIIO_FOUND)
|
||||
# add_subdirectory(plutosdroutput)
|
||||
#endif(LIBUSB_FOUND AND LIBIIO_FOUND)
|
||||
find_package(LibIIO)
|
||||
if(LIBUSB_FOUND AND LIBIIO_FOUND)
|
||||
add_subdirectory(plutosdroutput)
|
||||
endif(LIBUSB_FOUND AND LIBIIO_FOUND)
|
||||
|
||||
find_package(CM256cc)
|
||||
find_package(LibNANOMSG)
|
||||
@ -35,7 +35,7 @@ if (BUILD_DEBIAN)
|
||||
if (LIBNANOMSG_FOUND)
|
||||
add_subdirectory(sdrdaemonsink)
|
||||
endif (LIBNANOMSG_FOUND)
|
||||
# add_subdirectory(plutosdroutput)
|
||||
add_subdirectory(plutosdroutput)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
add_subdirectory(filesink)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "plutosdroutput.h"
|
||||
#include "plutosdroutputthread.h"
|
||||
|
||||
#define PLUTOSDR_BLOCKSIZE_SAMPLES (32*1024) //complex samples per buffer (must be multiple of 64)
|
||||
#define PLUTOSDR_BLOCKSIZE_SAMPLES (16*1024) //complex samples per buffer (must be multiple of 64)
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(PlutoSDROutput::MsgConfigurePlutoSDR, Message)
|
||||
|
||||
@ -185,9 +185,11 @@ bool PlutoSDROutput::openDevice()
|
||||
m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
|
||||
|
||||
// acquire the channel
|
||||
suspendBuddies();
|
||||
DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox();
|
||||
plutoBox->openTx();
|
||||
m_plutoTxBuffer = plutoBox->createTxBuffer(PLUTOSDR_BLOCKSIZE_SAMPLES, false); // PlutoSDR buffer size is counted in number of (I,Q) samples
|
||||
resumeBuddies();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -65,6 +65,13 @@ void PlutoSDROutputThread::setLog2Interpolation(unsigned int log2_interp)
|
||||
|
||||
void PlutoSDROutputThread::run()
|
||||
{
|
||||
std::ptrdiff_t p_inc = m_plutoBox->txBufferStep();
|
||||
|
||||
qDebug("PlutoSDROutputThread::run: txBufferStep: %ld bytes", p_inc);
|
||||
qDebug("PlutoSDROutputThread::run: Rx sample size is %ld bytes", m_plutoBox->getRxSampleSize());
|
||||
qDebug("PlutoSDROutputThread::run: Tx sample size is %ld bytes", m_plutoBox->getTxSampleSize());
|
||||
qDebug("PlutoSDROutputThread::run: nominal nbytes_tx is %d bytes", m_blockSizeSamples*4);
|
||||
|
||||
m_running = true;
|
||||
m_startWaiter.wakeAll();
|
||||
|
||||
@ -72,13 +79,11 @@ void PlutoSDROutputThread::run()
|
||||
{
|
||||
ssize_t nbytes_tx;
|
||||
char *p_dat, *p_end;
|
||||
std::ptrdiff_t p_inc;
|
||||
int ihs; // half sample index (I then Q to make a sample)
|
||||
|
||||
convert(m_buf, 2*m_blockSizeSamples); // size given in number of int16_t (I and Q interleaved)
|
||||
|
||||
// WRITE: Get pointers to TX buf and write IQ to TX buf port 0
|
||||
p_inc = m_plutoBox->txBufferStep();
|
||||
p_end = m_plutoBox->txBufferEnd();
|
||||
ihs = 0;
|
||||
|
||||
@ -97,7 +102,7 @@ void PlutoSDROutputThread::run()
|
||||
|
||||
if (nbytes_tx != 4*m_blockSizeSamples)
|
||||
{
|
||||
qDebug("PlutoSDROutputThread::run: error pushing buf %d != %d\n", (int) nbytes_tx, (int) 4*m_blockSizeSamples);
|
||||
qDebug("PlutoSDROutputThread::run: error pushing buf %d / %d\n", (int) nbytes_tx, (int) 4*m_blockSizeSamples);
|
||||
usleep(200000);
|
||||
continue;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "plutosdrinput.h"
|
||||
#include "plutosdrinputthread.h"
|
||||
|
||||
#define PLUTOSDR_BLOCKSIZE_SAMPLES (8*1024) //complex samples per buffer (must be multiple of 64)
|
||||
#define PLUTOSDR_BLOCKSIZE_SAMPLES (16*1024) //complex samples per buffer (must be multiple of 64)
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(PlutoSDRInput::MsgConfigurePlutoSDR, Message)
|
||||
MESSAGE_CLASS_DEFINITION(PlutoSDRInput::MsgFileRecord, Message)
|
||||
@ -214,9 +214,11 @@ bool PlutoSDRInput::openDevice()
|
||||
m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
|
||||
|
||||
// acquire the channel
|
||||
suspendBuddies();
|
||||
DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox();
|
||||
plutoBox->openRx();
|
||||
m_plutoRxBuffer = plutoBox->createRxBuffer(PLUTOSDR_BLOCKSIZE_SAMPLES*2, false); // PlutoSDR buffer size is counted in number of I or Q samples not the combination
|
||||
m_plutoRxBuffer = plutoBox->createRxBuffer(PLUTOSDR_BLOCKSIZE_SAMPLES, false);
|
||||
resumeBuddies();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class DeviceSourceAPI;
|
||||
|
||||
const PluginDescriptor PlutoSDRInputPlugin::m_pluginDescriptor = {
|
||||
QString("PlutoSDR Input"),
|
||||
QString("3.7.4"),
|
||||
QString("3.7.8"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
|
@ -34,8 +34,8 @@ PlutoSDRInputThread::PlutoSDRInputThread(uint32_t blocksizeSamples, DevicePlutoS
|
||||
m_fcPos(PlutoSDRInputSettings::FC_POS_CENTER),
|
||||
m_phasor(0)
|
||||
{
|
||||
m_buf = new qint16[blocksizeSamples*(sizeof(Sample)/sizeof(qint16))];
|
||||
m_bufConv = new qint16[blocksizeSamples*(sizeof(Sample)/sizeof(qint16))];
|
||||
m_buf = new qint16[blocksizeSamples*2]; // (I,Q) -> 2 * int16_t
|
||||
m_bufConv = new qint16[blocksizeSamples*2]; // (I,Q) -> 2 * int16_t
|
||||
}
|
||||
|
||||
PlutoSDRInputThread::~PlutoSDRInputThread()
|
||||
@ -75,6 +75,13 @@ void PlutoSDRInputThread::setFcPos(int fcPos)
|
||||
|
||||
void PlutoSDRInputThread::run()
|
||||
{
|
||||
std::ptrdiff_t p_inc = m_plutoBox->rxBufferStep();
|
||||
|
||||
qDebug("PlutoSDRInputThread::run: rxBufferStep: %ld bytes", p_inc);
|
||||
qDebug("PlutoSDRInputThread::run: Rx sample size is %ld bytes", m_plutoBox->getRxSampleSize());
|
||||
qDebug("PlutoSDRInputThread::run: Tx sample size is %ld bytes", m_plutoBox->getTxSampleSize());
|
||||
qDebug("PlutoSDRInputThread::run: nominal nbytes_rx is %d bytes with 2 refills", m_blockSizeSamples*2);
|
||||
|
||||
m_running = true;
|
||||
m_startWaiter.wakeAll();
|
||||
|
||||
@ -82,21 +89,19 @@ void PlutoSDRInputThread::run()
|
||||
{
|
||||
ssize_t nbytes_rx;
|
||||
char *p_dat, *p_end;
|
||||
std::ptrdiff_t p_inc;
|
||||
int ihs; // half sample index (I then Q to make a sample)
|
||||
|
||||
// Refill RX buffer
|
||||
nbytes_rx = m_plutoBox->rxBufferRefill();
|
||||
|
||||
if (nbytes_rx < 0)
|
||||
if (nbytes_rx != m_blockSizeSamples*2)
|
||||
{
|
||||
qWarning("PlutoSDRInputThread::run: error refilling buf %d\n",(int) nbytes_rx);
|
||||
qWarning("PlutoSDRInputThread::run: error refilling buf (1) %d / %d\n",(int) nbytes_rx, (int) m_blockSizeSamples*2);
|
||||
usleep(200000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// READ: Get pointers to RX buf and read IQ from RX buf port 0
|
||||
p_inc = m_plutoBox->rxBufferStep();
|
||||
p_end = m_plutoBox->rxBufferEnd();
|
||||
ihs = 0;
|
||||
|
||||
@ -111,6 +116,30 @@ void PlutoSDRInputThread::run()
|
||||
ihs++;
|
||||
}
|
||||
|
||||
// Refill RX buffer again - we still need twice more samples to complete since they come as I followed by Q
|
||||
nbytes_rx = m_plutoBox->rxBufferRefill();
|
||||
|
||||
if (nbytes_rx != m_blockSizeSamples*2)
|
||||
{
|
||||
qWarning("PlutoSDRInputThread::run: error refilling buf (2) %d / %d\n",(int) nbytes_rx, (int) m_blockSizeSamples*2);
|
||||
usleep(200000);
|
||||
continue;
|
||||
}
|
||||
|
||||
// READ: Get pointers to RX buf and read IQ from RX buf port 0
|
||||
p_end = m_plutoBox->rxBufferEnd();
|
||||
|
||||
// p_inc is 2 on a char* buffer therefore each iteration processes only the I or Q sample
|
||||
// I and Q samples are processed one after the other
|
||||
// conversion is not needed as samples are little endian
|
||||
|
||||
for (p_dat = m_plutoBox->rxBufferFirst(); p_dat < p_end; p_dat += p_inc)
|
||||
{
|
||||
m_buf[ihs] = *((int16_t *) p_dat);
|
||||
// iio_channel_convert(m_plutoBox->getRxChannel0(), (void *) &m_bufConv[ihs], (const void *) &m_buf[ihs]);
|
||||
ihs++;
|
||||
}
|
||||
|
||||
//m_sampleFifo->write((unsigned char *) m_buf, ihs*sizeof(int16_t));
|
||||
convert(m_buf, 2*m_blockSizeSamples); // size given in number of int16_t (I and Q interleaved)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user