mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2025-04-21 12:27:27 +03: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:
@@ -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,
|
||||
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);
|
||||
|
||||
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 */
|
||||
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);
|
||||
|
||||
printf("%.1f %.1f\n",
|
||||
printf("%.1f %.2f %.0f %.0f\n",
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user