LimeSDR in Windows: fixed build with debianminimalist branch of LimeSuite but do not include in the distribution

This commit is contained in:
f4exb 2017-08-10 03:42:15 +02:00
parent 5900d2197e
commit d612bc2ee6
5 changed files with 231 additions and 2 deletions

View File

@ -21,12 +21,25 @@ CONFIG(MINGW64):LIBBLADERFSRC = "D:\softs\bladeRF\host\libraries\libbladeRF\incl
CONFIG(macx):LIBHACKRFSRC = "/opt/local/include"
CONFIG(MINGW32):LIBHACKRFSRC = "D:\softs\hackrf\host"
CONFIG(MINGW64):LIBHACKRFSRC = "D:\softs\hackrf\host"
CONFIG(MINGW32):LIBLIMESUITESRC = "D:\softs\LimeSuite"
CONFIG(MINGW64):LIBLIMESUITESRC = "D:\softs\LimeSuite"
INCLUDEPATH += $$PWD
INCLUDEPATH += ../sdrbase
INCLUDEPATH += $$LIBBLADERFSRC
INCLUDEPATH += $$LIBHACKRFSRC
CONFIG(MINGW64)INCLUDEPATH += "D:\boost_1_58_0"
CONFIG(MINGW64)INCLUDEPATH += ../liblimesuite/srcmw
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/ADF4002
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/ConnectionRegistry
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/FPGA_common
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/GFIR
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/lms7002m
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/lms7002m_mcu
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/Si5351C
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/src/protocols
CONFIG(MINGW64)INCLUDEPATH += $$LIBLIMESUITESRC/external/cpp-feather-ini-parser
CONFIG(Release):build_subdir = release
CONFIG(Debug):build_subdir = debug
@ -39,6 +52,10 @@ SOURCES += hackrf/devicehackrf.cpp\
hackrf/devicehackrfvalues.cpp\
hackrf/devicehackrfshared.cpp
CONFIG(MINGW64)SOURCES += limesdr/devicelimesdr.cpp\
limesdr/devicelimesdrparam.cpp\
limesdr/devicelimesdrshared.cpp
!macx:HEADERS -= bladerf/devicebladerf.h\
bladerf/devicebladerfparam.h\
bladerf/devicebladerfvalues.h\
@ -49,9 +66,14 @@ HEADERS += hackrf/devicehackrf.h\
hackrf/devicehackrfvalues.h\
hackrf/devicehackrfshared.h
CONFIG(MINGW64)HEADERS += limesdr/devicelimesdr.h\
limesdr/devicelimesdrparam.h\
limesdr/devicelimesdrshared.h
LIBS += -L../sdrbase/$${build_subdir} -lsdrbase
LIBS += -L../libbladerf/$${build_subdir} -llibbladerf
LIBS += -L../libhackrf/$${build_subdir} -llibhackrf
CONFIG(MINGW64)LIBS += -L../liblimesuite/$${build_subdir} -lliblimesuite
macx {
LIBS -= -L../libbladerf/$${build_subdir} -llibbladerf

View File

@ -40,9 +40,9 @@ SOURCES = $$LIBLIMESUITESRC/src/ADF4002/ADF4002.cpp\
$$LIBLIMESUITESRC/src/ConnectionRegistry/ConnectionRegistry.cpp\
$$LIBLIMESUITESRC/src/ConnectionRegistry/IConnection.cpp\
srcmw/ConnectionSTREAM/ConnectionSTREAM.cpp\
$$LIBLIMESUITESRC/src/ConnectionSTREAM/ConnectionSTREAMEntry.cpp\
srcmw/ConnectionSTREAM/ConnectionSTREAMImages.cpp\
srcmw/ConnectionSTREAM/ConnectionSTREAMing.cpp\
srcmw/ConnectionSTREAM/ConnectionSTREAMEntry.cpp\
srcmw/Connection_uLimeSDR/Connection_uLimeSDR.cpp\
srcmw/Connection_uLimeSDR/Connection_uLimeSDREntry.cpp\
srcmw/Connection_uLimeSDR/Connection_uLimeSDRing.cpp\

View File

@ -0,0 +1,201 @@
/**
@file ConnectionSTREAMEntry.cpp
@author Lime Microsystems
@brief Implementation of STREAM board connection.
*/
#include "ConnectionSTREAM.h"
#include "Logger.h"
using namespace lime;
#ifdef __unix__
void ConnectionSTREAMEntry::handle_libusb_events()
{
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 250000;
while(mProcessUSBEvents.load() == true)
{
int r = libusb_handle_events_timeout_completed(ctx, &tv, NULL);
if(r != 0) lime::error("error libusb_handle_events %s", libusb_strerror(libusb_error(r)));
}
}
#endif // __UNIX__
//! make a static-initialized entry in the registry
void __loadConnectionSTREAMEntry(void) //TODO fixme replace with LoadLibrary/dlopen
{
static ConnectionSTREAMEntry STREAMEntry;
}
int USBTransferContext::idCounter = 0;
ConnectionSTREAMEntry::ConnectionSTREAMEntry(void):
ConnectionRegistryEntry("STREAM")
{
#ifdef __unix__
int r = libusb_init(&ctx); //initialize the library for the session we just declared
if(r < 0)
lime::error("Init Error %i", r); //there was an error
libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
mProcessUSBEvents.store(true);
mUSBProcessingThread = std::thread(&ConnectionSTREAMEntry::handle_libusb_events, this);
#endif
}
ConnectionSTREAMEntry::ConnectionSTREAMEntry(const std::string entryName):
ConnectionRegistryEntry(entryName)
{
#ifdef __unix__
int r = libusb_init(&ctx); //initialize the library for the session we just declared
if(r < 0)
lime::error("Init Error %i", r); //there was an error
libusb_set_debug(ctx, 3); //set verbosity level to 3, as suggested in the documentation
mProcessUSBEvents.store(true);
mUSBProcessingThread = std::thread(&ConnectionSTREAMEntry::handle_libusb_events, this);
#endif
}
ConnectionSTREAMEntry::~ConnectionSTREAMEntry(void)
{
#ifdef __unix__
mProcessUSBEvents.store(false);
mUSBProcessingThread.join();
libusb_exit(ctx);
#endif
}
#ifndef __unix__
/** @return name of usb device as string.
@param index device index in list
*/
std::string ConnectionSTREAMEntry::DeviceName(unsigned int index)
{
std::string name;
char tempName[USB_STRING_MAXLEN];
CCyUSBDevice device;
if (index >= device.DeviceCount())
return "";
for (int i = 0; i < USB_STRING_MAXLEN; ++i)
tempName[i] = device.DeviceName[i];
if (device.bSuperSpeed == true)
name = "USB 3.0";
else if (device.bHighSpeed == true)
name = "USB 2.0";
else
name = "USB";
name += " (";
name += tempName;
name += ")";
return name;
}
#endif
std::vector<ConnectionHandle> ConnectionSTREAMEntry::enumerate(const ConnectionHandle &hint)
{
std::vector<ConnectionHandle> handles;
#ifndef __unix__
CCyUSBDevice device;
if (device.DeviceCount())
{
for (int i = 0; i<device.DeviceCount(); ++i)
{
if (hint.index >= 0 && hint.index != i)
continue;
if (device.IsOpen())
device.Close();
device.Open(i);
ConnectionHandle handle;
handle.media = "USB";
handle.name = DeviceName(i);
handle.index = i;
std::wstring ws(device.SerialNumber);
handle.serial = std::string(ws.begin(),ws.end());
if (hint.serial.empty() or hint.serial == handle.serial)
{
handles.push_back(handle); //filter on serial
}
device.Close();
}
}
#else
libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices
int usbDeviceCount = libusb_get_device_list(ctx, &devs);
if (usbDeviceCount < 0) {
lime::error("failed to get libusb device list: %s", libusb_strerror(libusb_error(usbDeviceCount)));
return handles;
}
for(int i=0; i<usbDeviceCount; ++i)
{
libusb_device_descriptor desc;
int r = libusb_get_device_descriptor(devs[i], &desc);
if(r<0)
lime::error("failed to get device description");
int pid = desc.idProduct;
int vid = desc.idVendor;
if(vid == 1204 && pid == 34323)
{
ConnectionHandle handle;
handle.media = "USB";
handle.name = "DigiGreen";
handle.addr = std::to_string(int(pid))+":"+std::to_string(int(vid));
handles.push_back(handle);
}
else if((vid == 1204 && pid == 241) || (vid == 1204 && pid == 243) || (vid == 7504 && pid == 24840))
{
libusb_device_handle *tempDev_handle(nullptr);
if(libusb_open(devs[i], &tempDev_handle) != 0 || tempDev_handle == nullptr)
continue;
ConnectionHandle handle;
//check operating speed
int speed = libusb_get_device_speed(devs[i]);
if(speed == LIBUSB_SPEED_HIGH)
handle.media = "USB 2.0";
else if(speed == LIBUSB_SPEED_SUPER)
handle.media = "USB 3.0";
else
handle.media = "USB";
//read device name
char data[255];
r = libusb_get_string_descriptor_ascii(tempDev_handle, LIBUSB_CLASS_COMM, (unsigned char*)data, sizeof(data));
if(r > 0) handle.name = std::string(data, size_t(r));
r = std::sprintf(data, "%.4x:%.4x", int(vid), int(pid));
if (r > 0) handle.addr = std::string(data, size_t(r));
if (desc.iSerialNumber > 0)
{
r = libusb_get_string_descriptor_ascii(tempDev_handle,desc.iSerialNumber,(unsigned char*)data, sizeof(data));
if(r<0)
lime::error("failed to get serial number");
else
handle.serial = std::string(data, size_t(r));
}
libusb_close(tempDev_handle);
//add handle conditionally, filter by serial number
if (hint.serial.empty() or hint.serial == handle.serial)
{
handles.push_back(handle);
}
}
}
libusb_free_device_list(devs, 1);
#endif
return handles;
}
IConnection *ConnectionSTREAMEntry::make(const ConnectionHandle &handle)
{
return new ConnectionSTREAM(ctx, handle.addr, handle.serial, handle.index);
}

View File

@ -15,6 +15,7 @@ SUBDIRS += libhackrf
SUBDIRS += libairspy
SUBDIRS += libbladerf
CONFIG(MINGW64)SUBDIRS += libsqlite3
CONFIG(MINGW64)SUBDIRS += liblimesuite
SUBDIRS += mbelib
SUBDIRS += dsdcc
SUBDIRS += serialdv
@ -25,9 +26,11 @@ SUBDIRS += plugins/samplesource/rtlsdr
SUBDIRS += plugins/samplesource/hackrfinput
SUBDIRS += plugins/samplesource/airspy
SUBDIRS += plugins/samplesource/bladerfinput
CONFIG(MINGW64)SUBDIRS += plugins/samplesource/limesdrinput
SUBDIRS += plugins/samplesink/filesink
SUBDIRS += plugins/samplesink/bladerfoutput
SUBDIRS += plugins/samplesink/hackrfoutput
CONFIG(MINGW64)SUBDIRS += plugins/samplesink/limesdroutput
SUBDIRS += plugins/channelrx/chanalyzer
SUBDIRS += plugins/channelrx/chanalyzerng
SUBDIRS += plugins/channelrx/demodam

View File

@ -25,7 +25,8 @@ copy libhackrf\%1\libhackrf.dll %2
copy librtlsdr\%1\librtlsdr.dll %2
copy libairspy\%1\libairspy.dll %2
copy libbladerf\%1\libbladerf.dll %2
copy libsqlite3\%1\libsqlite3.dll %2
REM copy libsqlite3\%1\libsqlite3.dll %2
REM copy liblimesuite\%1\liblimesuite.dll %2
copy %libusbdir%\dll\libusb-1.0.dll %2
copy %opencvdir%\opencv_ffmpeg2413_64.dll %2
copy %opencvdir%\libopencv_imgproc2413.dll %2
@ -59,6 +60,8 @@ copy plugins\samplesource\rtlsdr\%1\inputrtlsdr.dll %2\plugins\samplesource
copy plugins\samplesource\hackrfinput\%1\inputhackrf.dll %2\plugins\samplesource
copy plugins\samplesource\airspy\%1\inputairspy.dll %2\plugins\samplesource
copy plugins\samplesource\bladerfinput\%1\inputbladerf.dll %2\plugins\samplesource
REM copy plugins\samplesource\limesdrinput\%1\inputlimesdr.dll %2\plugins\samplesource
copy plugins\samplesink\filesink\%1\outputfilesink.dll %2\plugins\samplesink
copy plugins\samplesink\bladerfoutput\%1\outputbladerf.dll %2\plugins\samplesink
copy plugins\samplesink\hackrfoutput\%1\outputhackrf.dll %2\plugins\samplesink
REM copy plugins\samplesink\limesdroutput\%1\outputlimesdr.dll %2\plugins\samplesink