Date:2013-02-12 20:19:09 (6 years 5 months ago)
Author:Werner Almesberger
Commit:8ac87a3fa132a42dad3f27490313f865c46c9117
Message:tools/: add timeout_ms argument to atrf_rx

Files: tools/atrf-txrx/atrf-txrx.c (1 diff)
tools/include/atrf.h (1 diff)
tools/lib/atrf.c (2 diffs)
tools/lib/atusb-common.c (2 diffs)
tools/lib/atusb-common.h (2 diffs)
tools/lib/driver.h (2 diffs)

Change Details

tools/atrf-txrx/atrf-txrx.c
299299    int n, i;
300300
301301    atrf_rx_mode(dsc, 1);
302    n = atrf_rx(dsc, buf, sizeof(buf), &lqi);
302    n = atrf_rx(dsc, buf, sizeof(buf), 0, &lqi);
303303    atrf_rx_mode(dsc, 0);
304304
305305    if (n < 2) {
tools/include/atrf.h
6060/* HardMAC operations */
6161
6262void atrf_rx_mode(struct atrf_dsc *dsc, int on);
63int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, uint8_t *lqi);
63int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, int timeout_ms,
64    uint8_t *lqi);
6465void atrf_tx(struct atrf_dsc *dsc, const void *buf, int size);
6566
6667#endif /* !ATRF_H */
tools/lib/atrf.c
11/*
22 * lib/atrf.c - ATRF access functions library
33 *
4 * Written 2010-2011 by Werner Almesberger
5 * Copyright 2010-2011 Werner Almesberger
4 * Written 2010-2011, 2013 by Werner Almesberger
5 * Copyright 2010-2011, 2013 Werner Almesberger
66 *
77 * This program is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
...... 
331331}
332332
333333
334int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, uint8_t *lqi)
334int atrf_rx(struct atrf_dsc *dsc, void *buf, int size, int timeout_ms,
335    uint8_t *lqi)
335336{
336337    if (!dsc->driver->rx)
337338        return 0;
338    return dsc->driver->rx(dsc->handle, buf, size, lqi);
339    return dsc->driver->rx(dsc->handle, buf, size, timeout_ms, lqi);
339340}
340341
341342
tools/lib/atusb-common.c
297297}
298298
299299
300int atusb_rx(void *handle, void *buf, int size, uint8_t *lqi)
300int atusb_rx(void *handle, void *buf, int size, int timeout_ms, uint8_t *lqi)
301301{
302302    struct atusb_dsc *dsc = handle;
303303    uint8_t len;
...... 
309309     * read of size one followed by the full read. Therefore, we just do
310310     * a maximum-sized read and hope that we don't split packets.
311311     */
312    res = usb_bulk_read(dsc->dev, 1, (char *) tmp, sizeof(tmp), 0);
312    res = usb_bulk_read(dsc->dev, 1, (char *) tmp, sizeof(tmp), timeout_ms);
313    if (res == -ETIMEDOUT)
314        return 0;
313315    if (res < 0) {
314316        fprintf(stderr, "usb_bulk_read: %d\n", res);
315317        dsc->error = 1;
tools/lib/atusb-common.h
11/*
22 * lib/atusb-common.h - ATUSB access functions shared by all ATUSB drivers
33 *
4 * Written 2010-2011 by Werner Almesberger
5 * Copyright 2010-2011 Werner Almesberger
4 * Written 2010-2011, 2013 by Werner Almesberger
5 * Copyright 2010-2011, 2013 Werner Almesberger
66 *
77 * This program is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
...... 
3535void atusb_slp_tr(void *handle, int on, int pulse);
3636int atusb_interrupt_wait(void *handle, int timeout_ms);
3737void atusb_rx_mode(void *handle, int on);
38int atusb_rx(void *handle, void *buf, int size, uint8_t *lqi);
38int atusb_rx(void *handle, void *buf, int size, int timeout_ms, uint8_t *lqi);
3939void atusb_tx(void *handle, const void *buf, int size);
4040
4141int atusb_set_clkm(void *handle, int mhz);
tools/lib/driver.h
11/*
22 * lib/driver.h - ATRF driver API
33 *
4 * Written 2010-2011 by Werner Almesberger
5 * Copyright 2010-2011 Werner Almesberger
4 * Written 2010-2011, 2013 by Werner Almesberger
5 * Copyright 2010-2011, 2013 Werner Almesberger
66 *
77 * This program is free software; you can redistribute it and/or modify
88 * it under the terms of the GNU General Public License as published by
...... 
3737    uint8_t (*sram_read)(void *dsc, uint8_t addr);
3838    int (*interrupt_wait)(void *dsc, int timeout_ms);
3939    void (*rx_mode)(void *dsc, int on);
40    int (*rx)(void *dsc, void *buf, int size, uint8_t *lqi);
40    int (*rx)(void *dsc, void *buf, int size, int timeout_ms, uint8_t *lqi);
4141    void (*tx)(void *dsc, const void *buf, int size);
4242};
4343

Archive Download the corresponding diff file



interactive