From a7d9dfd258fc9da71d23e96df0ab9470b19acce9 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 13 Apr 2011 14:17:01 -0300 Subject: [PATCH] atrf-path.c: do cw test setup only once if sweeping a single offset atrf-path -T +0.5 -g ... 10 10 time: before: 0.32-0.33 s after: 0.27-0.29 s (88%) - atrf-path.c (sample): force cw test setup if never done before - atrf-path.c (do_half_sweep): only request cw test setup if sweeping both offsets --- tools/atrf-path/atrf-path.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/atrf-path/atrf-path.c b/tools/atrf-path/atrf-path.c index aec0b38..d121f54 100644 --- a/tools/atrf-path/atrf-path.c +++ b/tools/atrf-path/atrf-path.c @@ -68,6 +68,7 @@ static double rssi_to_dBm(double rssi) static void sample(const struct sweep *sweep, int cont_tx, struct sample *res, int first) { + static int need_init = 1; int i, rssi; int sum = 0, min = -1, max = -1; double offset = tx_power_step2dBm(sweep->tx, sweep->power); @@ -80,10 +81,12 @@ static void sample(const struct sweep *sweep, int cont_tx, * set_channel(sweep->tx, chan); * usleep(155); / * table 7-2, tTR19 * / */ - if (first) + if (first || need_init) { cw_test_begin(sweep->tx, cont_tx); - else + need_init = 0; + } else { cw_test_resume(sweep->tx); + } /* table 7-1, tTR10, doubling since it's a "typical" value */ usleep(2*16); @@ -119,7 +122,7 @@ static void do_half_sweep(const struct sweep *sweep, int cont_tx, set_channel(sweep->tx, chan); usleep(155); /* table 7-2, tTR19 */ - sample(sweep, cont_tx, res, chan == 11); + sample(sweep, cont_tx, res, chan == 11 && !sweep->cont_tx); res += 2; } }