SWIG magic to work on member functions. Can change sample rate on the fly now.uplink
parent
1630e67c3b
commit
a528f375f7
@ -1,54 +0,0 @@
|
||||
/*
|
||||
# Copyright 2010 Nick Foster
|
||||
#
|
||||
# This file is part of gr-air-modes
|
||||
#
|
||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# gr-air-modes is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_AIR_MODES_int_and_dump_H
|
||||
#define INCLUDED_AIR_MODES_int_and_dump_H
|
||||
|
||||
#include <gr_block.h>
|
||||
|
||||
class air_modes_int_and_dump;
|
||||
typedef boost::shared_ptr<air_modes_int_and_dump> air_modes_int_and_dump_sptr;
|
||||
|
||||
air_modes_int_and_dump_sptr air_make_modes_int_and_dump(int samples_per_chip);
|
||||
|
||||
/*!
|
||||
* \brief mode select int_and_dump filter
|
||||
* \ingroup block
|
||||
*/
|
||||
class air_modes_int_and_dump : public gr_block
|
||||
{
|
||||
private:
|
||||
friend air_modes_int_and_dump_sptr air_make_modes_int_and_dump(int samples_per_chip);
|
||||
air_modes_int_and_dump(int samples_per_chip);
|
||||
|
||||
int d_samples_per_chip;
|
||||
float d_acc;
|
||||
float d_pos;
|
||||
|
||||
public:
|
||||
int general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_AIR_MODES_int_and_dump_H */
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
# Copyright 2010 Nick Foster
|
||||
#
|
||||
# This file is part of gr-air-modes
|
||||
#
|
||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# gr-air-modes is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_AIR_MODES_PREAMBLE_H
|
||||
#define INCLUDED_AIR_MODES_PREAMBLE_H
|
||||
|
||||
#include <gnuradio/block.h>
|
||||
#include <air_modes_api.h>
|
||||
|
||||
class air_modes_preamble;
|
||||
typedef boost::shared_ptr<air_modes_preamble> air_modes_preamble_sptr;
|
||||
|
||||
AIR_MODES_API air_modes_preamble_sptr air_make_modes_preamble(int channel_rate, float threshold_db);
|
||||
|
||||
/*!
|
||||
* \brief mode select preamble detection
|
||||
* \ingroup block
|
||||
*/
|
||||
class AIR_MODES_API air_modes_preamble : public gr::block
|
||||
{
|
||||
private:
|
||||
friend air_modes_preamble_sptr air_make_modes_preamble(int channel_rate, float threshold_db);
|
||||
air_modes_preamble(int channel_rate, float threshold_db);
|
||||
|
||||
int d_check_width;
|
||||
int d_chip_rate;
|
||||
float d_preamble_length_us;
|
||||
int d_samples_per_chip;
|
||||
int d_samples_per_symbol;
|
||||
float d_threshold_db;
|
||||
float d_threshold;
|
||||
pmt::pmt_t d_me, d_key;
|
||||
gr::tag_t d_timestamp;
|
||||
double d_secs_per_sample;
|
||||
|
||||
public:
|
||||
int general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
void set_rate(int channel_rate);
|
||||
void set_threshold(float threshold_db);
|
||||
float get_threshold(void);
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_AIR_MODES_PREAMBLE_H */
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
# Copyright 2013 Nick Foster
|
||||
#
|
||||
# This file is part of gr-air-modes
|
||||
#
|
||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# gr-air-modes is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_AIR_MODES_PREAMBLE_H
|
||||
#define INCLUDED_AIR_MODES_PREAMBLE_H
|
||||
|
||||
#include <gnuradio/block.h>
|
||||
#include <gr_air_modes/api.h>
|
||||
|
||||
namespace gr {
|
||||
namespace air_modes {
|
||||
|
||||
/*!
|
||||
* \brief mode select preamble detection
|
||||
* \ingroup block
|
||||
*/
|
||||
class AIR_MODES_API preamble : virtual public gr::block
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<preamble> sptr;
|
||||
static sptr make(int channel_rate, float threshold_db);
|
||||
|
||||
virtual void set_rate(int channel_rate) = 0;
|
||||
virtual void set_threshold(float threshold_db) = 0;
|
||||
virtual int get_rate(void) = 0;
|
||||
virtual float get_threshold(void) = 0;
|
||||
};
|
||||
|
||||
} // namespace air_modes
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_AIR_MODES_PREAMBLE_H */
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
# Copyright 2013 Nick Foster
|
||||
#
|
||||
# This file is part of gr-air-modes
|
||||
#
|
||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# gr-air-modes is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_AIR_MODES_SLICER_H
|
||||
#define INCLUDED_AIR_MODES_SLICER_H
|
||||
|
||||
#include <gnuradio/block.h>
|
||||
#include <gr_air_modes/api.h>
|
||||
#include <gnuradio/msg_queue.h>
|
||||
|
||||
namespace gr {
|
||||
namespace air_modes {
|
||||
|
||||
/*!
|
||||
* \brief mode select slicer
|
||||
* \ingroup block
|
||||
*/
|
||||
class AIR_MODES_API slicer : virtual public gr::sync_block
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<slicer> sptr;
|
||||
static sptr make(gr::msg_queue::sptr queue);
|
||||
};
|
||||
|
||||
} //namespace air_modes
|
||||
} //namespace gr
|
||||
|
||||
#endif /* INCLUDED_AIR_MODES_SLICER_H */
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
# Copyright 2010 Nick Foster
|
||||
#
|
||||
# This file is part of gr-air-modes
|
||||
#
|
||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# gr-air-modes is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <air_modes_int_and_dump.h>
|
||||
#include <gr_io_signature.h>
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
||||
air_modes_int_and_dump_sptr air_make_modes_int_and_dump(int samples_per_symbol)
|
||||
{
|
||||
return air_modes_int_and_dump_sptr (new air_modes_int_and_dump(samples_per_symbol));
|
||||
}
|
||||
|
||||
air_modes_int_and_dump::air_modes_int_and_dump(int samps_per_chip) :
|
||||
gr_block ("modes_int_and_dump",
|
||||
gr_make_io_signature (1, 1, sizeof(float)),
|
||||
gr_make_io_signature (1, 1, sizeof(float)))
|
||||
{
|
||||
d_samples_per_symbol = samples_per_symbol;
|
||||
set_output_multiple(d_samples_per_symbol);
|
||||
set_history(d_samples_per_symbol);
|
||||
|
||||
d_acc = 0;
|
||||
d_pos = 0;
|
||||
}
|
||||
|
||||
int air_modes_int_and_dump::general_work(int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const float *in = (const float *) input_items[0];
|
||||
float *out = (float *) output_items[0];
|
||||
|
||||
int input_items = std::min(ninput_items[0], ninput_items[1]); //just in case
|
||||
|
||||
//ok first of all we look for "preamble_found" tags in our input range.
|
||||
//get a vector of these tags, then every time we hit one
|
||||
//reset the integrator position and accumulator
|
||||
std::vector<pmt::pmt_t> tags;
|
||||
uint64_t abs_sample_cnt = nitems_read(0);
|
||||
get_tags_in_range(tags, 0, abs_sample_cnt, abs_sample_cnt + ninput_items, pmt::pmt_string_to_symbol("preamble_found"));
|
||||
|
||||
int out_items = 0;
|
||||
|
||||
int offset = gr_tags::get_nitems(&tags[0]) - abs_sample_cnt;
|
||||
|
||||
for(int i=0; i<120*2; i++) { //for each symbol in a potential long packet
|
||||
out[out_items] = 0;
|
||||
for(int j=0; j<d_samples_per_symbol; j++) { //for each sample in the symbol
|
||||
out[out_items] += in[offset+i+j]; //integrate
|
||||
}
|
||||
out_items++;
|
||||
}
|
||||
|
||||
//insert tag here
|
||||
add_item_tag(0, //stream ID
|
||||
nitems_written(0), //sample number
|
||||
pmt::pmt_string_to_symbol("preamble_found");
|
||||
pmt::PMT_T,
|
||||
pmt::pmt_string_to_symbol(unique_id());
|
||||
);
|
||||
|
||||
consume_each(wat);
|
||||
return out_items;
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
|
||||
#ifndef _AIR_MODES_PREAMBLE_IMPL_H_
|
||||
#define _AIR_MODES_PREAMBLE_IMPL_H_
|
||||
|
||||
#include <gnuradio/block.h>
|
||||
#include <gr_air_modes/api.h>
|
||||
#include <gr_air_modes/preamble.h>
|
||||
|
||||
namespace gr {
|
||||
namespace air_modes {
|
||||
|
||||
class AIR_MODES_API preamble_impl : public preamble
|
||||
{
|
||||
private:
|
||||
int d_check_width;
|
||||
int d_chip_rate;
|
||||
float d_preamble_length_us;
|
||||
int d_samples_per_chip;
|
||||
int d_samples_per_symbol;
|
||||
float d_threshold_db;
|
||||
float d_threshold;
|
||||
pmt::pmt_t d_me, d_key;
|
||||
gr::tag_t d_timestamp;
|
||||
double d_secs_per_sample;
|
||||
|
||||
public:
|
||||
preamble_impl(int channel_rate, float threshold_db);
|
||||
|
||||
int general_work (int noutput_items,
|
||||
gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items);
|
||||
|
||||
void set_rate(int channel_rate);
|
||||
void set_threshold(float threshold_db);
|
||||
float get_threshold(void);
|
||||
int get_rate(void);
|
||||
};
|
||||
|
||||
} //namespace air_modes
|
||||
} //namespace gr
|
||||
|
||||
#endif //_AIR_MODES_PREAMBLE_IMPL_H_
|
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys, re
|
||||
|
||||
if __name__== '__main__':
|
||||
data = sys.stdin.readlines()
|
||||
icaos = []
|
||||
num_icaos = 0
|
||||
for line in data:
|
||||
match = re.match(".*from (\w+)", line)
|
||||
if match is not None:
|
||||
icao = int(match.group(1), 16)
|
||||
icaos.append(icao)
|
||||
|
||||
#get dupes
|
||||
dupes = sorted([icao for icao in set(icaos) if icaos.count(icao) > 1])
|
||||
for icao in dupes:
|
||||
print "%x" % icao
|
||||
print "Found non-unique replies from %i aircraft" % len(dupes)
|
||||
|
||||
|
@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2012 Nick Foster
|
||||
#
|
||||
# This file is part of gr-air-modes
|
||||
#
|
||||
# gr-air-modes is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# gr-air-modes is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gr-air-modes; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
#multilateration client
|
||||
#outputs stamps to server, receives multilaterated outputs back
|
||||
|
||||
import socket, pickle, time, sys
|
||||
import air_modes
|
||||
from gnuradio import gr
|
||||
|
||||
pickle_prot = 0
|
||||
#pickle_prot = pickle.HIGHEST_PROTOCOL
|
||||
|
||||
class client_info:
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
self.position = []
|
||||
self.offset_secs = 0
|
||||
self.offset_frac_secs = 0.0
|
||||
self.time_source = None
|
||||
|
||||
class mlat_client:
|
||||
def __init__(self, queue, position, server_addr, time_source):
|
||||
self._queue = queue
|
||||
self._pos = position
|
||||
self._name = socket.gethostname()
|
||||
#connect to server
|
||||
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self._sock.setblocking(1)
|
||||
self._sock.connect((server_addr, 19005))
|
||||
info = client_info()
|
||||
info.name = self._name
|
||||
info.position = self._pos
|
||||
info.time_source = time_source #"gpsdo" or None
|
||||
self._sock.send(pickle.dumps(info))
|
||||
reply = self._sock.recv(1024)
|
||||
if reply != "HELO": #i know, shut up
|
||||
raise Exception("Invalid reply from server: %s" % reply)
|
||||
self._sock.setblocking(0)
|
||||
self._remnant = None
|
||||
|
||||
def __del__(self):
|
||||
self._sock.close()
|
||||
|
||||
#send a stamped report to the server
|
||||
def output(self, message):
|
||||
self._sock.send(message+"\n")
|
||||
|
||||
#this is called from the update() method list of the main app thread
|
||||
def get_mlat_positions(self):
|
||||
msg = None
|
||||
try:
|
||||
msg = self._sock.recv(1024)
|
||||
except socket.error:
|
||||
pass
|
||||
if msg:
|
||||
for line in msg.splitlines(True):
|
||||
if line.endswith("\n"):
|
||||
if self._remnant:
|
||||
line = self._remnant + line
|
||||
self._remnant = None
|
||||
self._queue.insert_tail(gr.message_from_string(line))
|
||||
|
||||
else:
|
||||
if self._remnant is not None:
|
||||
raise Exception("Malformed data: " + line)
|
||||
else:
|
||||
self._remnant = line
|
@ -0,0 +1 @@
|
||||
|
@ -1,45 +1,17 @@
|
||||
/* -*- c++ -*- */
|
||||
|
||||
%include "gnuradio.i" // the common stuff
|
||||
#define AIR_MODES_API
|
||||
|
||||
%include "gnuradio.i"
|
||||
|
||||
%{
|
||||
#include "air_modes_preamble.h"
|
||||
#include "air_modes_slicer.h"
|
||||
#include <gnuradio/msg_queue.h>
|
||||
#include "gr_air_modes/preamble.h"
|
||||
#include "gr_air_modes/slicer.h"
|
||||
%}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* First arg is the package prefix.
|
||||
* Second arg is the name of the class minus the prefix.
|
||||
*
|
||||
* This does some behind-the-scenes magic so we can
|
||||
* access howto_square_ff from python as howto.square_ff
|
||||
*/
|
||||
GR_SWIG_BLOCK_MAGIC(air,modes_preamble);
|
||||
|
||||
air_modes_preamble_sptr air_make_modes_preamble (int channel_rate, float threshold_db);
|
||||
|
||||
class air_modes_preamble : public gr::sync_block
|
||||
{
|
||||
set_rate(int channel_rate);
|
||||
set_threshold(float threshold_db);
|
||||
int get_threshold(void);
|
||||
private:
|
||||
air_modes_preamble (int channel_rate, float threshold_db);
|
||||
};
|
||||
|
||||
GR_SWIG_BLOCK_MAGIC(air,modes_slicer);
|
||||
|
||||
air_modes_slicer_sptr air_make_modes_slicer (int channel_rate, gr::msg_queue::sptr queue);
|
||||
|
||||
class air_modes_slicer : public gr::block
|
||||
{
|
||||
set_rate(int channel_rate);
|
||||
private:
|
||||
air_modes_slicer (int channel_rate, gr::msg_queue::sptr queue);
|
||||
};
|
||||
%include "gr_air_modes/preamble.h"
|
||||
%include "gr_air_modes/slicer.h"
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
GR_SWIG_BLOCK_MAGIC2(air_modes,preamble);
|
||||
GR_SWIG_BLOCK_MAGIC2(air_modes,slicer);
|
||||
|
||||
|
Loading…
Reference in new issue