Date:2013-07-31 00:59:11 (6 years 3 months ago)
Author:Werner Almesberger
Commit:07b1da29ec94c00d52cd7c16a667c537e48a65e8
Message:tools/lib/: aggressive polling for wait_for_interrupt, if timeout_ms = -1

Files: tools/include/misctxrx.h (1 diff)
tools/lib/atben.c (3 diffs)
tools/lib/atusb-common.c (1 diff)
tools/lib/misctxrx.c (2 diffs)

Change Details

tools/include/misctxrx.h
1919
2020
2121void flush_interrupts(struct atrf_dsc *dsc);
22
23/*
24 * timeout_ms:
25 * > 0: time out after that many milliseconds
26 * == 0: wait forever
27 * < 0: wait forever and eliminate poll delays (for high-speed capture)
28 */
29
2230uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for,
2331    uint8_t ignore, int timeout_ms);
2432
tools/lib/atben.c
11/*
22 * lib/atben.c - ATRF access functions library (Ben 8:10 card version)
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
...... 
439439    int timedout = 0;
440440    uint8_t irq;
441441
442    if (timeout_ms)
442    if (timeout_ms > 0)
443443        timeout_start(&to, timeout_ms);
444444    while (1) {
445        if (timeout_ms)
445        if (timeout_ms > 0)
446446            timedout = timeout_reached(&to);
447447        if (atben_interrupt(handle)) {
448448            irq = atben_reg_read(handle, REG_IRQ_STATUS);
...... 
452452        }
453453        if (timedout)
454454            return 0;
455        usleep(1000);
455        if (timeout_ms >= 0)
456            usleep(1000);
456457    }
457458
458459    return 0;
tools/lib/atusb-common.c
221221        return 0;
222222
223223    res = usb_bulk_read(dsc->dev, 1,
224        (char *) &buf, sizeof(buf), timeout_ms);
224        (char *) &buf, sizeof(buf), timeout_ms < 0 : 0 : timeout_ms);
225225    if (res == -ETIMEDOUT)
226226        return 0;
227227    if (res < 0) {
tools/lib/misctxrx.c
6262
6363    sigint = 0;
6464    old_sig = signal(SIGINT, die);
65    if (timeout_ms) {
65    if (timeout_ms > 0) {
6666        if (timeout_ms < MIN_TIMEOUT_MS)
6767            timeout_ms = MIN_TIMEOUT_MS;
6868        timeout_start(&to, timeout_ms);
6969    }
7070    while (!sigint && !timedout) {
7171        while (!sigint && !timedout) {
72            if (timeout_ms) {
72            if (timeout_ms > 0) {
7373                ms = timeout_left_ms(&to);
7474                if (ms <= 0) {
7575                    timedout = 1;
...... 
7878            } else {
7979                ms = 0;
8080            }
81            irq = atrf_interrupt_wait(dsc, ms);
81            irq = atrf_interrupt_wait(dsc,
82                timeout_ms < 0 ? -1 : ms);
8283            if (irq)
8384                break;
8485        }

Archive Download the corresponding diff file



interactive