svn commit: r245173 - user/adrian/ath_radar_stuff/src/spectral_fft
Adrian Chadd
adrian at FreeBSD.org
Tue Jan 8 19:16:09 UTC 2013
Author: adrian
Date: Tue Jan 8 19:16:08 2013
New Revision: 245173
URL: http://svnweb.freebsd.org/changeset/base/245173
Log:
Convert this code over to use the dBm value rather than calculating
it in the draw loop.
This breaks the Linux decoder for now.
Modified:
user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c
user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h
user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c
Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c
==============================================================================
--- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 18:47:29 2013 (r245172)
+++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.c Tue Jan 8 19:16:08 2013 (r245173)
@@ -212,32 +212,21 @@ int draw_picture(int highlight, int star
rnum = 0;
- for (result = result_list; result ; result = result->next) {
- int datamax = 0, datamin = 65536;
- int datasquaresum = 0;
+ for (result = result_list; result ; result = result->next, rnum++) {
- for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) {
- int data;
-
- data = result->sample.data[i] * result->sample.data[i];
- datasquaresum += data;
- if (data > datamax) datamax = data;
- if (data < datamin) datamin = data;
- }
+ if (rnum != highlight)
+ continue;
if (rnum == highlight) {
/* prints some statistical data about the currently selected
* data sample and auxiliary data. */
- printf("result[%03d]: freq %04d rssi %03d, noise %03d, max_magnitude %04d max_index %03d bitmap_weight %03d tsf %llu | ",
+ printf("result[%03d]: freq %04d rssi %03d, noise %03d, max_magnitude %04d max_index %03d bitmap_weight %03d tsf %llu\n",
rnum, result->sample.freq, result->sample.rssi, result->sample.noise,
result->sample.max_magnitude, result->sample.max_index, result->sample.bitmap_weight,
result->sample.tsf);
- printf("datamax = %d, datamin = %d, datasquaresum = %d\n", datamax, datamin, datasquaresum);
-
highlight_freq = result->sample.freq;
}
-
for (i = 0; i < SPECTRAL_HT20_NUM_BINS; i++) {
float freq;
float signal;
@@ -249,10 +238,10 @@ int draw_picture(int highlight, int star
/* This is where the "magic" happens: interpret the signal
* to output some kind of data which looks useful. */
- data = result->sample.data[i];
- if (data == 0)
- data = 1;
- signal = result->sample.noise + result->sample.rssi + 20 * log10f(data) - log10f(datasquaresum) * 10;
+ signal = result->sample.data[i];
+ printf(" signal[%d]: %f\n", i, signal);
+ if (signal == 0)
+ signal = 1;
y = 400 - (400.0 + Y_SCALE * signal);
@@ -268,7 +257,6 @@ int draw_picture(int highlight, int star
continue;
}
- rnum++;
}
SDL_BlitSurface(surface, NULL, screen, NULL);
Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h
==============================================================================
--- user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h Tue Jan 8 18:47:29 2013 (r245172)
+++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_eval.h Tue Jan 8 19:16:08 2013 (r245173)
@@ -5,6 +5,7 @@ typedef int8_t s8;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint64_t u64;
+typedef int16_t s16;
/* taken from ath9k.h */
#define SPECTRAL_HT20_NUM_BINS 56
@@ -34,7 +35,7 @@ struct fft_sample_ht20 {
u64 tsf;
- u16 data[SPECTRAL_HT20_NUM_BINS];
+ s16 data[SPECTRAL_HT20_NUM_BINS];
} __attribute__((packed));
Modified: user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c
==============================================================================
--- user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Tue Jan 8 18:47:29 2013 (r245172)
+++ user/adrian/ath_radar_stuff/src/spectral_fft/fft_freebsd.c Tue Jan 8 19:16:08 2013 (r245173)
@@ -70,7 +70,7 @@ pkt_handle_single(struct radar_entry *re
result->sample.tsf = re->re_timestamp;
/* XXX 56 = numspectralbins */
for (j = 0; j < 56; j++) {
- result->sample.data[j] = re->re_spectral_entries[i].pri.bins[j].raw_mag;
+ result->sample.data[j] = re->re_spectral_entries[i].pri.bins[j].dBm;
}
/* add it to the list */
@@ -150,7 +150,7 @@ pkt_handle(int chip, const char *pkt, in
/* XXX do something about it */
if (r) {
- pkt_print(&re);
+ //pkt_print(&re);
pkt_handle_single(&re);
}
}
More information about the svn-src-user
mailing list