diff --git a/devices/devices.pro b/devices/devices.pro index 4a4a47ad7..650455714 100644 --- a/devices/devices.pro +++ b/devices/devices.pro @@ -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 diff --git a/liblimesuite/liblimesuite.pro b/liblimesuite/liblimesuite.pro index 543e319d7..13e95e71c 100644 --- a/liblimesuite/liblimesuite.pro +++ b/liblimesuite/liblimesuite.pro @@ -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\ diff --git a/liblimesuite/srcmw/ConnectionSTREAM/ConnectionSTREAMEntry.cpp b/liblimesuite/srcmw/ConnectionSTREAM/ConnectionSTREAMEntry.cpp new file mode 100644 index 000000000..20812abbc --- /dev/null +++ b/liblimesuite/srcmw/ConnectionSTREAM/ConnectionSTREAMEntry.cpp @@ -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 ConnectionSTREAMEntry::enumerate(const ConnectionHandle &hint) +{ + std::vector handles; + +#ifndef __unix__ + CCyUSBDevice device; + if (device.DeviceCount()) + { + for (int i = 0; i= 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 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); +} diff --git a/sdrangel.windows.pro b/sdrangel.windows.pro index 2fd7b9382..9be3372b8 100644 --- a/sdrangel.windows.pro +++ b/sdrangel.windows.pro @@ -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 diff --git a/windows64.install.bat b/windows64.install.bat index d5432aaca..094ec4b0f 100644 --- a/windows64.install.bat +++ b/windows64.install.bat @@ -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