Add a delay between sending the commands.
When trying to send the commands as fast as possible, without any delay, the failure rate is very high. Almost every single packet fails with a timeout at first. Retrying the packet works, but those many timeouts make the download extremely slow. Adding a small delay avoids the much more expensive timeout and speeds up the transfer significantly.
This commit is contained in:
parent
fa348c0d04
commit
2abd5164f4
@ -49,6 +49,7 @@ mares_common_device_init (mares_common_device_t *device, const device_backend_t
|
||||
// Set the default values.
|
||||
device->port = NULL;
|
||||
device->echo = 0;
|
||||
device->delay = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -128,6 +129,10 @@ mares_common_packet (mares_common_device_t *device, const unsigned char command[
|
||||
if (device_is_cancelled (abstract))
|
||||
return DEVICE_STATUS_CANCELLED;
|
||||
|
||||
if (device->delay) {
|
||||
serial_sleep (device->delay);
|
||||
}
|
||||
|
||||
// Send the command to the device.
|
||||
int n = serial_write (device->port, command, csize);
|
||||
if (n != csize) {
|
||||
|
||||
@ -43,6 +43,7 @@ typedef struct mares_common_device_t {
|
||||
device_t base;
|
||||
serial_t *port;
|
||||
unsigned int echo;
|
||||
unsigned int delay;
|
||||
} mares_common_device_t;
|
||||
|
||||
void
|
||||
|
||||
@ -162,6 +162,7 @@ mares_darwin_device_open (device_t **out, const char* name, unsigned int model)
|
||||
|
||||
// Override the base class values.
|
||||
device->base.echo = 1;
|
||||
device->base.delay = 50;
|
||||
|
||||
*out = (device_t *) device;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user