diff --git a/tools/atrf-txrx/atrf-txrx.c b/tools/atrf-txrx/atrf-txrx.c index 1f1d838..3ec39be 100644 --- a/tools/atrf-txrx/atrf-txrx.c +++ b/tools/atrf-txrx/atrf-txrx.c @@ -299,7 +299,7 @@ static void receive_hmac(struct atrf_dsc *dsc) int n, i; atrf_rx_mode(dsc, 1); - n = atrf_rx(dsc, buf, sizeof(buf), &lqi); + n = atrf_rx(dsc, buf, sizeof(buf), 0, &lqi); atrf_rx_mode(dsc, 0); if (n < 2) { diff --git a/tools/include/atrf.h b/tools/include/atrf.h index 4917a43..5472c46 100644 --- a/tools/include/atrf.h +++ b/tools/include/atrf.h @@ -60,7 +60,8 @@ int atrf_interrupt_wait(struct atrf_dsc *dsc, int timeout_ms); /* HardMAC operations */ void atrf_rx_mode(struct atrf_dsc *dsc, int on); -int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, uint8_t *lqi); +int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, int timeout_ms, + uint8_t *lqi); void atrf_tx(struct atrf_dsc *dsc, const void *buf, int size); #endif /* !ATRF_H */ diff --git a/tools/lib/atrf.c b/tools/lib/atrf.c index 1ea295a..55d1be3 100644 --- a/tools/lib/atrf.c +++ b/tools/lib/atrf.c @@ -1,8 +1,8 @@ /* * lib/atrf.c - ATRF access functions library * - * Written 2010-2011 by Werner Almesberger - * Copyright 2010-2011 Werner Almesberger + * Written 2010-2011, 2013 by Werner Almesberger + * Copyright 2010-2011, 2013 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -331,11 +331,12 @@ void atrf_rx_mode(struct atrf_dsc *dsc, int on) } -int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, uint8_t *lqi) +int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, int timeout_ms, + uint8_t *lqi) { if (!dsc->driver->rx) return 0; - return dsc->driver->rx(dsc->handle, buf, size, lqi); + return dsc->driver->rx(dsc->handle, buf, size, timeout_ms, lqi); } diff --git a/tools/lib/atusb-common.c b/tools/lib/atusb-common.c index 33a7b16..9102833 100644 --- a/tools/lib/atusb-common.c +++ b/tools/lib/atusb-common.c @@ -297,7 +297,7 @@ void atusb_rx_mode(void *handle, int on) } -int atusb_rx(void *handle, void *buf, int size, uint8_t *lqi) +int atusb_rx(void *handle, void *buf, int size, int timeout_ms, uint8_t *lqi) { struct atusb_dsc *dsc = handle; uint8_t len; @@ -309,7 +309,9 @@ int atusb_rx(void *handle, void *buf, int size, uint8_t *lqi) * read of size one followed by the full read. Therefore, we just do * a maximum-sized read and hope that we don't split packets. */ - res = usb_bulk_read(dsc->dev, 1, (char *) tmp, sizeof(tmp), 0); + res = usb_bulk_read(dsc->dev, 1, (char *) tmp, sizeof(tmp), timeout_ms); + if (res == -ETIMEDOUT) + return 0; if (res < 0) { fprintf(stderr, "usb_bulk_read: %d\n", res); dsc->error = 1; diff --git a/tools/lib/atusb-common.h b/tools/lib/atusb-common.h index 052ae59..817abad 100644 --- a/tools/lib/atusb-common.h +++ b/tools/lib/atusb-common.h @@ -1,8 +1,8 @@ /* * lib/atusb-common.h - ATUSB access functions shared by all ATUSB drivers * - * Written 2010-2011 by Werner Almesberger - * Copyright 2010-2011 Werner Almesberger + * Written 2010-2011, 2013 by Werner Almesberger + * Copyright 2010-2011, 2013 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ void atusb_test_mode(void *handle); void atusb_slp_tr(void *handle, int on, int pulse); int atusb_interrupt_wait(void *handle, int timeout_ms); void atusb_rx_mode(void *handle, int on); -int atusb_rx(void *handle, void *buf, int size, uint8_t *lqi); +int atusb_rx(void *handle, void *buf, int size, int timeout_ms, uint8_t *lqi); void atusb_tx(void *handle, const void *buf, int size); int atusb_set_clkm(void *handle, int mhz); diff --git a/tools/lib/driver.h b/tools/lib/driver.h index b07f2f7..589691a 100644 --- a/tools/lib/driver.h +++ b/tools/lib/driver.h @@ -1,8 +1,8 @@ /* * lib/driver.h - ATRF driver API * - * Written 2010-2011 by Werner Almesberger - * Copyright 2010-2011 Werner Almesberger + * Written 2010-2011, 2013 by Werner Almesberger + * Copyright 2010-2011, 2013 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ struct atrf_driver { uint8_t (*sram_read)(void *dsc, uint8_t addr); int (*interrupt_wait)(void *dsc, int timeout_ms); void (*rx_mode)(void *dsc, int on); - int (*rx)(void *dsc, void *buf, int size, uint8_t *lqi); + int (*rx)(void *dsc, void *buf, int size, int timeout_ms, uint8_t *lqi); void (*tx)(void *dsc, const void *buf, int size); };