1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-22 14:10:37 +02:00

tools/: add timeout_ms argument to atrf_rx

This commit is contained in:
Werner Almesberger 2013-02-12 16:19:09 -03:00
parent 125cc6ad9f
commit 8ac87a3fa1
6 changed files with 18 additions and 14 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);
};