From 907527a7f98461bdaeb5ad5ca4460c64dd5f466e Mon Sep 17 00:00:00 2001 From: Hannes Matuschek Date: Wed, 3 Jun 2015 18:40:26 +0200 Subject: [PATCH] Cleanup --- examples/sdr_ax25.cc | 41 +++++++++++++++++++++++++++++++++++++++++ src/aprs.cc | 9 +++------ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 examples/sdr_ax25.cc diff --git a/examples/sdr_ax25.cc b/examples/sdr_ax25.cc new file mode 100644 index 0000000..9350ba1 --- /dev/null +++ b/examples/sdr_ax25.cc @@ -0,0 +1,41 @@ +#include "wavfile.hh" +#include "autocast.hh" +#include "interpolate.hh" +#include "fsk.hh" +#include "aprs.hh" +#include "utils.hh" + + +using namespace sdr; + + + +int main(int argc, char *argv[]) { + if (2 > argc) { std::cout << "USAGE: sdr_afsk1200 FILENAME" << std::endl; return -1; } + + sdr::Logger::get().addHandler( + new sdr::StreamLogHandler(std::cerr, sdr::LOG_DEBUG)); + + Queue &queue = Queue::get(); + + WavSource src(argv[1], 1024); + if (! src.isOpen()) { std::cout << "Can not open file " << argv[1] << std::endl; return -1; } + + AutoCast< int16_t > cast; + FSKDetector demod(1200, 1200, 2200); + BitStream bits(1200, BitStream::TRANSITION); + APRS decode; + + src.connect(&cast); + cast.connect(&demod); + demod.connect(&bits); + bits.connect(&decode); + + Queue::get().addIdle(&src, &WavSource::next); + src.addEOS(&queue, &Queue::stop); + + Queue::get().start(); + Queue::get().wait(); + + return 0; +} diff --git a/src/aprs.cc b/src/aprs.cc index f182caa..242255d 100644 --- a/src/aprs.cc +++ b/src/aprs.cc @@ -140,12 +140,8 @@ APRS::Message::Message(const AX25::Message &msg) return; } - if (_hasTime) { - if (! _readTime(offset)) { return; } - } - if (_hasLocation) { - if (! _readLocation(offset)) { return; } - } + if (_hasTime && (! _readTime(offset))) { _hasTime = false; _hasLocation = false; return; } + if (_hasLocation && (! _readLocation(offset))) { _hasLocation = false; return; } // Remaining text is comment if (offset < _payload.size()) { _comment = _payload.substr(offset); @@ -153,6 +149,7 @@ APRS::Message::Message(const AX25::Message &msg) } } + bool APRS::Message::_readLocation(size_t &offset) { // Read latitude