kopia lustrzana https://github.com/f4exb/sdrangel
SDRdaemon: first working version
rodzic
8d986368bd
commit
05a4a7cb4e
|
@ -287,7 +287,6 @@ add_library(sdrbase SHARED
|
|||
target_link_libraries(sdrbase
|
||||
${QT_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
${LIBUSB_LIBRARIES}
|
||||
)
|
||||
|
||||
if(FFTW3F_FOUND)
|
||||
|
@ -353,5 +352,8 @@ qt5_use_modules(sdrangel Widgets Multimedia)
|
|||
##############################################################################
|
||||
|
||||
add_subdirectory(plugins)
|
||||
add_subdirectory(fcdhid)
|
||||
add_subdirectory(fcdlib)
|
||||
|
||||
if(LIBUSB_FOUND AND UNIX)
|
||||
add_subdirectory(fcdhid)
|
||||
add_subdirectory(fcdlib)
|
||||
endif(LIBUSB_FOUND AND UNIX)
|
||||
|
|
|
@ -23,7 +23,6 @@ include_directories(
|
|||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/include-gpl
|
||||
${LIBRTLSDR_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
#include(${QT_USE_FILE})
|
||||
|
@ -42,7 +41,6 @@ add_library(inputfilesource SHARED
|
|||
|
||||
target_link_libraries(inputfilesource
|
||||
${QT_LIBRARIES}
|
||||
${LIBUSB_LIBRARIES}
|
||||
sdrbase
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ set(sdrdaemon_SOURCES
|
|||
sdrdaemongui.cpp
|
||||
sdrdaemoninput.cpp
|
||||
sdrdaemonplugin.cpp
|
||||
sdrdaemonthread.cpp
|
||||
sdrdaemonudphandler.cpp
|
||||
)
|
||||
|
||||
|
@ -16,7 +15,6 @@ set(sdrdaemon_HEADERS
|
|||
sdrdaemongui.h
|
||||
sdrdaemoninput.h
|
||||
sdrdaemonplugin.h
|
||||
sdrdaemonthread.h
|
||||
sdrdaemonudphandler.h
|
||||
)
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
#include <iostream>
|
||||
#include "sdrdaemonbuffer.h"
|
||||
|
||||
SDRdaemonBuffer::SDRdaemonBuffer(uint32_t blockSize) :
|
||||
SDRdaemonBuffer::SDRdaemonBuffer(uint32_t blockSize, uint32_t rateDivider) :
|
||||
m_blockSize(blockSize),
|
||||
m_rateDivider(rateDivider),
|
||||
m_sync(false),
|
||||
m_lz4(false),
|
||||
m_inCount(0),
|
||||
|
@ -40,7 +41,7 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t blockSize) :
|
|||
m_readCount(0),
|
||||
m_rawSize(0),
|
||||
m_rawBuffer(0),
|
||||
m_frameBuffer(0),
|
||||
m_chunkBuffer(0),
|
||||
m_bytesInBlock(0),
|
||||
m_nbBlocks(0)
|
||||
{
|
||||
|
@ -61,8 +62,8 @@ SDRdaemonBuffer::~SDRdaemonBuffer()
|
|||
delete[] m_lz4OutBuffer;
|
||||
}
|
||||
|
||||
if (m_frameBuffer) {
|
||||
delete[] m_frameBuffer;
|
||||
if (m_chunkBuffer) {
|
||||
delete[] m_chunkBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +141,8 @@ void SDRdaemonBuffer::writeData(char *array, uint32_t length)
|
|||
}
|
||||
else
|
||||
{
|
||||
writeDataUncompressed(array, length);
|
||||
//writeDataUncompressed(array, length);
|
||||
writeToRawBufferUncompressed(array, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,10 +251,11 @@ uint8_t *SDRdaemonBuffer::readData(uint32_t length)
|
|||
}
|
||||
else
|
||||
{
|
||||
std::memcpy((void *) m_frameBuffer, (const void *) &m_rawBuffer[readCount], m_rawSize - m_readCount); // read last bit from raw buffer
|
||||
m_readCount = length - (m_rawSize - m_readCount);
|
||||
std::memcpy((void *) &m_frameBuffer[m_rawSize - m_readCount], (const void *) m_frameBuffer, m_readCount); // read the rest at start of raw buffer
|
||||
return m_frameBuffer;
|
||||
uint32_t retLength = std::min(length, m_chunkSize);
|
||||
std::memcpy((void *) m_chunkBuffer, (const void *) &m_rawBuffer[readCount], m_rawSize - m_readCount); // read last bit from raw buffer
|
||||
m_readCount = retLength - (m_rawSize - m_readCount);
|
||||
std::memcpy((void *) &m_chunkBuffer[m_rawSize - m_readCount], (const void *) m_rawBuffer, m_readCount); // read the rest at start of raw buffer
|
||||
return m_chunkBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,11 +293,12 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate, uint32_t frameSize)
|
|||
m_rawSize = nbFrames * frameSize;
|
||||
m_rawBuffer = new uint8_t[m_rawSize];
|
||||
|
||||
if (m_frameBuffer) {
|
||||
delete[] m_frameBuffer;
|
||||
if (m_chunkBuffer) {
|
||||
delete[] m_chunkBuffer;
|
||||
}
|
||||
|
||||
m_frameBuffer = new uint8_t[frameSize];
|
||||
m_chunkSize = (sampleRate * 2 * 2) / m_rateDivider;
|
||||
m_chunkBuffer = new uint8_t[m_chunkSize];
|
||||
}
|
||||
|
||||
void SDRdaemonBuffer::updateBlockCounts(uint32_t nbBytesReceived)
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
SDRdaemonBuffer(uint32_t blockSize);
|
||||
SDRdaemonBuffer(uint32_t blockSize, uint32_t rateDivider);
|
||||
~SDRdaemonBuffer();
|
||||
bool readMeta(char *array, uint32_t length); //!< Attempt to read meta. Returns true if meta block
|
||||
void writeData(char *array, uint32_t length); //!< Write data into buffer.
|
||||
|
@ -79,7 +79,8 @@ private:
|
|||
void updateBufferSize(uint32_t sampleRate, uint32_t frameSize);
|
||||
void printMeta(MetaData *metaData);
|
||||
|
||||
std::size_t m_blockSize; //!< UDP block (payload) size
|
||||
uint32_t m_blockSize; //!< UDP block (payload) size
|
||||
uint32_t m_rateDivider; //!< Number of times per seconds the samples are fetched
|
||||
bool m_sync; //!< Meta data acquired (Stream synchronized)
|
||||
bool m_lz4; //!< Stream is compressed with LZ4
|
||||
MetaData m_currentMeta; //!< Stored current meta data
|
||||
|
@ -104,7 +105,8 @@ private:
|
|||
uint32_t m_readCount; //!< Current read position in the raw samples buffer
|
||||
uint32_t m_rawSize; //!< Size of the raw samples buffer in bytes
|
||||
uint8_t *m_rawBuffer; //!< Buffer for raw samples obtained from UDP (I/Q not in a formal I/Q structure)
|
||||
uint8_t *m_frameBuffer; //!< Buffer to build a frame length of raw samples
|
||||
uint8_t *m_chunkBuffer; //!< Buffer to build a chunk length of raw samples
|
||||
uint32_t m_chunkSize; //!< Size of a chunk of samples in bytes
|
||||
uint32_t m_bytesInBlock; //!< Number of bytes received in the current UDP block
|
||||
uint32_t m_nbBlocks; //!< Number of UDP blocks received in the current frame
|
||||
};
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <QUdpSocket>
|
||||
#include <QDebug>
|
||||
#include <unistd.h>
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "sdrdaemonudphandler.h"
|
||||
#include "sdrdaemoninput.h"
|
||||
|
||||
|
@ -25,7 +27,7 @@ const int SDRdaemonUDPHandler::m_udpPayloadSize = 512;
|
|||
|
||||
SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) :
|
||||
m_mutex(QMutex::Recursive),
|
||||
m_sdrDaemonBuffer(m_udpPayloadSize),
|
||||
m_sdrDaemonBuffer(m_udpPayloadSize, m_rateDivider),
|
||||
m_dataSocket(0),
|
||||
m_dataAddress(QHostAddress::LocalHost),
|
||||
m_dataPort(9090),
|
||||
|
@ -140,11 +142,13 @@ void SDRdaemonUDPHandler::processData()
|
|||
|
||||
if (change)
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_samplerate, m_centerFrequency);
|
||||
DSPEngine::instance()->getInputMessageQueue()->push(notif);
|
||||
SDRdaemonInput::MsgReportSDRdaemonStreamData *report = SDRdaemonInput::MsgReportSDRdaemonStreamData::create(
|
||||
metaData.m_sampleRate,
|
||||
metaData.m_centerFrequency,
|
||||
metaData.m_tv_sec,
|
||||
metaData.m_tv_usec);
|
||||
m_samplerate,
|
||||
m_centerFrequency,
|
||||
m_tv_sec,
|
||||
m_tv_usec);
|
||||
m_outputMessageQueueToGUI->push(report);
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue