From 4d4e132f0a4462edeff644a37a33d946aee1f256 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 9 Jun 2011 21:08:14 -0300 Subject: [PATCH] atrf-xmit: tightened checking of interrupt behaviour - atrf-xmit.c (xfer_one): also check that also the sender has no pending interrupts before we start sending - atrf-xmit.c (xfer_one): interrupt poll loop (now disabled) checked the sender, not the receiver. oops. - atrf-xmit.c (xfer_one): upon reception, check that the sender has finished (IRQ_TRX_END) as well --- tools/atrf-xmit/atrf-xmit.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/atrf-xmit/atrf-xmit.c b/tools/atrf-xmit/atrf-xmit.c index af57e42..f286ffc 100644 --- a/tools/atrf-xmit/atrf-xmit.c +++ b/tools/atrf-xmit/atrf-xmit.c @@ -72,6 +72,10 @@ static int xfer_one(struct atrf_dsc *tx, struct atrf_dsc *rx) uint8_t buf[PSDU_SIZE+1]; /* +1 for LQI */ int n, i; + if (atrf_interrupt(tx)) { + fprintf(stderr, "unexpected sender interrupt\n"); + exit(1); + } if (atrf_interrupt(rx)) { fprintf(stderr, "unexpected receiver interrupt\n"); exit(1); @@ -87,10 +91,21 @@ static int xfer_one(struct atrf_dsc *tx, struct atrf_dsc *rx) * interrupt, at least for now. */ usleep(5000); - irq = atrf_reg_read(tx, REG_IRQ_STATUS); + irq = atrf_reg_read(rx, REG_IRQ_STATUS); #endif if (!(irq & IRQ_TRX_END)) return 0; + + if (!atrf_interrupt(tx)) { + fprintf(stderr, "missing sender interrupt\n"); + exit(1); + } + irq = atrf_reg_read(tx, REG_IRQ_STATUS); + if (!(irq & IRQ_TRX_END)) { + fprintf(stderr, "sender claims packet was not sent ?\n"); + exit(1); + } + if (atrf_reg_read(rx, REG_PHY_RSSI) & RX_CRC_VALID) return 1; n = atrf_buf_read(rx, buf, sizeof(buf));