From 1d8021d309c2e40a6801590fa4861cabf2a18ff1 Mon Sep 17 00:00:00 2001 From: nanovna <54525305+nanovna@users.noreply.github.com> Date: Tue, 11 Feb 2020 17:41:17 +0000 Subject: [PATCH] fix build errors on windows --- libxavna/xavna.C | 2 +- libxavna/xavna_cpp.C | 4 ++-- vna_qt/firmwareupdater.C | 17 ++++------------- vna_qt/vna_qt.pro | 2 +- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/libxavna/xavna.C b/libxavna/xavna.C index d364b56..a14dfd6 100644 --- a/libxavna/xavna.C +++ b/libxavna/xavna.C @@ -557,7 +557,7 @@ extern "C" { try { return xavna_default_constructor(dev); } catch(logic_error& ex) { - errno = ENOMEDIUM; + errno = ECONNREFUSED; return NULL; } catch(exception& ex) { return NULL; diff --git a/libxavna/xavna_cpp.C b/libxavna/xavna_cpp.C index d0ab8ca..7037057 100644 --- a/libxavna/xavna_cpp.C +++ b/libxavna/xavna_cpp.C @@ -35,8 +35,8 @@ namespace xaxaxa { } _dev = xavna_open(dev.c_str()); if(!_dev) { - // ENOMEDIUM indicates DFU mode - if(errno == ENOMEDIUM) + // ECONNREFUSED indicates DFU mode + if(errno == ECONNREFUSED) throw logic_error("DFU mode"); throw runtime_error(strerror(errno)); } diff --git a/vna_qt/firmwareupdater.C b/vna_qt/firmwareupdater.C index 3bc509a..e1f758b 100644 --- a/vna_qt/firmwareupdater.C +++ b/vna_qt/firmwareupdater.C @@ -3,6 +3,7 @@ #include #include #include +#include // this dependency can be removed if you provide implementations // of qToLittleEndian() and qFromLittleEndian() @@ -144,22 +145,12 @@ void* FirmwareUpdater::_flashThread(void* v) { } -static inline timespec currTime() { - timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts; -} -static int64_t timediff(const timespec& start, const timespec& stop) { - int64_t tmp = stop.tv_nsec - start.tv_nsec; - tmp += int64_t(stop.tv_sec - start.tv_sec) * 1000000000LL; - return tmp; -} void* FirmwareUpdater::flashThread() { constexpr int bufSize = 255; uint8_t buf[bufSize]; int outstanding = 0; int progress = 0; - auto lastNotify = currTime(); + auto lastNotify = time(nullptr); while(true) { auto br = _reader(buf, bufSize); @@ -173,8 +164,8 @@ void* FirmwareUpdater::flashThread() { goto fail; progress += br; - auto t = currTime(); - if(timediff(lastNotify, t) > 100000000) { + auto t = time(nullptr); + if(t - lastNotify >= 1) { lastNotify = t; _cb(progress); } diff --git a/vna_qt/vna_qt.pro b/vna_qt/vna_qt.pro index 13e36c6..e7db2de 100644 --- a/vna_qt/vna_qt.pro +++ b/vna_qt/vna_qt.pro @@ -92,7 +92,7 @@ DISTFILES += languages/vna_qt_zh.ts RESOURCES += \ resources.qrc -LIBS += -L$$PWD/../libxavna/.libs/ -L/usr/local/lib/ -lxavna -lfftw3 +LIBS += -L$$PWD/../libxavna/.libs/ -L/usr/local/lib/ -lxavna -lfftw3 -lpthread android: LIBS += -L$$PWD/../lib win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../libxavna/xavna_mock_ui/release/ -lxavna_mock_ui