mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-23 01:07:31 +02:00
atrf-path: added min/max values and corrected averaging algorithm
- atrf-path.c (rssi_to_dBm, sample): moved RSSI value to dBm conversion to separate function - atrf-path.c (sample): corrected calculation of average - atrf-path.c (sample): also output minimum and maximum value - plot: new option -e to display extremal values - plot: added comment to explain y range
This commit is contained in:
parent
a2e0e1d807
commit
b159e00316
@ -50,10 +50,17 @@ static void init_rx(struct atrf_dsc *dsc, int trim, int chan)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static double rssi_to_dBm(double rssi)
|
||||||
|
{
|
||||||
|
return -91+3*(rssi-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void sample(struct atrf_dsc *tx, struct atrf_dsc *rx, int trim_tx,
|
static void sample(struct atrf_dsc *tx, struct atrf_dsc *rx, int trim_tx,
|
||||||
int power, int chan, int cont_tx, int samples)
|
int power, int chan, int cont_tx, int samples)
|
||||||
{
|
{
|
||||||
int i, rssi = 0;
|
int i, rssi;
|
||||||
|
int sum = 0, min = -1, max = -1;
|
||||||
double offset = tx_power_step2dBm(tx, power);
|
double offset = tx_power_step2dBm(tx, power);
|
||||||
|
|
||||||
init_tx(tx, trim_tx, power, chan);
|
init_tx(tx, trim_tx, power, chan);
|
||||||
@ -67,14 +74,20 @@ static void sample(struct atrf_dsc *tx, struct atrf_dsc *rx, int trim_tx,
|
|||||||
/* according to 8.3.2, PHY_RSSI is updated every 2 us */
|
/* according to 8.3.2, PHY_RSSI is updated every 2 us */
|
||||||
usleep(2);
|
usleep(2);
|
||||||
|
|
||||||
rssi += atrf_reg_read(rx, REG_PHY_RSSI) & RSSI_MASK;
|
rssi = atrf_reg_read(rx, REG_PHY_RSSI) & RSSI_MASK;
|
||||||
|
sum += rssi;
|
||||||
|
if (min == -1 || rssi < min)
|
||||||
|
min = rssi;
|
||||||
|
if (rssi > max)
|
||||||
|
max = rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_test_end(tx);
|
cw_test_end(tx);
|
||||||
|
|
||||||
printf("%.1f %.1f\n",
|
printf("%.1f %.2f %.0f %.0f\n",
|
||||||
2350+5*chan+(cont_tx == CONT_TX_M500K ? -0.5 : 0.5),
|
2350+5*chan+(cont_tx == CONT_TX_M500K ? -0.5 : 0.5),
|
||||||
-91+3*(rssi-1.0)/samples-offset);
|
rssi_to_dBm((double) sum/samples)-offset,
|
||||||
|
rssi_to_dBm(min)-offset, rssi_to_dBm(max)-offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,11 +2,18 @@
|
|||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
echo "usage: file ..." 1>&2
|
echo "usage: [-e] file ..." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
style=lines
|
||||||
|
if [ "$1" = -e ]; then
|
||||||
|
style=errorlines
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
[ "$1" ] || usage
|
[ "$1" ] || usage
|
||||||
|
|
||||||
files=
|
files=
|
||||||
while [ "$1" ]; do
|
while [ "$1" ]; do
|
||||||
[ "$files" ] && files="$files, "
|
[ "$files" ] && files="$files, "
|
||||||
@ -15,9 +22,12 @@ while [ "$1" ]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
gnuplot -persist <<EOF
|
gnuplot -persist <<EOF
|
||||||
|
# the y range is not entirely correct - we have RSSI in [-94, -10], and
|
||||||
|
# TX in [-17, 3], so the theoretically possible range would be [-97, 7].
|
||||||
set yrange [-94:-10]
|
set yrange [-94:-10]
|
||||||
set ylabel "RX-TX power (dBm)"
|
set ylabel "RX-TX power (dBm)"
|
||||||
set xlabel "Frequency (MHz)"
|
set xlabel "Frequency (MHz)"
|
||||||
set style data lines
|
set bars small
|
||||||
|
set style data $style
|
||||||
plot $files
|
plot $files
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user