From owner-svn-src-user@FreeBSD.ORG Sat Jun 23 04:47:42 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52F18106566C; Sat, 23 Jun 2012 04:47:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D4578FC0A; Sat, 23 Jun 2012 04:47:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5N4lgqu020017; Sat, 23 Jun 2012 04:47:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5N4lf3f020012; Sat, 23 Jun 2012 04:47:41 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201206230447.q5N4lf3f020012@svn.freebsd.org> From: Adrian Chadd Date: Sat, 23 Jun 2012 04:47:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237468 - user/adrian/ath_radar_stuff/src/qt-hpktlog X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 04:47:42 -0000 Author: adrian Date: Sat Jun 23 04:47:41 2012 New Revision: 237468 URL: http://svn.freebsd.org/changeset/base/237468 Log: * Migrate the pcap code to loop over the pcap if in live mode, rather than handling one every 2ms. * Move to using the QwtPlotSpectroCurve, which is an example (but does what I want, thankfully!) 3d plotting widget, which implements 'color' as the z dimension. * For now, just use RSSI as the z dimension. Eventually this should be the "density" rather than RSSI.. Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp ============================================================================== --- user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp Sat Jun 23 02:08:15 2012 (r237467) +++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp Sat Jun 23 04:47:41 2012 (r237468) @@ -5,6 +5,7 @@ #include "qwt_plot.h" #include "qwt_plot_curve.h" +#include "qwt_plot_spectrocurve.h" #include "qwt_plot_histogram.h" #include "qwt_symbol.h" @@ -35,9 +36,10 @@ MainApp::MainApp(QMainWindow *parent) q_symbol->setSize(2, 2); // And now, the default curve - q_curve = new QwtPlotCurve("curve"); - q_curve->setStyle(QwtPlotCurve::Dots); - q_curve->setSymbol(q_symbol); + q_curve = new QwtPlotSpectroCurve("curve"); + //q_curve->setStyle(QwtPlotCurve::Dots); + //q_curve->setSymbol(q_symbol); + q_curve->setPenWidth(4); q_curve->attach(q_plot); q_plot->show(); @@ -46,7 +48,13 @@ MainApp::MainApp(QMainWindow *parent) MainApp::~MainApp() { - /* XXX TIDYUP */ + /* XXX correct order? */ + if (q_symbol) + delete q_symbol; + if (q_curve) + delete q_curve; + if (q_plot) + delete q_plot; } // @@ -65,13 +73,19 @@ MainApp::getRadarEntry(struct radar_entr q_dur.insert(q_dur.begin(), (float) re.re_dur); q_rssi.insert(q_rssi.begin(), (float) re.re_rssi); + q_points.insert(q_points.begin(), + QwtPoint3D( + (float) re.re_dur, + (float) re.re_rssi, + (float) re.re_rssi * 25.0)); + // If we're too big, delete the first entry - if (q_dur.size() > num_entries) { + if (q_points.size() > num_entries) { q_dur.pop_back(); q_rssi.pop_back(); + q_points.pop_back(); } - // Trim the head entries if the array is too big // (maybe we should use a queue, not a vector?) @@ -83,7 +97,7 @@ void MainApp::RePlot() { // Plot them - q_curve->setSamples(&q_dur[0], &q_rssi[0], q_dur.size()); + q_curve->setSamples(q_points); /* Plot */ q_plot->replot(); Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h ============================================================================== --- user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h Sat Jun 23 02:08:15 2012 (r237467) +++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h Sat Jun 23 04:47:41 2012 (r237468) @@ -7,11 +7,14 @@ #include #include +#include #include "qwt_plot.h" #include "qwt_plot_curve.h" +#include "qwt_plot_spectrocurve.h" #include "qwt_plot_histogram.h" #include "qwt_symbol.h" +#include "qwt_point_3d.h" #include "libradarpkt/pkt.h" @@ -23,7 +26,7 @@ class MainApp : public QMainWindow // Why can't we just use references, rather than // pointers? QwtPlot *q_plot; - QwtPlotCurve *q_curve; + QwtPlotSpectroCurve *q_curve; QwtSymbol *q_symbol; // How many entries to keep in the histogram @@ -32,6 +35,7 @@ class MainApp : public QMainWindow // Our histogram data std::vector q_dur; std::vector q_rssi; + QVector q_points; // TODO When rendering the screen, we only want to do it // every say, 3ms. Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp ============================================================================== --- user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp Sat Jun 23 02:08:15 2012 (r237467) +++ user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp Sat Jun 23 04:47:41 2012 (r237468) @@ -41,6 +41,8 @@ PktSource::Load(const char *filename) //Kick-start the first timer! timerId = startTimer(1); + isLive = false; + return (true); } @@ -96,6 +98,7 @@ PktSource::OpenLive(const char *ifname) //Kick-start the first timer! timerId = startTimer(2); + isLive = true; return (true); @@ -127,64 +130,62 @@ PktSource::timerEvent(QTimerEvent *event // printf("%s: timer event!\n", __func__); - r = pcap_next_ex(PcapHdl, &hdr, &pkt); + while (1) { + r = pcap_next_ex(PcapHdl, &hdr, &pkt); - // Error? Delete the timer. - if (r < 0) { - killTimer(timerId); - timerId = -1; - printf("%s: final event (r=%d), finish timer!\n", - __func__, - r); - this->Close(); - return; + // Error? Delete the timer. + if (r < 0) { + killTimer(timerId); + timerId = -1; + printf("%s: final event (r=%d), finish timer!\n", + __func__, + r); + this->Close(); + return; + } + + // Nothing available? Just skip until the next + // check. + if (r == 0) + break; + + rt = (struct ieee80211_radiotap_header *) pkt; + if (rt->it_version != 0) { + printf("%s: unknown version (%d)\n", + __func__, + rt->it_version); + break; + } + + // TODO: just assume AR5416 for now.. + switch (chipid) { + case CHIP_AR5416: + r = ar5416_radar_decode(rt, + (pkt + le16toh(rt->it_len)), + hdr->caplen - le16toh(rt->it_len), &re); + break; + case CHIP_AR9280: + r = ar9280_radar_decode(rt, + (pkt + le16toh(rt->it_len)), + hdr->caplen - le16toh(rt->it_len), &re); + break; + default: + printf("%s: unknown chip id? (%d)\n", + __func__, + chipid); + } + + // Error? Skip to the next one. + if (r <= 0) { + printf("%s: parse failed\n", __func__); + } else { + // The actual event may be delayed; so i either have + // to pass a reference (not pointer), _or_ a copy. + emit emitRadarEntry(re); + } + + // Break out of the loop if we're not live + if (! isLive) + break; } - - // Nothing available? Just skip - if (r == 0) { - return; - } - - rt = (struct ieee80211_radiotap_header *) pkt; - if (rt->it_version != 0) { - printf("%s: unknown version (%d)\n", - __func__, - rt->it_version); - return; - } - - // TODO: just assume AR5416 for now.. - switch (chipid) { - case CHIP_AR5416: - r = ar5416_radar_decode(rt, - (pkt + le16toh(rt->it_len)), - hdr->caplen - le16toh(rt->it_len), &re); - break; - case CHIP_AR9280: - r = ar9280_radar_decode(rt, - (pkt + le16toh(rt->it_len)), - hdr->caplen - le16toh(rt->it_len), &re); - break; - default: - printf("%s: unknown chip id? (%d)\n", - __func__, - chipid); - } - // Error? Just wait for the next one? - if (r == 0) { - printf("%s: parse failed\n", __func__); - return; - } - -#if 0 - printf("%s: parsed: tsf=%llu, rssi=%d, dur=%d\n", - __func__, - (unsigned long long) re.re_timestamp, - re.re_rssi, - re.re_dur); -#endif - - // The actual event may be delayed; so i either have - // to pass a reference (not pointer), _or_ a copy. - emit emitRadarEntry(re); } Modified: user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h ============================================================================== --- user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h Sat Jun 23 02:08:15 2012 (r237467) +++ user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h Sat Jun 23 04:47:41 2012 (r237468) @@ -27,9 +27,12 @@ class PktSource : public QObject { pcap_t *PcapHdl; int timerId; int chipid; + bool isLive; public: - PktSource() : PcapHdl(NULL), timerId(-1), chipid(0) { }; + PktSource() : PcapHdl(NULL), timerId(-1), chipid(0), + isLive(false) { }; + ~PktSource(); void SetChipId(int chip_id) { chipid = chip_id; }; int GetChipId() { return (chipid); };