Fix hl_usleep again to undo prior fix

Fix hl_usleep to not sleep if 1ms or less is called for -- speeds things up on Windows dramatically
pull/1302/head
Mike Black W9MDB 2023-05-14 15:42:00 -05:00
rodzic 29d3833228
commit 647c5b37ef
2 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -759,7 +759,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p)
timeout_save = p->timeout;
timeout_retry_save = p->timeout_retry;
p->timeout = 1;
p->timeout = 0;
p->timeout_retry = 0;
do

Wyświetl plik

@ -52,6 +52,8 @@ extern "C" {
int hl_usleep(rig_useconds_t usec)
{
int retval = 0;
//rig_debug(RIG_DEBUG_ERR, "%s: usec=%ld\n", __func__, usec);
if (usec <= 1000) return 0; // dont' sleep if only 1ms is requested -- speeds things up on Windows
while (usec > 1000000)
{
@ -63,7 +65,7 @@ int hl_usleep(rig_useconds_t usec)
#ifdef HAVE_NANOSLEEP
struct timespec t, tleft;
t.tv_sec = usec/1e6;
t.tv_nsec = (usec - (t.tv_sec*1e6)) / 1e3;
t.tv_nsec = (usec - (t.tv_sec*1e6)) * 1e3;
return nanosleep(&t, &tleft);
#else
return usleep(usec);