trivial: Define the default replug timeout in a central place

Some users were using 2000ms and some the more sane 5000ms.
This commit is contained in:
Richard Hughes 2015-11-25 13:41:39 +00:00
parent a6778df664
commit 93a6edf2c6
4 changed files with 28 additions and 8 deletions

View File

@ -30,6 +30,8 @@
G_BEGIN_DECLS
#define DFU_DEVICE_REPLUG_TIMEOUT 5000 /* ms */
/**
* DfuDeviceQuirks:
* @DFU_DEVICE_QUIRK_NONE: No device quirks

View File

@ -1525,7 +1525,10 @@ dfu_device_upload (DfuDevice *device,
/* detach and USB reset */
if (!dfu_device_detach (device, NULL, error))
return NULL;
if (!dfu_device_wait_for_replug (device, 5000, NULL, error))
if (!dfu_device_wait_for_replug (device,
DFU_DEVICE_REPLUG_TIMEOUT,
cancellable,
error))
return NULL;
}
@ -1572,7 +1575,10 @@ dfu_device_upload (DfuDevice *device,
dfu_device_set_state (device, DFU_STATE_APP_DETACH);
/* DFU -> APP */
if (!dfu_device_wait_for_replug (device, 2000, cancellable, error))
if (!dfu_device_wait_for_replug (device,
DFU_DEVICE_REPLUG_TIMEOUT,
cancellable,
error))
return NULL;
}
@ -1678,7 +1684,10 @@ dfu_device_download (DfuDevice *device,
g_debug ("detaching");
if (!dfu_device_detach (device, NULL, error))
return FALSE;
if (!dfu_device_wait_for_replug (device, 5000, NULL, error))
if (!dfu_device_wait_for_replug (device,
DFU_DEVICE_REPLUG_TIMEOUT,
NULL,
error))
return FALSE;
}
@ -1732,7 +1741,10 @@ dfu_device_download (DfuDevice *device,
dfu_device_set_state (device, DFU_STATE_APP_DETACH);
/* DFU -> APP */
if (!dfu_device_wait_for_replug (device, 2000, cancellable, error))
if (!dfu_device_wait_for_replug (device,
DFU_DEVICE_REPLUG_TIMEOUT,
cancellable,
error))
return FALSE;
}

View File

@ -352,7 +352,7 @@ dfu_colorhug_plus_func (void)
g_assert (ret);
/* wait for it to come back as 273f:1005 */
ret = dfu_device_wait_for_replug (device2, 2000, NULL, &error);
ret = dfu_device_wait_for_replug (device2, 5000, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
@ -435,7 +435,7 @@ dfu_colorhug_plus_func (void)
g_assert (ret);
/* wait for it to come back as 273f:1004 */
ret = dfu_device_wait_for_replug (device, 2000, NULL, &error);
ret = dfu_device_wait_for_replug (device, 5000, NULL, &error);
g_assert_no_error (error);
g_assert (ret);

View File

@ -1092,7 +1092,10 @@ dfu_target_upload (DfuTarget *target,
/* boot to runtime */
if (flags & DFU_TARGET_TRANSFER_FLAG_BOOT_RUNTIME) {
g_debug ("booting to runtime");
if (!dfu_device_wait_for_replug (priv->device, 2000, cancellable, error))
if (!dfu_device_wait_for_replug (priv->device,
DFU_DEVICE_REPLUG_TIMEOUT,
cancellable,
error))
return NULL;
}
@ -1370,7 +1373,10 @@ dfu_target_download (DfuTarget *target, DfuImage *image,
/* boot to runtime */
if (flags & DFU_TARGET_TRANSFER_FLAG_BOOT_RUNTIME) {
g_debug ("booting to runtime to set auto-boot");
if (!dfu_device_wait_for_replug (priv->device, 2000, cancellable, error))
if (!dfu_device_wait_for_replug (priv->device,
DFU_DEVICE_REPLUG_TIMEOUT,
cancellable,
error))
return FALSE;
}