Reduce the very large timeout value by polling the serial line.

The event reporting is improved as well, by emitting more waiting 
events.
This commit is contained in:
Jef Driesen 2009-01-07 10:07:37 +00:00
parent c55bbede1d
commit 8f845c5fe6

View File

@ -113,8 +113,8 @@ uwatec_memomouse_device_open (device_t **out, const char* name)
return DEVICE_STATUS_IO; return DEVICE_STATUS_IO;
} }
// Set the timeout for receiving data (60s). // Set the timeout for receiving data (1000 ms).
if (serial_set_timeout (device->port, 60000) == -1) { if (serial_set_timeout (device->port, 1000) == -1) {
WARNING ("Failed to set the timeout."); WARNING ("Failed to set the timeout.");
serial_close (device->port); serial_close (device->port);
free (device); free (device);
@ -437,9 +437,13 @@ uwatec_memomouse_dump (uwatec_memomouse_device_t *device, unsigned char *data[],
return DEVICE_STATUS_PROTOCOL; return DEVICE_STATUS_PROTOCOL;
} }
progress_event (&progress, DEVICE_EVENT_WAITING, 0); // Wait for the data packet.
while (serial_get_received (device->port) == 0) {
progress_event (&progress, DEVICE_EVENT_WAITING, 0);
serial_sleep (100);
}
// Wait for the transfer and read the data. // Read the data packet.
return uwatec_memomouse_read_packet_inner (device, data, size, &progress); return uwatec_memomouse_read_packet_inner (device, data, size, &progress);
} }