1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

SDRdaemon: first working version

This commit is contained in:
f4exb 2016-02-17 19:42:26 +01:00
parent 8d986368bd
commit 05a4a7cb4e
6 changed files with 35 additions and 27 deletions

View File

@ -287,7 +287,6 @@ add_library(sdrbase SHARED
target_link_libraries(sdrbase target_link_libraries(sdrbase
${QT_LIBRARIES} ${QT_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${LIBUSB_LIBRARIES}
) )
if(FFTW3F_FOUND) if(FFTW3F_FOUND)
@ -353,5 +352,8 @@ qt5_use_modules(sdrangel Widgets Multimedia)
############################################################################## ##############################################################################
add_subdirectory(plugins) 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)

View File

@ -23,7 +23,6 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include-gpl ${CMAKE_SOURCE_DIR}/include-gpl
${LIBRTLSDR_INCLUDE_DIR}
) )
#include(${QT_USE_FILE}) #include(${QT_USE_FILE})
@ -42,7 +41,6 @@ add_library(inputfilesource SHARED
target_link_libraries(inputfilesource target_link_libraries(inputfilesource
${QT_LIBRARIES} ${QT_LIBRARIES}
${LIBUSB_LIBRARIES}
sdrbase sdrbase
) )

View File

@ -7,7 +7,6 @@ set(sdrdaemon_SOURCES
sdrdaemongui.cpp sdrdaemongui.cpp
sdrdaemoninput.cpp sdrdaemoninput.cpp
sdrdaemonplugin.cpp sdrdaemonplugin.cpp
sdrdaemonthread.cpp
sdrdaemonudphandler.cpp sdrdaemonudphandler.cpp
) )
@ -16,7 +15,6 @@ set(sdrdaemon_HEADERS
sdrdaemongui.h sdrdaemongui.h
sdrdaemoninput.h sdrdaemoninput.h
sdrdaemonplugin.h sdrdaemonplugin.h
sdrdaemonthread.h
sdrdaemonudphandler.h sdrdaemonudphandler.h
) )

View File

@ -19,8 +19,9 @@
#include <iostream> #include <iostream>
#include "sdrdaemonbuffer.h" #include "sdrdaemonbuffer.h"
SDRdaemonBuffer::SDRdaemonBuffer(uint32_t blockSize) : SDRdaemonBuffer::SDRdaemonBuffer(uint32_t blockSize, uint32_t rateDivider) :
m_blockSize(blockSize), m_blockSize(blockSize),
m_rateDivider(rateDivider),
m_sync(false), m_sync(false),
m_lz4(false), m_lz4(false),
m_inCount(0), m_inCount(0),
@ -40,7 +41,7 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t blockSize) :
m_readCount(0), m_readCount(0),
m_rawSize(0), m_rawSize(0),
m_rawBuffer(0), m_rawBuffer(0),
m_frameBuffer(0), m_chunkBuffer(0),
m_bytesInBlock(0), m_bytesInBlock(0),
m_nbBlocks(0) m_nbBlocks(0)
{ {
@ -61,8 +62,8 @@ SDRdaemonBuffer::~SDRdaemonBuffer()
delete[] m_lz4OutBuffer; delete[] m_lz4OutBuffer;
} }
if (m_frameBuffer) { if (m_chunkBuffer) {
delete[] m_frameBuffer; delete[] m_chunkBuffer;
} }
} }
@ -140,7 +141,8 @@ void SDRdaemonBuffer::writeData(char *array, uint32_t length)
} }
else else
{ {
writeDataUncompressed(array, length); //writeDataUncompressed(array, length);
writeToRawBufferUncompressed(array, length);
} }
} }
} }
@ -249,10 +251,11 @@ uint8_t *SDRdaemonBuffer::readData(uint32_t length)
} }
else else
{ {
std::memcpy((void *) m_frameBuffer, (const void *) &m_rawBuffer[readCount], m_rawSize - m_readCount); // read last bit from raw buffer uint32_t retLength = std::min(length, m_chunkSize);
m_readCount = length - (m_rawSize - m_readCount); std::memcpy((void *) m_chunkBuffer, (const void *) &m_rawBuffer[readCount], m_rawSize - m_readCount); // read last bit from raw buffer
std::memcpy((void *) &m_frameBuffer[m_rawSize - m_readCount], (const void *) m_frameBuffer, m_readCount); // read the rest at start of raw buffer m_readCount = retLength - (m_rawSize - m_readCount);
return m_frameBuffer; 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_rawSize = nbFrames * frameSize;
m_rawBuffer = new uint8_t[m_rawSize]; m_rawBuffer = new uint8_t[m_rawSize];
if (m_frameBuffer) { if (m_chunkBuffer) {
delete[] m_frameBuffer; 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) void SDRdaemonBuffer::updateBlockCounts(uint32_t nbBytesReceived)

View File

@ -61,7 +61,7 @@ public:
}; };
#pragma pack(pop) #pragma pack(pop)
SDRdaemonBuffer(uint32_t blockSize); SDRdaemonBuffer(uint32_t blockSize, uint32_t rateDivider);
~SDRdaemonBuffer(); ~SDRdaemonBuffer();
bool readMeta(char *array, uint32_t length); //!< Attempt to read meta. Returns true if meta block 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. 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 updateBufferSize(uint32_t sampleRate, uint32_t frameSize);
void printMeta(MetaData *metaData); 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_sync; //!< Meta data acquired (Stream synchronized)
bool m_lz4; //!< Stream is compressed with LZ4 bool m_lz4; //!< Stream is compressed with LZ4
MetaData m_currentMeta; //!< Stored current meta data 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_readCount; //!< Current read position in the raw samples buffer
uint32_t m_rawSize; //!< Size of the raw samples buffer in bytes 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_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_bytesInBlock; //!< Number of bytes received in the current UDP block
uint32_t m_nbBlocks; //!< Number of UDP blocks received in the current frame uint32_t m_nbBlocks; //!< Number of UDP blocks received in the current frame
}; };

View File

@ -17,6 +17,8 @@
#include <QUdpSocket> #include <QUdpSocket>
#include <QDebug> #include <QDebug>
#include <unistd.h> #include <unistd.h>
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "sdrdaemonudphandler.h" #include "sdrdaemonudphandler.h"
#include "sdrdaemoninput.h" #include "sdrdaemoninput.h"
@ -25,7 +27,7 @@ const int SDRdaemonUDPHandler::m_udpPayloadSize = 512;
SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) : SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) :
m_mutex(QMutex::Recursive), m_mutex(QMutex::Recursive),
m_sdrDaemonBuffer(m_udpPayloadSize), m_sdrDaemonBuffer(m_udpPayloadSize, m_rateDivider),
m_dataSocket(0), m_dataSocket(0),
m_dataAddress(QHostAddress::LocalHost), m_dataAddress(QHostAddress::LocalHost),
m_dataPort(9090), m_dataPort(9090),
@ -140,11 +142,13 @@ void SDRdaemonUDPHandler::processData()
if (change) if (change)
{ {
DSPSignalNotification *notif = new DSPSignalNotification(m_samplerate, m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
SDRdaemonInput::MsgReportSDRdaemonStreamData *report = SDRdaemonInput::MsgReportSDRdaemonStreamData::create( SDRdaemonInput::MsgReportSDRdaemonStreamData *report = SDRdaemonInput::MsgReportSDRdaemonStreamData::create(
metaData.m_sampleRate, m_samplerate,
metaData.m_centerFrequency, m_centerFrequency,
metaData.m_tv_sec, m_tv_sec,
metaData.m_tv_usec); m_tv_usec);
m_outputMessageQueueToGUI->push(report); m_outputMessageQueueToGUI->push(report);
} }
} }