Merge pull request #301 from riscv/mpsse_flush
Add wall clock timeout to mpsse_flush()
This commit is contained in:
commit
35eed36ffd
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "mpsse.h"
|
#include "mpsse.h"
|
||||||
#include "helper/log.h"
|
#include "helper/log.h"
|
||||||
|
#include "helper/time_support.h"
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
/* Compatibility define for older libusb-1.0 */
|
/* Compatibility define for older libusb-1.0 */
|
||||||
|
@ -892,6 +893,7 @@ int mpsse_flush(struct mpsse_ctx *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Polling loop, more or less taken from libftdi */
|
/* Polling loop, more or less taken from libftdi */
|
||||||
|
int64_t start = timeval_ms();
|
||||||
while (!write_result.done || !read_result.done) {
|
while (!write_result.done || !read_result.done) {
|
||||||
struct timeval timeout_usb;
|
struct timeval timeout_usb;
|
||||||
|
|
||||||
|
@ -914,6 +916,11 @@ int mpsse_flush(struct mpsse_ctx *ctx)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timeval_ms() - start > 2000) {
|
||||||
|
LOG_ERROR("Timed out handling USB events in mpsse_flush().");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_check:
|
error_check:
|
||||||
|
|
Loading…
Reference in New Issue