fix sleep durations on Windows
Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
parent
b745896cbe
commit
7ae9754ede
|
@ -28,11 +28,13 @@
|
|||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#define sleep_ms(ms) usleep(ms*1000)
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include "getopt/getopt.h"
|
||||
#define sleep_ms(ms) Sleep(ms)
|
||||
#endif
|
||||
|
||||
#include "osmo-fl2k.h"
|
||||
|
@ -191,13 +193,8 @@ int main(int argc, char **argv)
|
|||
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) sighandler, TRUE );
|
||||
#endif
|
||||
|
||||
while (!do_exit) {
|
||||
#ifndef _WIN32
|
||||
usleep(500000);
|
||||
#else
|
||||
Sleep(0.5);
|
||||
#endif
|
||||
}
|
||||
while (!do_exit)
|
||||
sleep_ms(500);
|
||||
|
||||
fl2k_close(dev);
|
||||
|
||||
|
|
|
@ -36,9 +36,12 @@
|
|||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h> /* for TCP_NODELAY */
|
||||
#include <fcntl.h>
|
||||
#define sleep_ms(ms) usleep(ms*1000)
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include "getopt/getopt.h"
|
||||
#define sleep_ms(ms) Sleep(ms)
|
||||
#endif
|
||||
|
||||
#include "osmo-fl2k.h"
|
||||
|
@ -217,11 +220,7 @@ int main(int argc, char **argv)
|
|||
|
||||
fprintf(stderr, "Connecting to %s:%d...\n", addr, port);
|
||||
while (connect(sock, (struct sockaddr *)&remote, sizeof(remote)) != 0) {
|
||||
#ifndef _WIN32
|
||||
usleep(500000);
|
||||
#else
|
||||
Sleep(0.5);
|
||||
#endif
|
||||
sleep_ms(500);
|
||||
if (do_exit)
|
||||
goto out;
|
||||
}
|
||||
|
@ -230,13 +229,8 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "Connected\n");
|
||||
connected = 1;
|
||||
|
||||
while (!do_exit) {
|
||||
#ifndef _WIN32
|
||||
usleep(500000);
|
||||
#else
|
||||
Sleep(0.5);
|
||||
#endif
|
||||
}
|
||||
while (!do_exit)
|
||||
sleep_ms(500);
|
||||
|
||||
out:
|
||||
free(txbuf);
|
||||
|
|
|
@ -41,9 +41,11 @@
|
|||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#define sleep_ms(ms) usleep(ms*1000)
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include "getopt/getopt.h"
|
||||
#define sleep_ms(ms) Sleep(ms)
|
||||
#endif
|
||||
|
||||
#include "osmo-fl2k.h"
|
||||
|
@ -290,17 +292,11 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "Reporting PPM error measurement every %u seconds...\n", ppm_duration);
|
||||
fprintf(stderr, "Press ^C after a few minutes.\n");
|
||||
|
||||
while (!do_exit) {
|
||||
#ifndef _WIN32
|
||||
usleep(500000);
|
||||
#else
|
||||
Sleep(0.5);
|
||||
#endif
|
||||
}
|
||||
while (!do_exit)
|
||||
sleep_ms(500);
|
||||
|
||||
if (do_exit) {
|
||||
if (do_exit)
|
||||
fprintf(stderr, "\nUser cancel, exiting...\n");
|
||||
}
|
||||
|
||||
exit:
|
||||
fl2k_close(dev);
|
||||
|
|
|
@ -25,15 +25,18 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <libusb.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#define sleep_ms(ms) usleep(ms*1000)
|
||||
#else
|
||||
#include <windows.h>
|
||||
#define sleep_ms(ms) Sleep(ms)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* All libusb callback functions should be marked with the LIBUSB_CALL macro
|
||||
* to ensure that they are compiled with the same calling convention as libusb.
|
||||
|
@ -476,13 +479,8 @@ int fl2k_close(fl2k_dev_t *dev)
|
|||
|
||||
if(!dev->dev_lost) {
|
||||
/* block until all async operations have been completed (if any) */
|
||||
while (FL2K_INACTIVE != dev->async_status) {
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(1000);
|
||||
#endif
|
||||
}
|
||||
while (FL2K_INACTIVE != dev->async_status)
|
||||
sleep_ms(100);
|
||||
|
||||
fl2k_deinit_device(dev);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue