kopia lustrzana https://github.com/stlink-org/stlink
[update] submit_wait timeout
rodzic
0f6e8186d0
commit
6e98918137
|
@ -2,6 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include "stlink-hw.h"
|
||||
|
@ -106,6 +107,9 @@ static void on_trans_done(struct libusb_transfer* trans)
|
|||
|
||||
static int submit_wait(struct libusb_transfer* trans)
|
||||
{
|
||||
struct timeval start;
|
||||
struct timeval now;
|
||||
struct timeval diff;
|
||||
struct trans_ctx trans_ctx;
|
||||
enum libusb_error error;
|
||||
|
||||
|
@ -121,6 +125,8 @@ static int submit_wait(struct libusb_transfer* trans)
|
|||
return -1;
|
||||
}
|
||||
|
||||
gettimeofday(&start, NULL);
|
||||
|
||||
while (!(trans_ctx.flags & TRANS_FLAGS_IS_DONE))
|
||||
{
|
||||
if (libusb_handle_events(NULL))
|
||||
|
@ -128,6 +134,14 @@ static int submit_wait(struct libusb_transfer* trans)
|
|||
printf("libusb_handle_events()\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
timersub(&now, &start, &diff);
|
||||
if (diff.tv_sec >= 3)
|
||||
{
|
||||
printf("libusb_handle_events() timeout\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Ładowanie…
Reference in New Issue