Skip to content

Commit

Permalink
fix build errors on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nanovna committed Feb 11, 2020
1 parent 1ab5c49 commit 1d8021d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion libxavna/xavna.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libxavna/xavna_cpp.C
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
17 changes: 4 additions & 13 deletions vna_qt/firmwareupdater.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <time.h>

// this dependency can be removed if you provide implementations
// of qToLittleEndian() and qFromLittleEndian()
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion vna_qt/vna_qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1d8021d

Please sign in to comment.