svn commit: r237437 - user/adrian/ath_radar_stuff/src/qt-hpktlog
Adrian Chadd
adrian at FreeBSD.org
Fri Jun 22 07:53:42 UTC 2012
Author: adrian
Date: Fri Jun 22 07:53:41 2012
New Revision: 237437
URL: http://svn.freebsd.org/changeset/base/237437
Log:
This is tonight's hack - a time-series version of the scatterplot.
Right now this just plots data points from an existing pcap and inserts a
1ms delay in there.
Don't take this as any example of good C++ (new() ? Really?), nor good
QT4. I'm a very big novice. However, as a basic proof of concept, this
is actually working.
Added:
user/adrian/ath_radar_stuff/src/qt-hpktlog/
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/Makefile
user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp
user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h
user/adrian/ath_radar_stuff/src/qt-hpktlog/main.c
user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp
user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.cpp Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,91 @@
+#include <QtGui/QWidget>
+#include <QtGui/QFileDialog>
+#include <QtGui/QMessageBox>
+#include <QtGui/QMainWindow>
+
+#include "qwt_plot.h"
+#include "qwt_plot_curve.h"
+#include "qwt_plot_histogram.h"
+#include "qwt_symbol.h"
+
+#include "MainApp.h"
+
+MainApp::MainApp(QMainWindow *parent)
+{
+
+ // How many entries to keep in the FIFO
+ num_entries = 128;
+
+ // Create window
+ q_plot = new QwtPlot(QwtText("example"));
+ q_plot->setTitle("Example");
+
+ // Default size
+ q_plot->setGeometry(0, 0, 640, 400);
+
+ // Scale
+ // y-scale?
+ q_plot->setAxisScale(QwtPlot::xBottom, 0.0, 256.0);
+ q_plot->setAxisScale(QwtPlot::yLeft, -128.0, 128.0);
+
+ // The default is a single 1 pixel dot.
+ // This makes it very difficult to see.
+ q_symbol = new QwtSymbol();
+ q_symbol->setStyle(QwtSymbol::Cross);
+ 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->attach(q_plot);
+
+ q_plot->show();
+}
+
+MainApp::~MainApp()
+{
+
+ /* XXX TIDYUP */
+}
+
+//
+// This causes the radar entry to get received and replotted.
+// It's quite possible we should just fire off a 1ms timer event
+// _after_ this occurs, in case we get squeezed a whole set of
+// radar entries. Noone will notice if we only update every 1ms,
+// right?
+void
+MainApp::getRadarEntry(struct radar_entry re)
+{
+
+ //printf("%s: called!\n", __func__);
+
+ // Add it to the start duration/rssi array
+ q_dur.insert(q_dur.begin(), (float) re.re_dur);
+ q_rssi.insert(q_rssi.begin(), (float) re.re_rssi);
+
+ // If we're too big, delete the first entry
+ if (q_dur.size() > num_entries) {
+ q_dur.pop_back();
+ q_rssi.pop_back();
+ }
+
+
+ // Trim the head entries if the array is too big
+ // (maybe we should use a queue, not a vector?)
+
+ // Replot!
+ RePlot();
+}
+
+void
+MainApp::RePlot()
+{
+ // Plot them
+ q_curve->setSamples(&q_dur[0], &q_rssi[0], q_dur.size());
+
+ /* Plot */
+ q_plot->replot();
+ q_plot->show();
+}
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/MainApp.h Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,46 @@
+#ifndef __MAINAPP_H__
+#define __MAINAPP_H__
+
+#include <vector>
+
+#include <pcap.h>
+
+#include <QtCore/QObject>
+#include <QtGui/QMainWindow>
+
+#include "qwt_plot.h"
+#include "qwt_plot_curve.h"
+#include "qwt_plot_histogram.h"
+#include "qwt_symbol.h"
+
+#include "libradarpkt/pkt.h"
+
+class MainApp : public QMainWindow
+{
+ Q_OBJECT
+
+ private:
+ // Why can't we just use references, rather than
+ // pointers?
+ QwtPlot *q_plot;
+ QwtPlotCurve *q_curve;
+ QwtSymbol *q_symbol;
+
+ // How many entries to keep in the histogram
+ size_t num_entries;
+
+ // Our histogram data
+ std::vector<double> q_dur;
+ std::vector<double> q_rssi;
+
+ public:
+ MainApp(QMainWindow *parent = 0);
+ ~MainApp();
+ void RePlot();
+
+ public slots:
+ void getRadarEntry(struct radar_entry re);
+
+};
+
+#endif /* __MAINAPP_H__ */
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/Makefile Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,229 @@
+#############################################################################
+# Makefile for building: qt-hpktlog
+# Generated by qmake (2.01a) (Qt 4.7.4) on: Fri Jun 22 00:53:09 2012
+# Project: qt-hpktlog.pro
+# Template: app
+# Command: /usr/local/bin/qmake-qt4 -o Makefile qt-hpktlog.pro
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS = -pipe -O2 -Wall -W $(DEFINES)
+CXXFLAGS = -pipe -O2 -Wall -W $(DEFINES)
+INCPATH = -I/usr/local/share/qt4/mkspecs/freebsd-g++ -I. -I/usr/local/include/qt4/QtCore -I/usr/local/include/qt4/QtGui -I/usr/local/include/qt4 -I. -I../../lib -I/usr/local/include/qt4 -I/usr/local/include/qwt6 -I. -I/usr/local/include/qt4 -I/usr/local/include
+LINK = g++
+LFLAGS = -Wl,-O1 -pthread -Wl,-rpath,/usr/local/lib/qt4
+LIBS = $(SUBLIBS) -L/usr/local/lib/qt4 -L/usr/local/lib -L../../lib/libradarpkt -lpcap -lradarpkt -lqwt6 -lQtGui -L/usr/local/lib -L/usr/local/lib/qt4 -lQtCore
+AR = ar cqs
+RANLIB =
+QMAKE = /usr/local/bin/qmake-qt4
+TAR = tar -cf
+COMPRESS = gzip -9f
+COPY = cp -f
+SED = sed
+COPY_FILE = $(COPY)
+COPY_DIR = $(COPY) -R
+STRIP =
+INSTALL_FILE = $(COPY_FILE)
+INSTALL_DIR = $(COPY_DIR)
+INSTALL_PROGRAM = $(COPY_FILE)
+DEL_FILE = rm -f
+SYMLINK = ln -f -s
+DEL_DIR = rmdir
+MOVE = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR = mkdir -p
+
+####### Output directory
+
+OBJECTS_DIR = ./
+
+####### Files
+
+SOURCES = MainApp.cpp \
+ PktSource.cpp \
+ main.cpp moc_MainApp.cpp \
+ moc_PktSource.cpp
+OBJECTS = MainApp.o \
+ PktSource.o \
+ main.o \
+ moc_MainApp.o \
+ moc_PktSource.o
+DIST = /usr/local/share/qt4/mkspecs/common/g++.conf \
+ /usr/local/share/qt4/mkspecs/common/unix.conf \
+ /usr/local/share/qt4/mkspecs/qconfig.pri \
+ /usr/local/share/qt4/mkspecs/modules/qt_phonon.pri \
+ /usr/local/share/qt4/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/share/qt4/mkspecs/features/qt_functions.prf \
+ /usr/local/share/qt4/mkspecs/features/qt_config.prf \
+ /usr/local/share/qt4/mkspecs/features/exclusive_builds.prf \
+ /usr/local/share/qt4/mkspecs/features/default_pre.prf \
+ /usr/local/share/qt4/mkspecs/features/release.prf \
+ /usr/local/share/qt4/mkspecs/features/default_post.prf \
+ /usr/local/share/qt4/mkspecs/features/unix/thread.prf \
+ /usr/local/share/qt4/mkspecs/features/warn_on.prf \
+ /usr/local/share/qt4/mkspecs/features/qt.prf \
+ /usr/local/share/qt4/mkspecs/features/moc.prf \
+ /usr/local/share/qt4/mkspecs/features/resources.prf \
+ /usr/local/share/qt4/mkspecs/features/uic.prf \
+ /usr/local/share/qt4/mkspecs/features/yacc.prf \
+ /usr/local/share/qt4/mkspecs/features/lex.prf \
+ /usr/local/share/qt4/mkspecs/features/include_source_dir.prf \
+ qt-hpktlog.pro
+QMAKE_TARGET = qt-hpktlog
+DESTDIR =
+TARGET = qt-hpktlog
+
+first: all
+####### Implicit rules
+
+.SUFFIXES: .o .c .cpp .cc .cxx .C
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
+
+####### Build rules
+
+all: Makefile $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
+
+Makefile: qt-hpktlog.pro /usr/local/share/qt4/mkspecs/freebsd-g++/qmake.conf /usr/local/share/qt4/mkspecs/common/g++.conf \
+ /usr/local/share/qt4/mkspecs/common/unix.conf \
+ /usr/local/share/qt4/mkspecs/qconfig.pri \
+ /usr/local/share/qt4/mkspecs/modules/qt_phonon.pri \
+ /usr/local/share/qt4/mkspecs/modules/qt_webkit_version.pri \
+ /usr/local/share/qt4/mkspecs/features/qt_functions.prf \
+ /usr/local/share/qt4/mkspecs/features/qt_config.prf \
+ /usr/local/share/qt4/mkspecs/features/exclusive_builds.prf \
+ /usr/local/share/qt4/mkspecs/features/default_pre.prf \
+ /usr/local/share/qt4/mkspecs/features/release.prf \
+ /usr/local/share/qt4/mkspecs/features/default_post.prf \
+ /usr/local/share/qt4/mkspecs/features/unix/thread.prf \
+ /usr/local/share/qt4/mkspecs/features/warn_on.prf \
+ /usr/local/share/qt4/mkspecs/features/qt.prf \
+ /usr/local/share/qt4/mkspecs/features/moc.prf \
+ /usr/local/share/qt4/mkspecs/features/resources.prf \
+ /usr/local/share/qt4/mkspecs/features/uic.prf \
+ /usr/local/share/qt4/mkspecs/features/yacc.prf \
+ /usr/local/share/qt4/mkspecs/features/lex.prf \
+ /usr/local/share/qt4/mkspecs/features/include_source_dir.prf \
+ /usr/local/lib/qt4/libQtGui.prl \
+ /usr/local/lib/qt4/libQtCore.prl
+ $(QMAKE) -o Makefile qt-hpktlog.pro
+/usr/local/share/qt4/mkspecs/common/g++.conf:
+/usr/local/share/qt4/mkspecs/common/unix.conf:
+/usr/local/share/qt4/mkspecs/qconfig.pri:
+/usr/local/share/qt4/mkspecs/modules/qt_phonon.pri:
+/usr/local/share/qt4/mkspecs/modules/qt_webkit_version.pri:
+/usr/local/share/qt4/mkspecs/features/qt_functions.prf:
+/usr/local/share/qt4/mkspecs/features/qt_config.prf:
+/usr/local/share/qt4/mkspecs/features/exclusive_builds.prf:
+/usr/local/share/qt4/mkspecs/features/default_pre.prf:
+/usr/local/share/qt4/mkspecs/features/release.prf:
+/usr/local/share/qt4/mkspecs/features/default_post.prf:
+/usr/local/share/qt4/mkspecs/features/unix/thread.prf:
+/usr/local/share/qt4/mkspecs/features/warn_on.prf:
+/usr/local/share/qt4/mkspecs/features/qt.prf:
+/usr/local/share/qt4/mkspecs/features/moc.prf:
+/usr/local/share/qt4/mkspecs/features/resources.prf:
+/usr/local/share/qt4/mkspecs/features/uic.prf:
+/usr/local/share/qt4/mkspecs/features/yacc.prf:
+/usr/local/share/qt4/mkspecs/features/lex.prf:
+/usr/local/share/qt4/mkspecs/features/include_source_dir.prf:
+/usr/local/lib/qt4/libQtGui.prl:
+/usr/local/lib/qt4/libQtCore.prl:
+qmake: FORCE
+ @$(QMAKE) -o Makefile qt-hpktlog.pro
+
+dist:
+ @$(CHK_DIR_EXISTS) .tmp/qt-hpktlog1.0.0 || $(MKDIR) .tmp/qt-hpktlog1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qt-hpktlog1.0.0/ && $(COPY_FILE) --parents MainApp.h PktSource.h .tmp/qt-hpktlog1.0.0/ && $(COPY_FILE) --parents MainApp.cpp PktSource.cpp main.cpp .tmp/qt-hpktlog1.0.0/ && (cd `dirname .tmp/qt-hpktlog1.0.0` && $(TAR) qt-hpktlog1.0.0.tar qt-hpktlog1.0.0 && $(COMPRESS) qt-hpktlog1.0.0.tar) && $(MOVE) `dirname .tmp/qt-hpktlog1.0.0`/qt-hpktlog1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qt-hpktlog1.0.0
+
+
+clean:compiler_clean
+ -$(DEL_FILE) $(OBJECTS)
+ -$(DEL_FILE) *~ core *.core
+
+
+####### Sub-libraries
+
+distclean: clean
+ -$(DEL_FILE) $(TARGET)
+ -$(DEL_FILE) Makefile
+
+
+check: first
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: moc_MainApp.cpp moc_PktSource.cpp
+compiler_moc_header_clean:
+ -$(DEL_FILE) moc_MainApp.cpp moc_PktSource.cpp
+moc_MainApp.cpp: MainApp.h
+ /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) MainApp.h -o moc_MainApp.cpp
+
+moc_PktSource.cpp: PktSource.h
+ /usr/local/bin/moc-qt4 $(DEFINES) $(INCPATH) PktSource.h -o moc_PktSource.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+ -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean
+
+####### Compile
+
+MainApp.o: MainApp.cpp MainApp.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o MainApp.o MainApp.cpp
+
+PktSource.o: PktSource.cpp PktSource.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o PktSource.o PktSource.cpp
+
+main.o: main.cpp MainApp.h \
+ PktSource.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
+
+moc_MainApp.o: moc_MainApp.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_MainApp.o moc_MainApp.cpp
+
+moc_PktSource.o: moc_PktSource.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_PktSource.o moc_PktSource.cpp
+
+####### Install
+
+install: FORCE
+
+uninstall: FORCE
+
+FORCE:
+
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.cpp Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,109 @@
+
+#include <pcap.h>
+#include <sys/endian.h>
+
+#include "net80211/ieee80211_radiotap.h"
+
+#include "PktSource.h"
+
+#include "libradarpkt/pkt.h"
+#include "libradarpkt/ar5416_radar.h"
+
+PktSource::~PktSource()
+{
+
+ this->Close();
+}
+
+bool
+PktSource::Load(const char *filename)
+{
+ char errbuf[PCAP_ERRBUF_SIZE];
+
+ this->Close();
+
+ PcapHdl = pcap_open_offline(filename, errbuf);
+
+ if (PcapHdl == NULL)
+ return (false);
+
+ // TODO: turn this into a method
+ if (timerId != -1)
+ killTimer(timerId);
+
+ //Kick-start the first timer!
+ timerId = startTimer(1);
+
+ return (true);
+}
+
+void
+PktSource::Close()
+{
+
+ if (PcapHdl != NULL) {
+ pcap_close(PcapHdl);
+ PcapHdl = NULL;
+ }
+}
+
+// Periodically read some more frames and pass them up as events.
+// Right now this reads one event.
+// Eventually it should pace the events based on their timestamps.
+void
+PktSource::timerEvent(QTimerEvent *event)
+{
+ int r;
+ struct pcap_pkthdr *hdr;
+ unsigned const char *pkt;
+ struct ieee80211_radiotap_header *rt;
+ struct radar_entry re;
+
+// printf("%s: timer event!\n", __func__);
+
+ r = pcap_next_ex(PcapHdl, &hdr, &pkt);
+
+ // Error? Delete the timer.
+ // TODO: this should handle the "error/EOF" versus "none just for now,
+ // but more are coming" errors correctly!
+ if (r <= 0) {
+ killTimer(timerId);
+ timerId = -1;
+ printf("%s: final event (r=%d), finish timer!\n",
+ __func__,
+ r);
+ this->Close();
+ 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..
+ r = ar5416_radar_decode(rt,
+ (pkt + le16toh(rt->it_len)),
+ hdr->caplen - le16toh(rt->it_len), &re);
+
+ // 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);
+}
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/PktSource.h Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,43 @@
+#ifndef __PKTSOURCE_H__
+#define __PKTSOURCE_H__
+
+#include <QtCore/QObject>
+#include <QtCore/QTimerEvent>
+
+#include <pcap.h>
+
+#include "libradarpkt/pkt.h"
+
+//
+// This class provides a source of packet events.
+//
+// It's designed to be a base class for a packet source;
+// this may include (say) a live pcap source, or a recorded
+// pcap with timer events to "pace" how frequently the events
+// come in.
+//
+// This class requires some destination to send each pcap entry
+// to.
+//
+class PktSource : public QObject {
+
+ Q_OBJECT
+
+ private:
+ pcap_t *PcapHdl;
+ int timerId;
+
+ public:
+ PktSource() : PcapHdl(NULL), timerId(-1) { };
+ ~PktSource();
+ bool Load(const char *filename);
+ void Close();
+
+ signals:
+ void emitRadarEntry(struct radar_entry re);
+
+ protected:
+ void timerEvent(QTimerEvent *event);
+};
+
+#endif /* __PKTSOURCE_H__ */
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/main.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/main.c Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,53 @@
+
+static pcap_t *
+open_online(const char *ifname)
+{
+ pcap_t *p;
+ char errbuf[PCAP_ERRBUF_SIZE];
+ struct bpf_program fp;
+
+ p = pcap_open_live(ifname, 65536, 1, 1000, errbuf);
+ if (! p) {
+ err(1, "pcap_create: %s\n", errbuf);
+ return (NULL);
+ }
+
+ if (pcap_set_datalink(p, DLT_IEEE802_11_RADIO) != 0) {
+ pcap_perror(p, "pcap_set_datalink");
+ return (NULL);
+ }
+
+ /* XXX pcap_is_swapped() ? */
+
+ if (! pkt_compile(p, &fp)) {
+ pcap_perror(p, "pkg_compile compile error\n");
+ return (NULL);
+ }
+
+ if (pcap_setfilter(p, &fp) != 0) {
+ printf("pcap_setfilter failed\n");
+ return (NULL);
+ }
+
+ return (p);
+}
+
+{
+ /*
+ * Iterate over frames, looking for radiotap frames
+ * which have PHY errors.
+ *
+ * XXX We should compile a filter for this, but the
+ * XXX access method is a non-standard hack atm.
+ */
+ while ((r = pcap_next_ex(p, &hdr, &pkt)) >= 0) {
+#if 0
+ printf("capture: len=%d, caplen=%d\n",
+ hdr->len, hdr->caplen);
+#endif
+ if (r > 0)
+ pkt_handle(chip, pkt, hdr->caplen);
+ }
+
+ pcap_close(p);
+}
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/main.cpp Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,123 @@
+#include <QtGui/QApplication>
+#include <QtGui/QMainWindow>
+#include <QtGui/QWidget>
+
+#include <pcap.h>
+#include <err.h>
+
+#include "qwt_plot.h"
+#include "qwt_plot_curve.h"
+#include "qwt_plot_histogram.h"
+#include "qwt_symbol.h"
+
+#include "libradarpkt/pkt.h"
+#include "libradarpkt/ar5416_radar.h"
+#include "libradarpkt/ar9280_radar.h"
+
+
+#include "MainApp.h"
+#include "PktSource.h"
+
+#if 0
+/*
+ * XXX eww, using pointers rather than references.
+ */
+void
+plotSet(QwtPlot *p, PktLogData *pl)
+{
+ QwtPlotCurve *c = new QwtPlotCurve("curve");
+ QwtSymbol *s = new QwtSymbol();
+ std::vector<double> dur;
+ std::vector<double> rssi;
+
+ // The default is a single 1 pixel dot.
+ // This makes it very difficult to see.
+ s->setStyle(QwtSymbol::Cross);
+ s->setSize(2, 2);
+
+ p->setTitle("Example");
+
+ //p->setAutoLegend(true);
+ //p->setLegendPos(Qwt::Bottom);
+
+ // Curve Plot - dots, == scatterplot
+ c->setStyle(QwtPlotCurve::Dots);
+ // And set the symbol type, a default dot is not really
+ // all that helpful.
+ c->setSymbol(s);
+
+ /* Load in values */
+ dur = pl->GetDuration();
+ rssi = pl->GetRssi();
+// for (int i = 0; i < dur.size(); i++)
+// printf("%d: dur=%f, rssi=%f\n", i, dur[i], rssi[i]);
+
+ printf("dur size=%d, rssi size=%d\n", dur.size(), rssi.size());
+
+ // Plot them
+ c->setSamples(&dur[0], &rssi[0], dur.size());
+ c->attach(p);
+
+ /* Plot */
+ p->replot();
+ p->show();
+}
+#endif
+
+//
+
+static void
+usage()
+{
+ printf("usage: <ar5416|ar9280> <ifname>\n");
+ exit(127);
+}
+
+int
+main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ PktSource ps;
+ MainApp m;
+
+ int type = 0;
+
+ if (argc < 3)
+ usage();
+
+ if (strcmp(argv[1], "ar5416")== 0)
+ type = CHIP_AR5416;
+ else if (strcmp(argv[1], "ar9280")== 0)
+ type = CHIP_AR9280;
+ else
+ usage();
+
+ // Connect the ps source -> mainapp handler
+ QObject::connect(&ps, SIGNAL(emitRadarEntry(struct radar_entry)),
+ &m, SLOT(getRadarEntry(struct radar_entry)));
+
+ // Now that it's connected, begin firing off events
+ // by opening a file
+ if (ps.Load(argv[2]) == false) {
+ err(1, "open");
+ }
+
+#if 0
+ pr.LoadPcapOffline(argv[2], type);
+
+ QwtPlot plot(QwtText("example"));
+
+ // Default size
+ plot.setGeometry(0, 0, 640, 400);
+
+ // Scale
+ plot.setAxisScale(QwtPlot::xBottom, 0.0, 256.0);
+
+ plotSet(&plot, &pr);
+#endif
+
+ // Show main application window
+ m.show();
+
+ return a.exec();
+}
Added: user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/adrian/ath_radar_stuff/src/qt-hpktlog/qt-hpktlog.pro Fri Jun 22 07:53:41 2012 (r237437)
@@ -0,0 +1,14 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Tue Feb 14 14:16:07 2012
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += . ../../lib/ /usr/local/include/qt4 /usr/local/include/qwt6
+LIBS+= -L../../lib/libradarpkt -lpcap -lradarpkt -lqwt6
+
+# Input
+HEADERS += MainApp.h PktSource.h
+# FORMS += PlotWindow.ui MainWindow.ui
+SOURCES += MainApp.cpp PktSource.cpp main.cpp
More information about the svn-src-user
mailing list