diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 0521e2e..58e18ea 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -326,15 +326,7 @@ hw_ostc3_transfer (hw_ostc3_device_t *device, } if (delay && device->available == 0) { - unsigned int count = delay / 100; - for (unsigned int i = 0; i < count; ++i) { - size_t available = 0; - status = dc_iostream_get_available (device->iostream, &available); - if (status == DC_STATUS_SUCCESS && available > 0) - break; - - dc_iostream_sleep (device->iostream, 100); - } + dc_iostream_poll (device->iostream, delay); } if (cmd != EXIT) { diff --git a/src/mares_nemo.c b/src/mares_nemo.c index 7529704..f5e22a3 100644 --- a/src/mares_nemo.c +++ b/src/mares_nemo.c @@ -177,13 +177,11 @@ mares_nemo_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); // Wait until some data arrives. - size_t available = 0; - while (dc_iostream_get_available (device->iostream, &available) == DC_STATUS_SUCCESS && available == 0) { + while (dc_iostream_poll (device->iostream, 100) == DC_STATUS_TIMEOUT) { if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; device_event_emit (abstract, DC_EVENT_WAITING, NULL); - dc_iostream_sleep (device->iostream, 100); } // Receive the header of the package. diff --git a/src/uwatec_memomouse.c b/src/uwatec_memomouse.c index c77b598..e605578 100644 --- a/src/uwatec_memomouse.c +++ b/src/uwatec_memomouse.c @@ -309,14 +309,13 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t * { dc_status_t status = DC_STATUS_SUCCESS; dc_device_t *abstract = (dc_device_t *) device; - size_t available = 0; // Enable progress notifications. dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); // Waiting for greeting message. - while (dc_iostream_get_available (device->iostream, &available) == DC_STATUS_SUCCESS && available == 0) { + while (dc_iostream_poll (device->iostream, 300) == DC_STATUS_TIMEOUT) { if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; @@ -330,8 +329,6 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t * ERROR (abstract->context, "Failed to reject the packet."); return status; } - - dc_iostream_sleep (device->iostream, 300); } // Read the ID string. @@ -385,12 +382,11 @@ uwatec_memomouse_dump_internal (uwatec_memomouse_device_t *device, dc_buffer_t * } // Wait for the data packet. - while (dc_iostream_get_available (device->iostream, &available) == DC_STATUS_SUCCESS && available == 0) { + while (dc_iostream_poll (device->iostream, 100) == DC_STATUS_TIMEOUT) { if (device_is_cancelled (abstract)) return DC_STATUS_CANCELLED; device_event_emit (&device->base, DC_EVENT_WAITING, NULL); - dc_iostream_sleep (device->iostream, 100); } // Fetch the current system time.