commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5897 - in gnuradio/branches/developers/wb1hbu/wip/gr-


From: wb1hbu
Subject: [Commit-gnuradio] r5897 - in gnuradio/branches/developers/wb1hbu/wip/gr-air/src: . lib python
Date: Tue, 3 Jul 2007 10:26:00 -0600 (MDT)

Author: wb1hbu
Date: 2007-07-03 10:25:59 -0600 (Tue, 03 Jul 2007)
New Revision: 5897

Added:
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/Makefile.am
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/Makefile.am
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air.i
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_attributes.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_consts.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_types.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.cc
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.h
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/Makefile.am
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/ppm_demod.py
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/qa_air.py
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/run_tests.in
   
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_mode_s_logfile.py
   gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_oscope_ms.py
Log:
Added missing files to initial Mode Select Receiver

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/Makefile.am
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/Makefile.am              
                (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/Makefile.am      
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,22 @@
+#
+# Copyright 2004 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio 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 2, or (at your option)
+# any later version.
+# 
+# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+SUBDIRS = lib python


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/Makefile.am
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/Makefile.am          
                (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/Makefile.am  
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,112 @@
+#
+# Copyright 2004, 2006, 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 2, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+# Install this stuff so that it ends up as the gnuradio.vocoder module
+# This usually ends up at:
+#   ${prefix}/lib/python${python_version}/site-packages/gnuradio
+
+ourpythondir = $(grpythondir)
+ourlibdir    = $(grpyexecdir)
+
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS)
+
+SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(STD_DEFINES_AND_INCLUDES)
+
+
+ALL_IFILES =                           \
+       $(LOCAL_IFILES)                 \
+       $(NON_LOCAL_IFILES)
+
+NON_LOCAL_IFILES =                     \
+       $(GNURADIO_I)
+
+
+LOCAL_IFILES =                                 \
+       $(top_srcdir)/gr-air/src/lib/air.i
+
+# These files are built by SWIG.  The first is the C++ glue.
+# The second is the python wrapper that loads the _howto shared library
+# and knows how to call our extensions.
+
+BUILT_SOURCES = \
+       air.cc  \
+       air.py
+
+# This gets air.py installed in the right place
+ourpython_PYTHON =     \
+       air.py
+
+ourlib_LTLIBRARIES = _air.la
+
+# These are the source files that go into the shared library
+_air_la_SOURCES = \
+    air.cc \
+    air_ms_pulse_detect.cc \
+    air_ms_preamble.cc \
+    air_ms_framer.cc \
+    air_ms_ppm_decode.cc \
+    air_ms_fmt_log.cc \
+    air_ms_cvt_float.cc \
+    air_ms_parity.cc \
+    air_ms_ec_brute.cc \
+    airi_ms_parity.cc \
+    # Additional source modules here
+
+
+# magic flags
+_air_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
+
+# link the library against the c++ standard library
+_air_la_LIBADD =       \
+       $(PYTHON_LDFLAGS)       \
+       $(GNURADIO_CORE_LA)     \
+       -lstdc++
+
+air.cc air.py: air.i $(ALL_IFILES)
+       $(SWIG) $(SWIGPYTHONARGS) -module air -o air.cc $(LOCAL_IFILES)
+
+# These headers get installed in ${prefix}/include/gnuradio
+grinclude_HEADERS =                    \
+    air_ms_types.h \
+    air_ms_pulse_detect.h \
+    air_ms_preamble.h \
+    air_ms_framer.h \
+    air_ms_ppm_decode.h \
+    air_ms_fmt_log.h \
+    air_ms_cvt_float.h \
+    air_ms_parity.h \
+    air_ms_ec_brute.h \
+    # Additional header files here
+
+# These swig headers get installed in ${prefix}/include/gnuradio/swig
+swiginclude_HEADERS =                  \
+       $(LOCAL_IFILES)
+
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc *~ *.tmp
+
+# Don't distribute output of swig
+dist-hook:
+       @for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done
+       @for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done
+


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/Makefile.am
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air.i
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air.i                
                (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air.i        
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+%feature("autodoc","1");
+%include "exception.i"
+%import "gnuradio.i"
+
+%{
+#include "gnuradio_swig_bug_workaround.h"      // mandatory bug fix
+#include "air_ms_pulse_detect.h"
+#include "air_ms_preamble.h"
+#include "air_ms_framer.h"
+#include "air_ms_ppm_decode.h"
+#include "air_ms_parity.h"
+#include "air_ms_ec_brute.h"
+#include "air_ms_fmt_log.h"
+#include "air_ms_cvt_float.h"
+#include <stdexcept>
+%}
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_pulse_detect);
+
+air_ms_pulse_detect_sptr air_make_ms_pulse_detect(float alpha, float beta, int 
width);
+
+class air_ms_pulse_detect : public gr_sync_block
+{
+private:
+    air_ms_pulse_detect(float alpha, float beta, int width);
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_preamble);
+
+air_ms_preamble_sptr air_make_ms_preamble(int channel_rate);
+
+class air_ms_preamble : public gr_sync_block
+{
+private:
+    air_ms_preamble(int channel_rate);
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_framer);
+
+air_ms_framer_sptr air_make_ms_framer(int channel_rate);
+
+class air_ms_framer : public gr_sync_block
+{
+private:
+    air_ms_framer(int channel_rate);
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_ppm_decode);
+
+air_ms_ppm_decode_sptr air_make_ms_ppm_decode(int channel_rate);
+
+class air_ms_ppm_decode : public gr_block
+{
+private:
+    air_ms_ppm_decode(int channel_rate);
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_parity);
+
+air_ms_parity_sptr air_make_ms_parity();
+
+class air_ms_parity : public gr_sync_block
+{
+private:
+    air_ms_parity();
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_ec_brute);
+
+air_ms_ec_brute_sptr air_make_ms_ec_brute();
+
+class air_ms_ec_brute : public gr_sync_block
+{
+private:
+    air_ms_ec_brute();
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_fmt_log);
+
+air_ms_fmt_log_sptr air_make_ms_fmt_log(int pass_all, gr_msg_queue_sptr queue);
+
+class air_ms_fmt_log : public gr_sync_block
+{
+private:
+    air_ms_fmt_log(int pass_all, gr_msg_queue_sptr queue);
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(air,ms_cvt_float);
+
+air_ms_cvt_float_sptr air_make_ms_cvt_float();
+
+class air_ms_cvt_float : public gr_sync_block
+{
+private:
+    air_ms_cvt_float();
+
+public:
+};


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air.i
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_attributes.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_attributes.h  
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_attributes.h  
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_ATTRIBUTES_H
+#define INCLUDED_AIR_MS_ATTRIBUTES_H
+
+// Attribute Codes
+
+const int MS_VALID_PULSE    = 0x10000000;  // Pulse is above threshold
+const int MS_LEADING_EDGE   = 0x20000000; // Pulse is above threshold with a 
good leading edge
+const int MS_PREAMBLE_START = 0x40000000;  // Start of Preamble or Frame
+const int MS_FRAME_END      = 0x80000000;  // Frame has ended
+const int MS_DATA_MASK      = 0x0FFFFFFF;  // Data passed downstream
+
+// Data Offsets from Preamble Start  (Used downstream from the framer)
+const int MS__OFFSET_REFERENCE = 0;   // Reference Level
+const int MS__OFFSET_COUNT_HIGH = 1;  // Sample Count High 16 bits
+const int MS__OFFSET_COUNT_LOW = 2;  // Sample Count Low 16 bits
+
+#endif /* INCLUDED_AIR_MS_ATTRIBUTES_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_attributes.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_consts.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_consts.h      
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_consts.h      
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_CONSTS_H
+#define INCLUDED_AIR_MS_CONSTS_H
+
+
+const int MS_SHORT_FRAME_LENGTH    =  56;  // Data length for short frame
+const int MS_LONG_FRAME_LENGTH     = 112;
+
+const int MS_DATA_RATE             = 1000000;
+const int MS_PREAMBLE_PULSE_COUNT  =   4;
+// Frame Times in microSeconds
+const int MS_PREAMBLE_TIME_US      =   8;
+const int MS_BIT_TIME_US           =   1;
+#endif /* INCLUDED_AIR_MS_CONSTS_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_consts.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.cc  
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.cc  
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,69 @@
+
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+/*
+Convert the data in pipeline info as floats so it can be displayed on the 
oscilloscope
+Also handle sample data so everything stays in sync.
+
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include <air_ms_types.h>
+#include <air_ms_cvt_float.h>
+
+air_ms_cvt_float_sptr air_make_ms_cvt_float()
+{
+    return air_ms_cvt_float_sptr(new air_ms_cvt_float());
+}
+
+air_ms_cvt_float::air_ms_cvt_float() :
+    gr_sync_block ("ms_cvt_float",
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)),
+                   gr_make_io_signature (3, 3, sizeof(float)))
+{
+    set_output_multiple(1);
+}
+
+
+int air_ms_cvt_float::work(int noutput_items,
+                          gr_vector_const_void_star &input_items,
+                         gr_vector_void_star &output_items)
+
+{
+    float *data_in = (float *)input_items[0];
+    ms_plinfo *attrib_in = (ms_plinfo *)input_items[1];
+    float *data_out = (float *) output_items[0];  // sample data out
+    float *ref_out = (float *) output_items[1];    // attribute data out
+    float *attrib_out = (float *) output_items[2];    // attribute data out
+
+    int size = noutput_items;
+    int i;
+    for (i = 0; i < size; i++)
+    {
+       data_out[i] = data_in[i]; // Direct Copy
+       ref_out[i] = attrib_in[i].reference();
+        attrib_out[i] = (float)attrib_in[i].flags() *-20.;  // Make it visible 
by inverting it
+    }
+    return i;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.h   
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.h   
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_CVT_FLOAT_H
+#define INCLUDED_AIR_MS_CVT_FLOAT_H
+
+#include <gr_sync_block.h>
+
+class air_ms_cvt_float;
+typedef boost::shared_ptr<air_ms_cvt_float> air_ms_cvt_float_sptr;
+
+air_ms_cvt_float_sptr air_make_ms_cvt_float();
+
+/*!
+ * \brief mode select convert to floats
+ * \ingroup block
+ */
+class air_ms_cvt_float : public gr_sync_block
+{
+private:
+    friend air_ms_cvt_float_sptr air_make_ms_cvt_float();
+    air_ms_cvt_float();
+
+
+public:
+    int work (int noutput_items,
+              gr_vector_const_void_star &input_items,
+              gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_CVT_FLOAT_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_cvt_float.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.cc   
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.cc   
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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_ms_ec_brute.h>
+#include <airi_ms_parity.h>
+#include <gr_io_signature.h>
+#include <air_ms_types.h>
+
+// The recommendation is to do a convervative error correction of 12 bits and 
a brute force of 5 bits.
+// The modern processor should be able to do 12 bits brute force :)
+const int MAX_EC_CORRECTION = 12;
+
+
+air_ms_ec_brute_sptr air_make_ms_ec_brute()
+{
+    return air_ms_ec_brute_sptr(new air_ms_ec_brute());
+}
+
+air_ms_ec_brute::air_ms_ec_brute() :
+    gr_sync_block("ms_ec_brute",
+       gr_make_io_signature(1, 1, sizeof(ms_frame_raw)),
+       gr_make_io_signature(1, 1, sizeof(ms_frame_raw)))
+{
+}
+
+int air_ms_ec_brute::work(int noutput_items,
+    gr_vector_const_void_star &input_items,
+    gr_vector_void_star &output_items)
+{
+    ms_frame_raw *data_in = (ms_frame_raw *)input_items[0];
+    ms_frame_raw *data_out = (ms_frame_raw *)output_items[0];
+
+    unsigned int error_syndrome = 0;
+    unsigned int crc;
+    int lcb_positions[MAX_EC_CORRECTION + 1];
+    int i, j, index;
+    int search_code;
+    int offset;
+    int found;
+    int correction = 0;
+    for (i = 0; i < noutput_items; i++) {
+       data_out[i] = data_in[i];
+       if((data_out[i].lcb_count() == 0) || (data_out[i].ec_quality() & 
(ms_frame_raw::crc_ok | ms_frame_raw::eq_ec_corrected)))
+               continue;  // Nothing to do so continue on
+        // The assumption is Mode A/C "Fruit" flipped some bits that were set 
as low confidence upstream.
+        // This will only work for ADS-B and ACAS/TCAS Frames as the address 
overlayed on the parity is zero.
+       if(data_out[i].lcb_count() <= MAX_EC_CORRECTION)
+       {
+               // Get the error
+               error_syndrome = ms_check_parity(data_out[i]);
+               index = 0;
+               found = 0;
+                // Offset into the parity table for short frames  The offsets 
are 0 for long frames and 56 for short frames
+               offset = MS_LONG_FRAME_LENGTH - data_out[i].length();
+               // Assume all bits need to be flipped so start at the high end
+               search_code = (1 << data_out[i].lcb_count()) - 1;
+               // Get the low confidence bits
+               lcb_positions[index++] = data_out[i].first_lcb();
+               for (j= data_out[i].first_lcb() + 1; j <= 
data_out[i].last_lcb();j++)
+               {
+                       if(data_out[i].flags(j))
+                       {
+                               lcb_positions[index++] =j;
+                       }
+               }
+               // Search down
+               // Zero code means no correction which at this point is not 
possible
+               while(search_code > 0)
+               {
+                       crc = 0;
+                       // Calculate the syndrome for the search code
+                       for(j = 0; j < index; j++)
+                       {
+                               if((search_code >> j) & 1)
+                                       crc ^= 
ms_parity_table[lcb_positions[j]+offset];
+                       }
+                       // A match
+                       if(crc == error_syndrome)
+                       {
+                               // Remember the correction
+                               correction = search_code;
+                               // If over one solution then it is no solution
+                               if(++found > 1)
+                                       break;
+                       }
+                       search_code--;
+               }
+               if(found == 1) // Only one valid solution
+               {
+                       // Flip the bits
+                       for(j = 0; j < index; j++)
+                       {
+                               if((correction >> j) & 1)
+                               {
+                                       
data_out[i].set_bit_flipped(lcb_positions[j]);
+                               }
+                       }
+                       // Correct the output
+                       crc = ms_check_parity(data_out[i]);
+                       data_out[i].set_address(crc);
+                       
data_out[i].set_ec_quality(ms_frame_raw::eq_ec_corrected);
+               }
+               else if(found > 1)  // Indicate multiple solutions
+                       
data_out[i].set_ec_quality(ms_frame_raw::eq_ec_multiple);
+               else  // Nothing can be done
+                       data_out[i].set_ec_quality(ms_frame_raw::eq_ec_na);
+
+
+       }
+       else  // Too many lcbs
+               data_out[i].set_ec_quality(ms_frame_raw::eq_ec_na);
+    }
+    return i;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.h    
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.h    
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_EC_BRUTE_H
+#define INCLUDED_AIR_MS_EC_BRUTE_H
+
+#include <gr_sync_block.h>
+
+class air_ms_ec_brute;
+typedef boost::shared_ptr<air_ms_ec_brute> air_ms_ec_brute_sptr;
+
+air_ms_ec_brute_sptr air_make_ms_ec_brute();
+
+/*!
+ * \brief Mode Select Error Correction Brute Force Style
+ * \ingroup block
+ */
+
+class air_ms_ec_brute : public gr_sync_block
+{
+private:
+    // Constructors
+    friend air_ms_ec_brute_sptr air_make_ms_ec_brute();
+    air_ms_ec_brute();
+
+
+public:
+    int work(int noutput_items,
+        gr_vector_const_void_star &input_items,
+        gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_MS_PARITY_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ec_brute.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.cc    
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.cc    
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+   Format Mode S frames in text format for logging.  It is possible to read
+   in the text log file and decode the frames by external programs
+
+Some typical lines and description
+008602b8                7be1c3  34.082 bd647bba 46897d33   0 00000001 00 a7502c
+008182b8                a3dc20  36.069 bd64f551 46897d33   0 00000001 00 a7502c
+8d4005a6 9904a194409f09 0cc9f2  33.959 bd6543dc 46897d33   0 00000001 17 000000
+Short    Extended       PI      Ref Lv TS       Time     LCB EC Qual  Ty Addr
+
+Short is the first 32 bits of the frame and represents the data portion of a 
short frame.
+
+Extended is not present in a short frame and represnets the extended data 
portion of a long frame.
+
+PI is the parity bits of both the short and long frames and represents the 
last 24 bits of a frame.
+
+Ref Lv is the Reference Level used and can be used as a RSSI.
+
+TS is the sample number.  It will roll over after a short period of time.  It 
represnets the preample
+   start sample and may be useful to determine short time differences between 
Mode S Frames.
+
+Time is the decode time using the unix time() function (Seconds since Jan 1, 
1970)  It represents when
+the whole frame was received and processed.  This may be useful for the 
standard 5 minute delay when sending
+information on the internet
+
+LCB is the number of Low Confidence Bits in the frame
+
+EC Qual is the bits indicating the Error Correction result (See air_ms_types.h)
+
+Ty is the first five bits of the frame in decimal format and represents the 
frame type.
+
+Addr is the overlayed address, error syndrome, or both depending on the frame 
type and errors
+
+A side effect of logging Mode S frames in a busy area is the megabytes of text 
data generated
+in a short period of time.
+
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <air_ms_fmt_log.h>
+#include <gr_io_signature.h>
+#include <air_ms_types.h>
+#include <ctype.h>
+#include <iostream>
+
+air_ms_fmt_log_sptr air_make_ms_fmt_log(int pass_all, gr_msg_queue_sptr queue)
+{
+    return air_ms_fmt_log_sptr(new air_ms_fmt_log(pass_all, queue));
+}
+
+air_ms_fmt_log::air_ms_fmt_log(int pass_all, gr_msg_queue_sptr queue) :
+    gr_sync_block("ms_fmt_log",
+       gr_make_io_signature(1, 1, sizeof(ms_frame_raw)),
+       gr_make_io_signature(0, 0, 0)),
+        d_queue(queue), d_pass_all(pass_all)
+{
+       d_count = 0;
+}
+
+int air_ms_fmt_log::work(int noutput_items,
+    gr_vector_const_void_star &input_items,
+    gr_vector_void_star &output_items)
+{
+    ms_frame_raw *data_in = (ms_frame_raw *)input_items[0];
+
+    int i;
+    for(i = 0;i < noutput_items; i++)
+    {
+        // If pass all or data good then send it out otherwise move on
+       if(d_pass_all || (data_in[i].ec_quality() & (ms_frame_raw::crc_ok | 
ms_frame_raw::eq_ec_corrected)))
+       {
+               format_data(data_in[i]);
+               d_count++;
+       }
+    }
+
+    return i;
+}
+
+
+void air_ms_fmt_log::format_data(ms_frame_raw &frame)
+{
+       int i;
+       int typecode = 0;
+       int data = 0;
+       int pi = 0;
+       for (i = 0; i < 5; i++)
+       {
+          typecode = (typecode << 1) + frame.bit(i);
+          data = (data << 1) + frame.bit(i);
+       }
+       for (i = 5; i < 32; i++)
+       {
+           data = (data << 1) + frame.bit(i);
+       }
+       d_payload.str("");
+       d_payload.width(8);
+       d_payload.fill('0');
+       d_payload << std::hex <<  data << FIELD_DELIM;
+       if(frame.length() >= MS_LONG_FRAME_LENGTH)
+       {
+               data = 0;
+               d_payload.width(7);
+               for (i = 32; i < 60; i++)
+               {
+                       data = (data << 1) + frame.bit(i);
+               }
+               d_payload << data;
+               data = 0;
+               d_payload.width(7);
+               for (i = 60; i < 88; i++)
+               {
+                       data = (data << 1) + frame.bit(i);
+               }
+               d_payload << data << FIELD_DELIM;
+               d_payload.width(6);
+               for (i = 88; i < MS_LONG_FRAME_LENGTH; i++)
+               {
+                       pi = (pi << 1) + frame.bit(i);
+               }
+               d_payload << pi << FIELD_DELIM;
+       }
+       else
+       {
+               for (i = 32; i < MS_SHORT_FRAME_LENGTH; i++)
+               {
+                       pi = (pi << 1) + frame.bit(i);
+               }
+               d_payload << FIELD_DELIM << "             " << FIELD_DELIM;
+               d_payload.width(6);
+               d_payload << pi << FIELD_DELIM;
+       }
+       d_payload.width(7);
+        d_payload.precision(5);
+       d_payload.fill(' ');
+       d_payload << std::dec << frame.reference() << FIELD_DELIM;
+       d_payload.width(8);
+       d_payload.fill('0');
+        d_payload << std::hex << frame.timestamp() << FIELD_DELIM << 
frame.rx_time() << FIELD_DELIM;
+       d_payload.width(3);
+       d_payload.fill(' ');
+        d_payload << std::dec << frame.lcb_count() << FIELD_DELIM;
+       d_payload.width(8);
+       d_payload.fill('0');
+        d_payload << std::hex << frame.ec_quality() << FIELD_DELIM;
+       d_payload.width(2);
+       d_payload << std::dec << typecode << FIELD_DELIM;
+       d_payload.width(6);
+        d_payload << std::hex << frame.address();
+       gr_message_sptr msg = 
gr_make_message_from_string(std::string(d_payload.str()));
+       d_queue->handle(msg);
+}
+


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.h     
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.h     
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006, 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_FMT_LOG_H
+#define INCLUDED_AIR_MS_FMT_LOG_H
+
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+#include <sstream>
+
+class air_ms_fmt_log;
+class ms_frame_raw;
+typedef boost::shared_ptr<air_ms_fmt_log> air_ms_fmt_log_sptr;
+
+air_ms_fmt_log_sptr air_make_ms_fmt_log(int pass_all, gr_msg_queue_sptr queue);
+
+/*!
+ * \brief Mode Select Log Formatter description
+ * \ingroup block
+ */
+
+#define FIELD_DELIM ((unsigned char)32)
+
+class air_ms_fmt_log : public gr_sync_block
+{
+private:
+    // Constructors
+    friend air_ms_fmt_log_sptr air_make_ms_fmt_log(int pass_all, 
gr_msg_queue_sptr queue);
+    air_ms_fmt_log(int pass_all, gr_msg_queue_sptr queue);
+
+    std::ostringstream d_payload;
+    gr_msg_queue_sptr d_queue;           // Destination for decoded mode S
+
+    int d_count;                         // Count of logged codewords
+    int d_pass_all;                      // Pass all frames if no zero
+    void format_data(ms_frame_raw &data);
+
+public:
+    int work(int noutput_items,
+        gr_vector_const_void_star &input_items,
+        gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_MS_FMT_LOG_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_fmt_log.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.cc     
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.cc     
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,197 @@
+
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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 <gr_io_signature.h>
+#include <air_ms_types.h>
+#include <air_ms_framer.h>
+
+air_ms_framer_sptr air_make_ms_framer(int channel_rate)
+{
+    return air_ms_framer_sptr(new air_ms_framer(channel_rate));
+}
+
+air_ms_framer::air_ms_framer(int channel_rate) :
+    gr_sync_block ("ms_framer",
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)),
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)))
+{
+    d_channel_rate = channel_rate;
+    d_reference = 0.0;
+    d_data_start = MS_PREAMBLE_TIME_US * channel_rate / 1000000;
+    d_bit_width = MS_BIT_TIME_US * channel_rate / 1000000;
+    d_chip_width = d_bit_width / 2;   // Two Chips per bit
+    d_min_frame_width =  (MS_PREAMBLE_TIME_US + MS_BIT_TIME_US * 
MS_SHORT_FRAME_LENGTH)* channel_rate / 1000000;
+    d_max_frame_width = (MS_PREAMBLE_TIME_US + MS_BIT_TIME_US * 
MS_LONG_FRAME_LENGTH)* channel_rate / 1000000;
+    d_var_n = (channel_rate > 8000000)?3:2;  // Number of bits after leading 
edge to sample
+    d_var_m = d_var_n + 1;
+
+    set_output_multiple(2*(d_max_frame_width+2));
+}
+
+
+int air_ms_framer::work(int noutput_items,
+                          gr_vector_const_void_star &input_items,
+                         gr_vector_void_star &output_items)
+
+{
+    float *data_in = (float *)input_items[0];
+    ms_plinfo *attrib_in = (ms_plinfo *)input_items[1];
+    float *data_out = (float *) output_items[0];  // sample data out
+    ms_plinfo   *attrib_out = (ms_plinfo *) output_items[1];    // attribute 
data out
+
+    int size = noutput_items - d_max_frame_width - 2; // Only search up to a 
frame from the end
+    int i, j, k;
+    int offset;
+    int frame_size;
+    float reference;
+    float high_limit;
+    float low_limit;
+    float max_level;
+    reference = 0.0;
+    for (i = 0; i < size; i++)
+    {
+       data_out[i] = data_in[i]; // Direct Copy
+        attrib_out[i] = attrib_in[i];
+       // Look for the start of the extended part of the frame
+       if(attrib_in[i].preamble_start())
+       {
+               // Calculate the reference and limits
+               reference = attrib_in[i].reference();
+                low_limit = reference * 0.5012;  // -6 dB
+               // There is a short 56 bit frame and a long 112 bit frame
+                // So figure out the frame size
+                // Assume maximum frame size
+               frame_size = d_max_frame_width;
+               // Do a similar DF Valid technique for bits 57 through 62
+               offset = i + d_min_frame_width;
+               for( j = 0; j < (5 * d_bit_width); j += d_bit_width)
+               {
+                       int chips;
+                       int leflag;
+                       int jj;
+                       max_level = 0.;
+                       chips = 0;
+                       leflag = 0;
+                       k = 0;
+                       if(attrib_in[offset+j].valid_pulse())
+                       {
+                               chips++;
+                               max_level = data_in[offset+j]; // init maximum 
level
+                               leflag = 1;
+                       }
+                       else // look at +/- 1 bit for valid pulse
+                       {
+                               for(k = -1; k < 2; k += 2)
+                               {
+                                       if(attrib_in[offset+j+k].valid_pulse())
+                                       {
+                                               chips++;
+                                               max_level = 
data_in[offset+j+k]; // init maximum level
+                                               leflag = 1;
+                                               break;
+                                       }
+                               }
+                       }
+                       if(leflag)
+                       {
+                               for(jj = 0; jj < d_var_m; jj++)
+                               {
+                                       if(data_in[offset+j+k+jj] > max_level)
+                                               max_level = 
data_in[offset+j+k+jj];
+                               }
+                       }
+                       // Look at the second chip now
+                       leflag = 0;
+                       k = d_chip_width;
+                       if(attrib_in[offset+j+k].valid_pulse())
+                       {
+                               chips++;
+                               max_level = data_in[offset+j+k]; // init 
maximum level
+                               leflag = 1;
+                       }
+                       else // look at +/- 1 bit for valid pulse
+                       {
+                               for(k = d_chip_width -1; k < d_chip_width+2; k 
+= 2)
+                               {
+                                       if(attrib_in[offset+j+k].valid_pulse())
+                                       {
+                                               chips++;
+                                               max_level = data_in[offset+j+k];
+                                               leflag = 1;
+                                               break;
+                                       }
+                               }
+                       }
+                       if(leflag)
+                       {
+                               for(jj = 0; jj < d_var_m; jj++)
+                               {
+                                       if(data_in[offset+j+k+jj] > max_level)
+                                               max_level = 
data_in[offset+j+k+jj];
+                               }
+                       }
+                       if ((chips == 0) || (max_level < low_limit))  // If no 
valid bits at 57 - 62 so 56 bit frame
+                       {
+                               frame_size = d_min_frame_width;
+                               break;
+                       }
+               }
+                // "Retrigger"  See if there is a preamble detected with a 
level that is more than 3 dB
+                //              in the frame.  If so ignore current frame and 
move on
+               high_limit = reference * 1.41253;  // + 3 dB
+                for (j = 1; j <= frame_size; j++)
+               {
+                       // Copy the frame data to output
+                       data_out[i+j] = data_in[i+j]; // Direct Copy
+                       attrib_out[i+j] = attrib_in[i+j];
+                        // If there is a preamble start see if it is + 3 dB 
stronger otherwise clear it
+                       if(attrib_in[i+j].preamble_start())
+                       {
+                               if (high_limit < attrib_in[i+j].reference())
+                               {
+                                       // Ignore current preamble and any 
preamble up to the stronger one
+                                       attrib_out[i].reset_preamble_start();
+                                       break;
+                               }
+                               else // Make downstream processing ignore any 
following preambles within frame size
+                               {
+                                       attrib_out[i+j].reset_preamble_start();
+                               }
+                       }
+                       attrib_out[i+j].set_reference(reference); // Keep 
setting the reference (mainly for scope display)
+               }
+                // If no stronger preamble in the frame then output
+                if(j > frame_size)
+               {
+                       attrib_out[i+d_data_start].set_data_start(reference);  
// denote the start of data and indicate reference again
+                       attrib_out[i+frame_size].set_data_end();  // denote the 
end
+               }
+                // point to the sample after the frame or the stronger preamble
+               i = i + j;
+       }
+    }
+    return i;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.h      
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.h      
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_FRAMER_H
+#define INCLUDED_AIR_MS_FRAMER_H
+
+#include <gr_sync_block.h>
+
+class air_ms_framer;
+typedef boost::shared_ptr<air_ms_framer> air_ms_framer_sptr;
+
+air_ms_framer_sptr air_make_ms_framer(int channel_rate);
+
+/*!
+ * \brief mode select framer
+ * \ingroup block
+ */
+class air_ms_framer : public gr_sync_block
+{
+private:
+    friend air_ms_framer_sptr air_make_ms_framer(int channel_rate);
+    air_ms_framer(int channel_rate);
+
+    float d_reference;   // current reference level
+    int d_channel_rate;  // Sample rate of the streams
+    int d_data_start;        // When the data starts in samples
+    int d_check_width;   // Width of Preamble checking in samples
+    int d_chip_width;    // Width of chip (1/2 bit time) in samples
+    int d_bit_width;     // Width of bit in samples
+    int d_var_n;         // Number of samples to use after a leading edge
+    int d_var_m;         // d_var_n plus trailing edge
+    int d_min_frame_width;  // length of short frame in samples
+    int d_max_frame_width;  // length of long frame in samples
+
+public:
+    int work (int noutput_items,
+              gr_vector_const_void_star &input_items,
+              gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_MS_FRAMER_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_framer.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.cc     
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.cc     
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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_ms_parity.h>
+#include <airi_ms_parity.h>
+#include <gr_io_signature.h>
+#include <air_ms_types.h>
+
+air_ms_parity_sptr air_make_ms_parity()
+{
+    return air_ms_parity_sptr(new air_ms_parity());
+}
+
+air_ms_parity::air_ms_parity() :
+    gr_sync_block("ms_parity",
+       gr_make_io_signature(1, 1, sizeof(ms_frame_raw)),
+       gr_make_io_signature(1, 1, sizeof(ms_frame_raw)))
+{
+}
+
+int air_ms_parity::work(int noutput_items,
+    gr_vector_const_void_star &input_items,
+    gr_vector_void_star &output_items)
+{
+    ms_frame_raw *data_in = (ms_frame_raw *)input_items[0];
+    ms_frame_raw *data_out = (ms_frame_raw *)output_items[0];
+
+    int crc = 0;
+    int i, j;
+    for (i = 0; i < noutput_items; i++) {
+       data_out[i] = data_in[i];
+        data_out[i].count_lcbs();
+       crc = ms_check_parity(data_out[i]);
+       data_out[i].set_address(crc);  // assume error syndrome is address 
overlay
+       // If the crc is good then we are done.  ACAS/TCAS Frames have a 
address of zero.
+       if(crc == 0)
+       {
+               data_out[i].set_ec_quality(ms_frame_raw::crc_ok);
+       }
+       else // if things are not good then do a few checks
+       {
+               if(data_out[i].length() == MS_LONG_FRAME_LENGTH)
+               {
+                       //See if the frame should be a short one so check if 
all low energy bits are in second half
+                       if ((data_out[i].lcb_count() >= MS_SHORT_FRAME_LENGTH) 
&& (data_out[i].first_leb() >= MS_SHORT_FRAME_LENGTH))
+                       {
+                               data_out[i].set_short_frame();
+                               crc = ms_check_parity(data_out[i]);
+                               data_out[i].set_address(crc);  // assume error 
syndrome is address overlay
+                                data_out[i].count_lcbs();
+                               if(crc == 0)  // address is zero (ACAS/TCAS)
+                               {
+                                       
data_out[i].set_ec_quality((ms_frame_raw::crc_ok|ms_frame_raw::eq_change_short_frame));
+                               }
+                               else if(data_out[i].lcb_count())
+                               {
+                                       
data_out[i].set_ec_quality((ms_frame_raw::crc_bad|ms_frame_raw::eq_change_short_frame));
+                               }
+                               else // assume it is a crc with address overlay
+                               {
+                                       
data_out[i].set_ec_quality((ms_frame_raw::crc_ok|ms_frame_raw::eq_change_short_frame));
+                               }
+                               continue;
+                       }
+                       else
+                       {
+                                       // Check for a too short of frame  If 
no parity at all say it is a short frame
+                                       data_out[i].set_address(crc);
+                                       for(j = MS_LONG_FRAME_LENGTH - 1; j > 
(MS_LONG_FRAME_LENGTH - 25); j--)
+                                       {
+                                               if(data_out[i].flags(j) == 
ms_frame_raw::fl_high_confidence)
+                                                       break;
+                                       }
+                                       if(j == (MS_LONG_FRAME_LENGTH - 25))
+                                       {
+                                               
data_out[i].set_ec_quality(ms_frame_raw::eq_too_short_frame);
+                                               continue;
+
+                                       }
+                       }
+               }
+               else
+               {
+                       // Check for a too short of frame  If no parity at all 
say it is a short frame
+                       data_out[i].set_address(crc);
+                       for(j = MS_SHORT_FRAME_LENGTH - 1; j > 
(MS_SHORT_FRAME_LENGTH - 25); j--)
+                       {
+                               if(data_out[i].flags(j) == 
ms_frame_raw::fl_high_confidence)
+                                       break;
+                       }
+                       if((MS_SHORT_FRAME_LENGTH - 25))
+                       {
+                               
data_out[i].set_ec_quality(ms_frame_raw::eq_too_short_frame);
+                               continue;
+                       }
+               }
+               // If low confidence bits then it is bad
+               if(data_out[i].lcb_count())
+               {
+                       data_out[i].set_ec_quality(ms_frame_raw::crc_bad);
+               }
+               else // assume it is a crc with address overlay
+               {
+                       data_out[i].set_ec_quality(ms_frame_raw::crc_ok);
+               }
+       }
+    }
+    return i;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.h      
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.h      
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_PARITY_H
+#define INCLUDED_AIR_MS_PARITY_H
+
+#include <gr_sync_block.h>
+
+class air_ms_parity;
+typedef boost::shared_ptr<air_ms_parity> air_ms_parity_sptr;
+
+air_ms_parity_sptr air_make_ms_parity();
+
+/*!
+ * \brief Mode Select Parity Check
+ * \ingroup block
+ */
+
+class air_ms_parity : public gr_sync_block
+{
+private:
+    // Constructors
+    friend air_ms_parity_sptr air_make_ms_parity();
+    air_ms_parity();
+
+public:
+    int work(int noutput_items,
+        gr_vector_const_void_star &input_items,
+        gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_MS_PARITY_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_parity.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.cc 
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.cc 
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,229 @@
+
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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 <gr_io_signature.h>
+#include <air_ms_types.h>
+#include <air_ms_ppm_decode.h>
+
+air_ms_ppm_decode_sptr air_make_ms_ppm_decode(int channel_rate)
+{
+    return air_ms_ppm_decode_sptr(new air_ms_ppm_decode(channel_rate));
+}
+
+air_ms_ppm_decode::air_ms_ppm_decode(int channel_rate) :
+    gr_block ("ms_ppm_decode",
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)),
+                   gr_make_io_signature (1, 1, sizeof(ms_frame_raw)))
+{
+    d_channel_rate = channel_rate;
+    d_reference = 0.0;
+    d_high_limit = 0.0;
+    d_low_limit = 0.0;
+    d_low_energy_limit = 0.0;
+    d_data_start = MS_PREAMBLE_TIME_US * channel_rate / 1000000; // in uS
+    d_bit_width = MS_BIT_TIME_US * channel_rate / 1000000;
+    d_chip_width = d_bit_width / 2;   // Two Chips per bit
+    d_min_data_width =  MS_BIT_TIME_US * MS_SHORT_FRAME_LENGTH * channel_rate 
/ 1000000; // in uS
+    d_max_data_width =  MS_BIT_TIME_US * MS_LONG_FRAME_LENGTH * channel_rate / 
1000000;
+    d_sample_count = 0;
+
+    //  Mode S frames are sent in a burst of one frame that occurs when the 
Mode S transponder is interrogated
+    //  by the ground or other aircraft (ACAS/TCAS).  ADS-B Frames may also be 
sent once per second.
+    //  This number represents a channel occupancy of about 50%  or over 4 
thousand frames per second.
+    //  It is unlikely that 700 to 2000 aircraft will be in range
+    set_relative_rate((double)(d_max_data_width+d_data_start)*2.0+2.0);
+    // set_output_multiple(2*(d_max_data_width+2));
+}
+
+void air_ms_ppm_decode::forecast (int noutput_items,
+              gr_vector_int &ninput_items_required)
+{
+       int size;
+       size = noutput_items*d_max_data_width*2+2;  // do at least two frame 
width of data
+       ninput_items_required[1] = ninput_items_required[0] = size;
+}
+
+int air_ms_ppm_decode::general_work(int noutput_items,
+                               gr_vector_int &ninput_items,
+                               gr_vector_const_void_star &input_items,
+                               gr_vector_void_star &output_items)
+
+{
+    float *data_in = (float *)input_items[0];
+    ms_plinfo *attrib_in = (ms_plinfo *)input_items[1];
+    ms_frame_raw *data_out = (ms_frame_raw *) output_items[0];  // sample data 
out
+
+    int size = ninput_items[0] - (d_max_data_width+2); // Only search up to a 
frame from the end
+    int i, j, k;
+    int out_count;
+    int bit_index = 0;
+    int frame_end = 0;
+    float f;
+    out_count = 0;
+    j = 0;
+    for (i = 0; (i < size) && (out_count < noutput_items); i++)
+    {
+       // Ignore any preamble starts and look for data start
+        // The upstream code puts a reference value at data start
+       if(attrib_in[i].data_start())
+       {
+               // Calculate the reference and limits
+               d_reference = attrib_in[i].reference();
+               d_high_limit = d_reference * 1.41253;  // + 3 dB
+               d_low_limit = d_reference * 0.70795;  // - 3 dB
+                d_low_energy_limit = d_reference * 0.5012;  // -6 dB
+                // Prep an output frame
+               data_out[out_count].reset_all();
+               data_out[out_count].set_rx_time(time(NULL));
+               data_out[out_count].set_timestamp((d_sample_count + i));
+               data_out[out_count].set_reference(d_reference);
+               // Init variables used in loop
+               bit_index = 0;
+               frame_end = 0;
+               int multiplier = 1;
+               int phase = 0;  // Data bit phase
+               int chip_zero_ok = 0;
+               int chip_zero_low_energy = 0;
+               int chip_one_ok = 0;
+               int chip_one_low_energy = 0;
+               int score_zero = 0;
+               int score_one = 0;
+               int score_low_energy;
+               // Go for up to the Maximum Frame length for the data bits
+                // It is possible that noise could skew the phase enough that 
the buffer runs out so test input size as well
+               for(bit_index = 0; (i < ninput_items[0]) && (bit_index < 
MS_LONG_FRAME_LENGTH); i++)
+               {
+                       // If leading edge is a sample time late resync
+                       if((phase == 1) && attrib_in[i].leading_edge())
+                       {
+                               phase--;
+                               chip_one_ok = 0;   // Might as well reset
+                               chip_one_low_energy = 0;
+                       }
+                       // If leading edge is a sample time early resync
+                       if((phase == 3) && attrib_in[i].leading_edge())
+                       {
+                               phase++;
+                       }
+                       // If leading edge is a sample time late resync
+                       if((phase == (d_chip_width+1)) && 
attrib_in[i].leading_edge())
+                       {
+                               phase--;
+                               chip_zero_ok = 0;  // Might as well reset
+                               chip_zero_low_energy = 0;
+                       }
+                       // If leading edge is a sample time late resync
+                       if((phase == 7) && attrib_in[i].leading_edge())
+                       {
+                               phase++;
+                       }
+                       // the middle of the pulses have more weight than the 
edges
+                       if((phase == 0) ||(phase == (d_chip_width-1)) ||
+                          (phase == d_chip_width) ||(phase >= (d_bit_width-1)))
+                               multiplier = 1;
+                       else
+                               multiplier = 2;
+                        // Score the samples that represent a valid level and 
a low energy level
+                       if(phase < d_chip_width)   // the first chip represents 
a data value of one
+                       {
+                               f = data_in[i];
+                               if(f >= d_low_limit && f <= d_high_limit)
+                                       chip_one_ok += multiplier;
+                               else if(f < d_low_energy_limit)
+                                       chip_one_low_energy += multiplier;
+                       }
+                       else if(phase < d_bit_width)  // the second chip 
represents a data value of zero
+                       {
+                               f = data_in[i];
+                               if(f >= d_low_limit && f <= d_high_limit)
+                                       chip_zero_ok += multiplier;
+                               else if(f < d_low_energy_limit)
+                                       chip_zero_low_energy += multiplier;
+                       }
+                       if(++phase >= d_bit_width)
+                       {
+                               // Decide what the bit is.  Tie scores go to 
the zero
+                               score_one = chip_one_ok - chip_zero_ok + 
chip_zero_low_energy - chip_one_low_energy;
+                               score_zero = chip_zero_ok - chip_one_ok + 
chip_one_low_energy - chip_zero_low_energy;
+                               score_low_energy = chip_one_low_energy + 
chip_zero_low_energy - chip_one_ok - chip_zero_ok;
+                               k = abs(score_one - score_zero);
+                               if(k > 2)  // Bit has high confidence
+                               {
+                                       
data_out[out_count].set_bit_high_confidence(bit_index, (score_one > 
score_zero)?1:0);
+                               }
+                               else if(k > 0)  // Bit has a low confidence
+                               {
+                                       
data_out[out_count].set_bit_low_confidence(bit_index, (score_one > 
score_zero)?1:0);
+                               }
+                               else if(chip_zero_low_energy >= 6)  // both 
chips are equal as k == 0
+                               {
+                                       
data_out[out_count].set_bit_low_energy(bit_index, (score_one > score_zero)?1:0);
+                               }
+                               else
+                               {
+                                       
data_out[out_count].set_bit_low_confidence(bit_index, 0);
+                               }
+                               if(frame_end)
+                                       break;  // Fall to data end block below
+                               phase = 0;
+                               chip_zero_ok = 0;
+                               chip_zero_low_energy = 0;
+                               chip_one_ok = 0;
+                               chip_one_low_energy = 0;
+                               score_zero = 0;
+                               score_one = 0;
+                               bit_index++;
+                       }
+                       if(attrib_in[i].data_end())
+                       {
+                               if(phase == 0)
+                                       break;  // Fall to data end block below
+                               else  // complete the bit
+                                       frame_end++;
+                       }
+               }
+       }
+       // If frame has ended send the output
+       if(attrib_in[i].data_end() || frame_end)
+       {
+               frame_end = 0;
+               if(bit_index >= MS_LONG_FRAME_LENGTH)
+               {
+                       data_out[out_count].set_long_frame();
+               }
+               else if (bit_index >= MS_SHORT_FRAME_LENGTH)
+               {
+                       data_out[out_count].set_short_frame();
+               }
+               d_reference = 0.0; // Reset the reference
+                out_count++;
+       }
+    }
+    // Consumed the input with a output packet
+    d_sample_count += i;
+    consume_each(i);
+    return out_count;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.h  
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.h  
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_PPM_DECODE_H
+#define INCLUDED_AIR_MS_PPM_DECODE_H
+
+#include <gr_block.h>
+
+class air_ms_ppm_decode;
+typedef boost::shared_ptr<air_ms_ppm_decode> air_ms_ppm_decode_sptr;
+
+air_ms_ppm_decode_sptr air_make_ms_ppm_decode(int channel_rate);
+
+/*!
+ * \brief mode select framer
+ * \ingroup block
+ */
+class air_ms_ppm_decode : public gr_block
+{
+private:
+    friend air_ms_ppm_decode_sptr air_make_ms_ppm_decode(int channel_rate);
+    air_ms_ppm_decode(int channel_rate);
+
+    float d_reference;   // current reference level
+    float d_high_limit;
+    float d_low_limit;
+    float d_low_energy_limit;
+    int d_channel_rate;  // Sample rate of the streams
+    int d_data_start;
+    int d_chip_width;
+    int d_bit_width;
+    int d_min_data_width;
+    int d_max_data_width;
+    int d_sample_count;
+
+public:
+    void forecast (int noutput_items,
+                  gr_vector_int &ninput_items_required);
+
+    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_MS_PPM_DECODE_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_ppm_decode.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.cc   
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.cc   
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,349 @@
+
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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 <gr_io_signature.h>
+#include <air_ms_types.h>
+#include <air_ms_preamble.h>
+
+air_ms_preamble_sptr air_make_ms_preamble(int channel_rate)
+{
+    return air_ms_preamble_sptr(new air_ms_preamble(channel_rate));
+}
+
+air_ms_preamble::air_ms_preamble(int channel_rate) :
+    gr_sync_block ("ms_preamble",
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)),
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)))
+{
+    d_channel_rate = channel_rate;
+    d_reference = 0.0;
+    d_bit_positions[0] = 0 * channel_rate / 10000000;  // Figure out sample 
positions of preamble pulses (0.1 us units)
+    d_bit_positions[1] = 10 * channel_rate / 10000000;
+    d_bit_positions[2] = 35 * channel_rate / 10000000;
+    d_bit_positions[3] = 45 * channel_rate / 10000000;
+    d_data_start = MS_PREAMBLE_TIME_US * channel_rate / 1000000;
+    d_bit_width = MS_BIT_TIME_US * channel_rate / 1000000;
+    d_chip_width = d_bit_width / 2;   // Two Chips per bit
+    d_check_width = ((MS_PREAMBLE_TIME_US+(5*MS_BIT_TIME_US)) * channel_rate / 
1000000)+2;
+    d_var_n = (channel_rate > 8000000)?3:2;  // Number of bits after leading 
edge to sample
+    d_var_m = d_var_n + 1;
+    set_output_multiple(2*d_check_width);
+}
+
+
+int air_ms_preamble::work(int noutput_items,
+                          gr_vector_const_void_star &input_items,
+                                 gr_vector_void_star &output_items)
+{
+    float *data_in = (float *)input_items[0];
+    ms_plinfo *attrib_in = (ms_plinfo *)input_items[1];
+    float *data_out = (float *) output_items[0];  // sample data out
+    ms_plinfo *attrib_out = (ms_plinfo *) output_items[1];    // attribute 
data out
+
+    int size = noutput_items - d_check_width; // Only search up to a check 
width from the end
+    int i, j, k;
+    float f;
+    for (i = 0; i < size; i++)
+    {
+       float reference = 0.0;
+       int   lateness[MS_PREAMBLE_PULSE_COUNT];  // How late a bit is in 
samples
+       int   pcount = 0;
+       int   lcount = 0;
+        int maxcount = 0;
+        int multiflag = 0;
+       float levels[d_var_n*MS_PREAMBLE_PULSE_COUNT];
+        int rcount[d_var_n*MS_PREAMBLE_PULSE_COUNT];
+        float high_limit = 0.0;
+        float low_limit = 0.0;
+        float min_level = 0.0;
+        float max_level = 0.0;
+        for (j = 0; j < MS_PREAMBLE_PULSE_COUNT; j++)
+               lateness[j] = -1;
+       data_out[i] = data_in[i]; // Direct Copy
+        attrib_out[i] = attrib_in[i];
+       // look for valid pulses at 0 1 3.5 and 4.5 uS
+        // also collect samples for later processing
+       for(j = 0; j < MS_PREAMBLE_PULSE_COUNT; j++)
+       {
+               int pos = i + d_bit_positions[j]; // Position to the sample
+               if(attrib_in[pos+1].leading_edge())
+               {
+                       lateness[j] = 1;
+                       for(k = 1; k <= d_var_n; k++)
+                               levels[lcount++] = data_in[pos+k+lateness[j]];
+                       pcount++;
+               }
+               else if(attrib_in[pos].leading_edge())
+               {
+                       lateness[j] = 0;
+                       for(k = 1; k <= d_var_n; k++)
+                               levels[lcount++] = data_in[pos+k+lateness[j]];
+                       pcount++;
+               }
+               else if(attrib_in[pos].valid_pulse())
+               {
+                       lateness[j] = 0;
+                       pcount++;
+               }
+               else if(attrib_in[pos+1].valid_pulse())
+               {
+                       lateness[j] = 1;
+                       pcount++;
+               }
+               else
+                       break;  // No Valid Pulse in time slot
+       }
+       if((pcount < MS_PREAMBLE_PULSE_COUNT) || (lcount < 
(d_var_n*(MS_PREAMBLE_PULSE_COUNT/2))))
+               continue;
+        // Plus or minus one sample is okay but not samples at both plus and 
minus
+        // This code only looks ahead one sample so it is possible that all 
four samples are late
+        // If all samples are late then just continue and it will be picked up 
next time
+       if((lateness[0] + lateness[1] + lateness[2] + lateness[3]) == 4)
+               continue;
+        // The Mode S specifications say the amplitude levels of the pulses 
must be within 2 dB
+       // Take the samples after the leading edges and figure out the 
reference level
+        // The Reference Level is also used downstream for framing and decoding
+        multiflag = 0;
+       for(j = 0; j < lcount; j++)
+       {
+               // Count the number of other samples that are within 2 db of 
the level
+               rcount[j] = 0;
+               high_limit = levels[j] * 1.25893;  // 2 db
+               low_limit =  levels[j] * 0.79433;  // - 2 db
+               for(k = 0; k < lcount; k++)
+               {
+                       if(j == k) // Do not count itself
+                               continue;
+                       if(levels[k] >= low_limit && levels[k] <= high_limit)
+                               rcount[j]++;
+               }
+                // if the count is the higher than previous high level then 
assume it is the only highest
+               if(rcount[j] > maxcount)
+               {
+                       maxcount = rcount[j];
+                       multiflag = 0;
+                        // This is the reference candidate
+                       min_level = reference = levels[j];
+               }
+                // else if there is a tie more processing is needed unless a 
higher level comes along later
+               else if(rcount[j] == maxcount)
+               {
+                       multiflag++;
+                        // find the minimum power of the maximum count samples
+                       if(levels[j] < min_level)
+                       {
+                               min_level = levels[j];
+                       }
+               }
+       }
+        // If there are 2 or more values with the same maximum count then 
average out the samples
+       if(multiflag)
+       {
+               max_level = min_level * 1.25893; // + 2 dB
+               reference = 0.0;
+               k = 0;
+               for(j = 0; j < lcount; j++)
+               {
+                       // Sum up samples with the maximum count and within 2 
dB of minimum power
+                       if((rcount[j] == maxcount) && (levels[j] <= max_level))
+                       {
+                               reference += levels[j];
+                               k++;
+                       }
+               }
+                // This should never happen so if it does then give up
+               if ((k == 0) || (reference == 0))
+                       continue;
+                // Average the samples
+               reference = reference / (float)k;
+       }
+        // Mode S Frames can overlap (FRUIT) and if the later frame is 3 dB or 
stronger it can be decoded.
+        // Later processing can retrigger the start of a data frame but it has 
problems when
+        // the later preamble values are used to calculate the current 
preamble reference level.
+        //
+        // Look for overlapping preambles
+        // Only the bit after the preamble start + the bit time is used
+        // Start with the 1.0 uS position and find the minimum level at 1.0 
2.0 4.5 5.5
+        int offset = i + lateness[0] + d_bit_positions[1] + 1;
+        min_level = data_in[offset + d_bit_positions[0]];
+        for (j = 1; j < MS_PREAMBLE_PULSE_COUNT; j++)
+       {
+               f = data_in[offset+d_bit_positions[j]];
+               if(f < min_level)
+                       min_level = f;
+       }
+        // calculate the -3 dB point
+        min_level *= 0.70795;  // -3 dB
+        // Find maximum of 0 and 3.5
+       offset = i + lateness[0] + 1;
+       max_level = data_in[offset + d_bit_positions[0]];
+        f =  data_in[offset + d_bit_positions[2]];
+       if(f > max_level)
+               max_level = f;
+        // If maximum of 0 and 3.5 is below the -3 dB point of the minimum 
level at 1.0 2.0 4.5 5.5 then reject
+       if(max_level < min_level)
+               continue;
+        // Go to the 3.5 position and find the minimum level at 3.5 4.5 7.0 8.0
+        offset = i + lateness[0] + d_bit_positions[2] + 1;
+        min_level = data_in[offset + d_bit_positions[0]];
+        for(j = 1; j < MS_PREAMBLE_PULSE_COUNT; j++)
+       {
+               f = data_in[offset+d_bit_positions[j]];
+               if(f < min_level)
+                       min_level = f;
+       }
+       // calculate the -3 dB point
+        min_level *= 0.70795;  // - 3 dB
+        // Find maximum of 0 and 1.0
+       offset = i + lateness[0] + 1;
+       max_level = data_in[offset + d_bit_positions[0]];
+        f =  data_in[offset + d_bit_positions[1]];
+       if(f > max_level)
+               max_level = f;
+        // If maximum of 0 and 1.0 is below the -3 dB point of the minimum 
level at 3.5 4.5 7.0 8.0 then reject
+       if(max_level < min_level)
+               continue;
+        // Go to the 4.5 position and find the minimum level at 4.5 5.5 8.0 9.0
+        offset = i + lateness[0] + d_bit_positions[3] + 1;
+        min_level = data_in[offset + d_bit_positions[0]];
+        for(j = 1; j < MS_PREAMBLE_PULSE_COUNT; j++)
+       {
+               f = data_in[offset+d_bit_positions[j]];
+               if(f < min_level)
+                       min_level = f;
+       }
+       // calculate the -3 dB point
+        min_level *= 0.70795;  // -3 dB
+       // Find maximum of 0 1.0 3.5
+       offset = i + lateness[0] + 1;
+       max_level = data_in[offset + d_bit_positions[0]];
+        f =  data_in[offset + d_bit_positions[1]];
+       if(f > max_level)
+               max_level = f;
+        f =  data_in[offset + d_bit_positions[2]];
+       if(f > max_level)
+               max_level = f;
+        // If maximum of 0 1.0 3.5 is below the -3 dB point of the minimum 
level at 4.5 5.5 8.0 9.0 then reject
+       if(max_level < min_level)
+               continue;
+       // Consistent Power Test
+        // Two out of the 4 preambles must be within 3 dB of the reference
+       maxcount = 0;
+       high_limit = reference * 1.41253;  // + 3 dB
+       low_limit = reference * 0.70795;  // - 3 dB
+       offset = i + lateness[0] + 1;
+        for(j = 0; j < MS_PREAMBLE_PULSE_COUNT; j++)
+       {
+               f = data_in[offset+d_bit_positions[j]];
+               if (f >= low_limit && f <= high_limit)
+                       maxcount++;
+       }
+       if(maxcount < (MS_PREAMBLE_PULSE_COUNT/2))
+               continue;  // No preamble here so return
+        // DF Validation
+        // Look for valid pulses in one or both of the chip positions for 5 
data bits
+        // Pulses must be -6 dB or greater of the reference level
+        low_limit = reference * 0.5012;  // -6 dB
+        offset = i + lateness[0] + d_data_start;
+       for( j = 0; j < (5 * d_bit_width); j += d_bit_width)
+       {
+               int chips;
+               int leflag;
+                int jj;
+               max_level = 0.;
+               chips = 0;
+               leflag = 0;
+               k = 0;
+               if(attrib_in[offset+j].valid_pulse())
+               {
+                       chips++;
+                       max_level = data_in[offset+j]; // init maximum level
+                       leflag = 1;
+               }
+               else // look at +/- 1 bit for valid pulse
+               {
+                       for(k = -1; k < 2; k += 2)
+                       {
+                               if(attrib_in[offset+j+k].valid_pulse())
+                               {
+                                       chips++;
+                                       max_level = data_in[offset+j+k]; // 
init maximum level
+                                       leflag = 1;
+                                       break;
+                               }
+                       }
+                }
+               if(leflag)
+               {
+                       for(jj = 0; jj < d_var_m; jj++)
+                       {
+                               if(data_in[offset+j+k+jj] > max_level)
+                                       max_level = data_in[offset+j+k+jj];
+                       }
+               }
+                // Look at the second chip now
+               leflag = 0;
+                k = d_chip_width;
+               if(attrib_in[offset+j+k].valid_pulse())
+               {
+                       chips++;
+                       max_level = data_in[offset+j+k]; // init maximum level
+                       leflag = 1;
+               }
+               else // look at +/- 1 bit for valid pulse
+               {
+                       for(k = d_chip_width -1; k < d_chip_width+2; k += 2)
+                       {
+                               if(attrib_in[offset+j+k].valid_pulse())
+                               {
+                                       chips++;
+                                       max_level = data_in[offset+j+k];
+                                       leflag = 1;
+                                       break;
+                               }
+                       }
+               }
+               if(leflag)
+               {
+                       for(jj = 0; jj < d_var_m; jj++)
+                       {
+                               if(data_in[offset+j+k+jj] > max_level)
+                                       max_level = data_in[offset+j+k+jj];
+                       }
+               }
+               if ((chips == 0) || (max_level < low_limit))
+                       break;  // No preamble here so break out
+       }
+       if(j < (5 * d_bit_width)) // If Data Field is not valid then search
+               continue;
+       // There is a possible preamble
+        // Preamble detection is always running so it is up to the downstream 
to
+        // not act on preamble starts that occur because of data in the Mode S 
frame
+       d_reference = reference;
+       attrib_out[i].set_preamble_start(d_reference);
+    }
+    return i;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.h    
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.h    
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_PREAMBLE_H
+#define INCLUDED_AIR_MS_PREAMBLE_H
+
+#include <gr_sync_block.h>
+#include <air_ms_consts.h>   // For Mode S const values
+
+class air_ms_preamble;
+typedef boost::shared_ptr<air_ms_preamble> air_ms_preamble_sptr;
+
+air_ms_preamble_sptr air_make_ms_preamble(int channel_rate);
+
+/*!
+ * \brief mode select preamble detection
+ * \ingroup block
+ */
+class air_ms_preamble : public gr_sync_block
+{
+private:
+    friend air_ms_preamble_sptr air_make_ms_preamble(int channel_rate);
+    air_ms_preamble(int channel_rate);
+
+    float d_reference;   // current reference level
+    int d_channel_rate;  // Sample rate of the streams
+    int d_bit_positions[MS_PREAMBLE_PULSE_COUNT];  // Position of preample 
pulses in samples
+    int d_data_start;        // When the data starts in samples
+    int d_check_width;   // Width of Preamble checking in samples
+    int d_chip_width;    // Width of chip (1/2 bit time) in samples
+    int d_bit_width;     // Width of bit in samples
+    int d_var_n;         // Number of samples to use after a leading edge
+    int d_var_m;         // d_var_n plus trailing edge
+public:
+    int work (int noutput_items,
+              gr_vector_const_void_star &input_items,
+              gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_MS_PREAMBLE_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_preamble.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.cc
===================================================================
--- 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.cc   
                            (rev 0)
+++ 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.cc   
    2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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 <math.h>              // for pow()
+#include <gr_io_signature.h>
+#include <air_ms_types.h>
+#include <air_ms_pulse_detect.h>
+
+air_ms_pulse_detect_sptr air_make_ms_pulse_detect(float alpha, float beta, int 
width)
+{
+    return air_ms_pulse_detect_sptr(new air_ms_pulse_detect(alpha, beta, 
width));
+}
+
+air_ms_pulse_detect::air_ms_pulse_detect(float alpha, float beta, int width) :
+    gr_sync_block ("ms_pulse_detect",
+                   gr_make_io_signature (1, 1, sizeof(float)),
+                   gr_make_io_signature2 (2, 2, sizeof(float), 
sizeof(ms_plinfo)))
+{
+    d_alpha = powf(10., alpha/20.);  // Convert leading edge threshold from db 
to ratio
+    d_beta = beta;                   // Threshold of valid pulse
+    d_width = width;                 // width of valid pulse - 1
+    set_history(2);    // need to look at two inputs
+    set_output_multiple(1+d_width); // Look ahead for a valid pulse width
+}
+
+int air_ms_pulse_detect::work(int noutput_items,
+                          gr_vector_const_void_star &input_items,
+                                 gr_vector_void_star &output_items)
+{
+    float *in = (float *) input_items[0];
+    float *data_out = (float *) output_items[0];  // sample data out
+    ms_plinfo   *attrib_out = (ms_plinfo *) output_items[1];    // attribute 
data out
+    int t_count = 0;  // Count of samples over the threshold
+    in += 1;         // ensure that in[-1] is valid
+
+    for (int i = 0; i < noutput_items; i++)
+    {
+       attrib_out[i].reset_all();  // No attributes to start
+       data_out[i] = in[i]; // Direct Copy
+       if(in[i] >= d_beta) // Only interested in samples at or above threshold
+       {
+               if(++t_count > d_width) // Check there are enough samples above 
threshold
+               {
+                       int pos = i - d_width;  // rewind and set attributes
+                       attrib_out[pos].set_valid_pulse();
+                       if((in[pos] >= (in[pos - 1] * d_alpha)) && (in[pos + 1] 
< (in[pos] * d_alpha)))
+                       {
+                               attrib_out[pos].set_leading_edge();
+                       }
+               }
+       }
+       else
+               t_count = 0;
+    }
+    return noutput_items-d_width;
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.h
===================================================================
--- 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.h    
                            (rev 0)
+++ 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.h    
    2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_PULSE_DETECT_H
+#define INCLUDED_AIR_MS_PULSE_DETECT_H
+
+#include <gr_sync_block.h>
+
+class air_ms_pulse_detect;
+typedef boost::shared_ptr<air_ms_pulse_detect> air_ms_pulse_detect_sptr;
+
+air_ms_pulse_detect_sptr air_make_ms_pulse_detect(float alpha, float beta, int 
width);
+
+/*!
+ * \brief mode select pulse detect
+ * \ingroup block
+ */
+class air_ms_pulse_detect : public gr_sync_block
+{
+private:
+    friend air_ms_pulse_detect_sptr air_make_ms_pulse_detect(float alpha, 
float beta, int width);
+    air_ms_pulse_detect(float alpha, float beta, int width);
+
+
+    float d_alpha;      // Attack constant used to test if pulse edge
+    float d_beta;      // Threshold
+    int d_width;        // width of valid pulse in samples minus 2 for edges
+
+public:
+    int work (int noutput_items,
+              gr_vector_const_void_star &input_items,
+              gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_AIR_MS_PULSE_DETECT_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_pulse_detect.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_types.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_types.h       
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_types.h       
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIR_MS_TYPES_H
+#define INCLUDED_AIR_MS_TYPES_H
+
+#include <time.h>            // For time_t
+#include <air_ms_consts.h>   // For Mode S const values
+
+/*!
+ * \brief pipeline info that flows besides the data
+ *
+ * Not all modules need all the info
+ */
+class ms_plinfo {
+public:
+  ms_plinfo () : _flags (0), _reference (0.0) { }
+
+  // accessors
+
+  bool valid_pulse () const { return (_flags & fl_valid_pulse) != 0; }
+  bool leading_edge () const { return (_flags & fl_leading_edge) != 0; }
+  bool preamble_start () const { return (_flags & fl_preamble_start) != 0; }
+  bool data_start () const { return (_flags & fl_data_start) != 0; }
+  bool data_end () const { return (_flags & fl_data_end) != 0; }
+
+  float reference ()   const { return _reference; }
+  unsigned int flags () const { return _flags; }
+
+  // setters
+
+  void set_valid_pulse ()
+  {
+    _flags |= fl_valid_pulse;
+  }
+
+  void set_leading_edge ()
+  {
+    _flags |= fl_leading_edge;
+  }
+
+  void set_reference (float reference)
+  {
+    _reference = reference;
+  }
+  void set_preamble_start (float reference)
+  {
+    _reference = reference;
+    _flags |= fl_preamble_start;
+  }
+
+  void set_data_start (float reference)
+  {
+    _reference = reference;
+    _flags |= fl_data_start;
+  }
+  void set_data_end ()
+  {
+    _flags |= fl_data_end;
+  }
+
+ // resetters
+
+  void reset_all ()
+  {
+    _reference = 0.0;
+    _flags = 0;
+  }
+  void reset_preamble_start ()
+  {
+    _reference = 0.0;
+    _flags &= ~fl_preamble_start;
+  }
+  // overload equality operator
+  bool operator== (const ms_plinfo &other) const {
+    return (_flags == other._flags && _reference == other._reference);
+  }
+
+  bool operator!= (const ms_plinfo &other) const {
+    return !(_flags == other._flags && _reference == other._reference);
+  }
+
+
+protected:
+  unsigned short       _flags;         // bitmask
+  float                        _reference;     // reference level
+
+  //     This value is above the threshold
+  static const int     fl_valid_pulse          = 0x0001;
+  //    This marks the leading edge of a pulse
+  static const int     fl_leading_edge         = 0x0002;
+  //    This marks the start of a preamble
+  static const int     fl_preamble_start       = 0x0004;
+  //    This marks the start of the data segment
+  static const int     fl_data_start   = 0x0008;
+  //    This marks the end of the data segment
+  static const int     fl_data_end     = 0x0010;
+};
+
+/*!
+ * \brief Raw mode select data frame
+ *
+ *
+ */
+class ms_frame_raw {
+public:
+  ms_frame_raw () : _timestamp (0), _length(0),  _lcb_count(0), 
_first_lcb(-1), _last_lcb(-1),
+                    _leb_count(0), _first_leb(-1), _last_leb(-1) { }
+
+  // accessors
+
+  bool bit_high_confidence (int index) const { return _flags[index] == 0; }
+  bool bit_low_confidence (int index) const { return (_flags[index] & 
fl_low_confidence) != 0; }
+  bool bit_low_energy (int index) const { return (_flags[index] & 
fl_low_energy) == fl_low_energy; }
+  unsigned char bit (int index)        const { return _bits[index]; }
+  unsigned int flags (int index) const { return _flags[index]; }
+  int timestamp () const { return _timestamp; }
+  float reference ()   const { return _reference; }
+  int length() const { return _length; }
+  short lcb_count() const { return _lcb_count; }
+  short first_lcb() const { return _first_lcb; }
+  short last_lcb() const { return _last_lcb; }
+  short leb_count() const { return _leb_count; }
+  short first_leb() const { return _first_leb; }
+  short last_leb() const { return _last_leb; }
+  unsigned short ec_quality() const { return _ec_quality; }
+  time_t rx_time() const { return _rx_time; }
+  unsigned int address() const { return _address; }
+
+  // setters
+
+  void set_timestamp(int timestamp)
+  {
+       _timestamp = timestamp;
+  }
+
+  void set_reference(float reference)
+  {
+       _reference = reference;
+  }
+
+  void set_short_frame ()
+  {
+       _length = MS_SHORT_FRAME_LENGTH;
+  }
+
+  void set_long_frame ()
+  {
+       _length = MS_LONG_FRAME_LENGTH;
+  }
+
+  void set_bit_high_confidence (int index, unsigned char bit)
+  {
+    if(index < 0 || index >= MS_LONG_FRAME_LENGTH)
+       return;
+    _bits[index] = bit;
+    _flags[index] = fl_high_confidence;
+  }
+
+  void set_bit_low_confidence (int index, unsigned char bit)
+  {
+    if(index < 0 || index >= MS_LONG_FRAME_LENGTH)
+       return;
+    _bits[index] = bit;
+    _flags[index] = fl_low_confidence;
+  }
+
+  void set_bit_low_energy (int index, unsigned char bit)
+  {
+    if(index < 0 || index >= MS_LONG_FRAME_LENGTH)
+       return;
+    _bits[index] = bit;
+    _flags[index] = fl_low_energy;
+  }
+
+  void set_bit_flipped (int index)
+  {
+    if(index < 0 || index >= MS_LONG_FRAME_LENGTH)
+       return;
+    _bits[index] = (_bits[index])?0:1;
+  }
+
+  void count_lcbs ()
+  {
+    reset_lcb();
+    for (int i = 0; i < _length; i++)
+    {
+       if(_flags[i] == fl_low_confidence)
+       {
+               if(_first_lcb < 0)
+                       _first_lcb = i;
+               _last_lcb = i;
+               _lcb_count++;
+       }
+       else if(_flags[i] == fl_low_energy)
+       {
+               if(_first_lcb < 0)
+                       _first_lcb = i;
+               _last_lcb = i;
+               _lcb_count++;
+               if(_first_leb < 0)
+                       _first_leb = i;
+               _last_leb = i;
+               _leb_count++;
+       }
+    }
+  }
+
+  void set_ec_quality(int ec_quality)
+  {
+       _ec_quality = ec_quality;
+  }
+
+  void set_rx_time(time_t rx_time)
+  {
+       _rx_time = rx_time;
+  }
+
+  void set_address(int address)
+  {
+       _address = address;
+  }
+
+ // resetters
+
+  void reset_lcb()
+  {
+    _lcb_count = 0;
+    _first_lcb = -1;
+    _last_lcb = -1;
+    _leb_count = 0;
+    _first_leb = -1;
+    _last_leb = -1;
+  }
+
+  void reset_all ()
+  {
+    _timestamp = 0;
+    _reference = 0.0;
+    _length = 0;
+    _lcb_count = 0;
+    _first_lcb = -1;
+    _last_lcb = -1;
+    _leb_count = 0;
+    _first_leb = -1;
+    _last_leb = -1;
+    _ec_quality = ec_unknown;
+  }
+protected:
+       static const int NPAD = 134;
+       int _timestamp;  // Timestamp in number of samples since start
+       float _reference; // "Signal Strength"
+       int _length;     // Length
+        unsigned char _bits[MS_LONG_FRAME_LENGTH];  // The bits of the frame
+       unsigned short _flags[MS_LONG_FRAME_LENGTH];  // The quality flags
+       short _lcb_count;  // count of low confidence bits
+       short _first_lcb;  // first low confidence bits
+       short _last_lcb;  // first low confidence bits
+       short _leb_count;  // count of low energy bits
+       short _first_leb;  // first low energy bits
+       short _last_leb;  // last low energy bits
+       unsigned short _ec_quality;  // The quality of this
+        time_t _rx_time;
+       unsigned char  _frame_type;  // 1st 5 bits
+       unsigned int   _address;   // airframe or interrogator address
+       unsigned char _pad_[NPAD];
+
+public:
+  //     This bit is of high confidence
+  static const int     fl_high_confidence      = 0x0000;
+  //     This bit is of low confidence
+  static const int     fl_low_confidence       = 0x0001;
+  //     This bit is of low confidence (low energy)
+  static const int     fl_low_energy           = 0x0003;
+
+  //  Quality
+  static const int     ec_unknown              = 0x0000;  // No checking done
+  static const int     crc_bad                 = 0x8000;  // totally NG
+  static const int     eq_too_short_frame      = 0x4000;  // Frame too short
+  static const int     eq_crc_overlayed        = 0x2000;  // CRC has data 
overlay and low confidence bits present
+  static const int     eq_ec_na                = 0x0800;  // EC can not be done
+  static const int     eq_ec_multiple          = 0x0400;  // EC can not be 
done (Multiple solutions
+  static const int     eq_ec_corrected         = 0x0004;  // EC was done
+  static const int     eq_change_short_frame   = 0x0002;  // Long frame is 
really short
+  static const int     crc_ok                  = 0x0001;  // Everything ok
+
+};
+#endif /* INCLUDED_AIR_MS_TYPES_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/air_ms_types.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.cc
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.cc    
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.cc    
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; 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 <stdio.h>
+#include <airi_ms_parity.h>
+#include <air_ms_types.h>
+
+/*  Mode S Parity Table
+ *   Index is bit position with bit 0 being the first bit after preamble
+ *   On short frames an offset of 56 is used.
+*/
+const unsigned int ms_parity_table[MS_LONG_FRAME_LENGTH] =
+{
+    0x3935ea,  // Start of Long Frame CRC
+    0x1c9af5,
+    0xf1b77e,
+    0x78dbbf,
+    0xc397db,
+    0x9e31e9,
+    0xb0e2f0,
+    0x587178,
+    0x2c38bc,
+    0x161c5e,
+    0x0b0e2f,
+    0xfa7d13,
+    0x82c48d,
+    0xbe9842,
+    0x5f4c21,
+    0xd05c14,
+    0x682e0a,
+    0x341705,
+    0xe5f186,
+    0x72f8c3,
+    0xc68665,
+    0x9cb936,
+    0x4e5c9b,
+    0xd8d449,
+    0x939020,
+    0x49c810,
+    0x24e408,
+    0x127204,
+    0x093902,
+    0x049c81,
+    0xfdb444,
+    0x7eda22,
+    0x3f6d11, // Extended 56 bit field
+    0xe04c8c,
+    0x702646,
+    0x381323,
+    0xe3f395,
+    0x8e03ce,
+    0x4701e7,
+    0xdc7af7,
+    0x91c77f,
+    0xb719bb,
+    0xa476d9,
+    0xadc168,
+    0x56e0b4,
+    0x2b705a,
+    0x15b82d,
+    0xf52612,
+    0x7a9309,
+    0xc2b380,
+    0x6159c0,
+    0x30ace0,
+    0x185670,
+    0x0c2b38,
+    0x06159c,
+    0x030ace,
+    0x018567,
+    0xff38b7,  // Start of Short Frame CRC
+    0x80665f,
+    0xbfc92b,
+    0xa01e91,
+    0xaff54c,
+    0x57faa6,
+    0x2bfd53,
+    0xea04ad,
+    0x8af852,
+    0x457c29,
+    0xdd4410,
+    0x6ea208,
+    0x375104,
+    0x1ba882,
+    0x0dd441,
+    0xf91024,
+    0x7c8812,
+    0x3e4409,
+    0xe0d800,
+    0x706c00,
+    0x383600,
+    0x1c1b00,
+    0x0e0d80,
+    0x0706c0,
+    0x038360,
+    0x01c1b0,
+    0x00e0d8,
+    0x00706c,
+    0x003836,
+    0x001c1b,
+    0xfff409,
+    0x800000,   // 24 PI or PA bits
+    0x400000,
+    0x200000,
+    0x100000,
+    0x080000,
+    0x040000,
+    0x020000,
+    0x010000,
+    0x008000,
+    0x004000,
+    0x002000,
+    0x001000,
+    0x000800,
+    0x000400,
+    0x000200,
+    0x000100,
+    0x000080,
+    0x000040,
+    0x000020,
+    0x000010,
+    0x000008,
+    0x000004,
+    0x000002,
+    0x000001,
+};
+int ms_check_parity(ms_frame_raw &frame)
+{
+       int short_crc, long_crc, i;
+       // Check both long and short
+       short_crc = 0;
+       long_crc = 0;
+       for(i = 0; i < MS_SHORT_FRAME_LENGTH; i++)
+       {
+               if(frame.bit(i))
+               {
+                       short_crc ^= ms_parity_table[i+56];
+                       long_crc ^= ms_parity_table[i];
+
+               }
+       }
+       for( ; i < frame.length(); i++)
+       {
+               if(frame.bit(i))
+               {
+                       long_crc ^= ms_parity_table[i];
+               }
+       }
+       return ((frame.length() == MS_LONG_FRAME_LENGTH)?long_crc:short_crc);
+}


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.cc
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.h
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.h     
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.h     
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_AIRI_MS_PARITY_H
+#define INCLUDED_AIRI_MS_PARITY_H
+
+#include <air_ms_consts.h>   // For const
+
+class ms_frame_raw;
+
+extern const unsigned int ms_parity_table[MS_LONG_FRAME_LENGTH];
+
+int ms_check_parity(ms_frame_raw &frame);
+
+#endif /* INCLUDED_AIRI_MS_PARITY_H */


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/lib/airi_ms_parity.h
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/Makefile.am
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/Makefile.am       
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/Makefile.am       
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,39 @@
+#
+# Copyright 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 2, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+include $(top_srcdir)/Makefile.common
+
+EXTRA_DIST = run_tests.in
+
+
+TESTS =                                \
+       run_tests
+
+
+grblkspythondir = $(grpythondir)/blksimpl
+
+grblkspython_PYTHON =          \
+       ppm_demod.py
+
+noinst_PYTHON =                        \
+       qa_air.py
+
+CLEANFILES = *.pyc *.pyo


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/Makefile.am
___________________________________________________________________
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/ppm_demod.py
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/ppm_demod.py      
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/ppm_demod.py      
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,109 @@
+#
+# Copyright 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 2, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gru, optfir, air
+from math import pi
+
+class ppm_demod:
+    """
+    Mode S protocol demodulation block.
+
+    This block demodulates a complex down-converted baseband
+    channel into Aviation Mode S protocol frames.
+
+    Flow graph (so far):
+
+    RESAMP   - Resample Input Stream (if needed)
+    MAG      - Use Magitude function to get AM Pulses
+    DETECT   - Detects Valid Pulses and Leading Edges
+    SYNC     - Detects the Mode S Preamble
+    FRAME    - Frames the data
+    BIT      - Decodes the Pulse Position Modulation (PPM) to Mode S Data 
Frames
+    PARITY   - Parity Checking (CRC)
+    EC       - Brute Force Error Correction
+
+    ---
+
+    @param fg: flowgraph
+    @type fg: flow graph
+    @param channel_rate:  incoming sample rate of the baseband channel
+    @type channel_rate: integer
+    @parm theshold: minumum level for a valid pulse
+    @type theshold: integer
+    """
+from gnuradio import gr, gru
+
+risetime_threshold_db = 48.0   # The minimum change for pulse leading edge in 
dB per bit time (Assume value for 8 MHz BW)
+data_rate = 1000000.0        # Data rate in bits per second
+chip_rate = data_rate*2.0     # Two chips to a bit so rate is double
+
+class ppm_demod(gr.hier_block):
+    def __init__(self, fg, channel_rate, threshold):
+       chan_rate = 8000000 # Minimum sample rate
+
+       if channel_rate < chan_rate:
+            raise ValueError, "Invalid channel rate %d. Must be 8000000 sps or 
higher" % (channel_rate)
+
+       if channel_rate >= 10000000:
+               chan_rate = 10000000    # Higher Performance Receiver
+       # if rate is not supported then resample
+       if channel_rate != chan_rate:
+               interp = gru.lcm(channel_rate, chan_rate)/channel_rate
+               decim  = gru.lcm(channel_rate, chan_rate)/chan_rate
+               self.RESAMP = rational_resampler_ccf(fg, interp, decim)
+
+       # Calculate the leading edge threshold per sample time
+       leading_edge = risetime_threshold_db/(chan_rate/data_rate)
+       # Calculate the number of following samples above threshold needed to 
make a sample a valid pulse position
+       valid_pulse_position = 2
+       if chan_rate == 10000000:
+               valid_pulse_position = 3
+       # Demodule AM with classic sqrt (I*I + Q*Q)
+        self.MAG = gr.complex_to_mag()
+        self.DETECT = air.ms_pulse_detect(leading_edge, threshold, 
valid_pulse_position) # Attack, Threshold, Pulsewidth
+       self.SYNC = air.ms_preamble(chan_rate)
+       self.FRAME = air.ms_framer(chan_rate)
+       self.BIT   = air.ms_ppm_decode(chan_rate)
+       self.PARITY = air.ms_parity()
+       self.EC    =  air.ms_ec_brute()
+
+       if channel_rate != chan_rate:
+               fg.connect(self.RESAMP, self.MAG)
+        fg.connect(self.MAG, self.DETECT)
+        fg.connect((self.DETECT, 0), (self.SYNC, 0))
+        fg.connect((self.DETECT, 1), (self.SYNC, 1))
+        fg.connect((self.SYNC, 0), (self.FRAME, 0))
+        fg.connect((self.SYNC, 1), (self.FRAME, 1))
+        fg.connect((self.FRAME, 0), (self.BIT, 0))
+        fg.connect((self.FRAME, 1), (self.BIT, 1))
+        fg.connect(self.BIT, self.PARITY, self.EC)
+       if channel_rate != chan_rate:
+               gr.hier_block.__init__(self,
+                                       fg,
+                                       self.RESAMP,  # head of the pipeline
+                                       self.EC)   # tail of the pipeline
+       else :
+               gr.hier_block.__init__(self,
+                                       fg,
+                                       self.MAG,       # head of the pipeline
+                                       self.EC)   # tail of the pipeline
+
+


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/ppm_demod.py
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/qa_air.py
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/qa_air.py         
                (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/qa_air.py 
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 2, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+import air_swig
+
+class qa_air(gr_unittest.TestCase):
+
+    def setUp (self):
+        self.fg = gr.flow_graph ()
+
+    def tearDown (self):
+        self.fg = None
+
+if __name__ == '__main__':
+    gr_unittest.main ()


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/qa_air.py
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Added: gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/run_tests.in
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/run_tests.in      
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/run_tests.in      
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# 1st parameter is absolute path to component source directory
+# 2nd parameter is absolute path to component build directory
+# 3rd parameter is path to Python QA directory
+
address@hidden@/run_tests.sh \
+    @abs_top_srcdir@/gr-air \
+    @abs_top_builddir@/gr-air \
+    @srcdir@

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_mode_s_logfile.py
===================================================================
--- 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_mode_s_logfile.py
                            (rev 0)
+++ 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_mode_s_logfile.py
    2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,144 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru, usrp, optfir, eng_notation, blks, air
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import time, os, sys
+from string import split, join
+from usrpm import usrp_dbid
+
+"""
+This example application demonstrates receiving and demodulating the
+Aviation Mode Select (Mode S) Transponder protocol.  The decoded Mode
+Select frames are outputted to a log file
+
+A receive chain is built up of the following signal processing
+blocks:
+
+USRP  - Daughter board source generating complex baseband signal.
+MODE_S - Mode S transponder protocol decoder
+FORMAT - Format Mode S Frames for logging
+
+The following are optional command line parameters:
+
+-R SUBDEV    Daughter board specification, defaults to first found
+-f FREQ             USRP receive frequency (1090 MHz Default)
+-g GAIN      Daughterboard gain setting. Defaults to mid-range.
+-d DECIM     USRP decimation rate
+-t THRESH    Receiver valid pulse threshold
+-a           Output all frames. Defaults only output frames
+
+Once the program is running, ctrl-break (Ctrl-C) stops operation.
+"""
+
+def pick_subdevice(u):
+    """
+    The user didn't specify a subdevice on the command line.
+    Try for one of these, in order: DBS_RX, BASIC_RX, whatever is on side A.
+
+    @return a subdev_spec
+    """
+    return usrp.pick_subdev(u, (usrp_dbid.DBS_RX,
+                                usrp_dbid.DBS_RX_REV_2_1,
+                                usrp_dbid.BASIC_RX))
+
+class usrp_source_c(gr.hier_block):
+    """
+    Create a USRP source object supplying complex floats.
+
+    Selects user supplied subdevice or chooses first available one.
+
+    """
+    def __init__(self, fg, subdev_spec, decim, gain=None):
+        self._decim = decim
+       if self._decim < 8:
+               self.fpga_filename="std_4rx_0tx.rbf" #Min decimation of this 
firmware is 4. contains 4 Rx paths without halfbands and 0 tx paths.
+               self._src = usrp.source_c(fpga_filename=self.fpga_filename)
+       else :
+                #standard fpga firmware "std_2rxhb_2tx.rbf" contains 2 Rx 
paths with halfband filters and 2 tx paths (the default) min decimation 8
+               self._src = usrp.source_c()
+       if subdev_spec is None:
+            subdev_spec = pick_subdevice(self._src)
+        self._subdev = usrp.selected_subdev(self._src, subdev_spec)
+        self._src.set_mux(usrp.determine_rx_mux_value(self._src, subdev_spec))
+        self._src.set_decim_rate(self._decim)
+       # self._subdev.set_bw(8e6)  # Only valid for DBS_RX
+
+
+        # If no gain specified, set to midrange
+        if gain is None:
+            g = self._subdev.gain_range()
+            gain = (g[0]+g[1])/2.0
+
+        self._subdev.set_gain(gain)
+
+        gr.hier_block.__init__(self, fg, self._src, self._src)
+
+    def tune(self, freq):
+        result = usrp.tune(self._src, 0, self._subdev, freq)
+        # Signal is so wideband no residual tune is needed
+
+    def rate(self):
+        return self._src.adc_rate()/self._decim
+
+class app_flow_graph(gr.flow_graph):
+    def __init__(self, options, args, queue):
+        gr.flow_graph.__init__(self)
+        self.options = options
+        self.args = args
+
+        USRP = usrp_source_c(self,          # Flow graph
+                    options.rx_subdev_spec, # Daugherboard spec
+                   options.decim,          # IF decimation ratio
+                    options.gain)           # Receiver gain
+        USRP.tune(options.freq)
+
+        if_rate = USRP.rate()
+       pass_all = 0
+       if options.output_all :
+               pass_all = 1
+        MODE_S = blks.ppm_demod(self, if_rate, options.thresh)
+       FORMAT = air.ms_fmt_log(pass_all, queue)
+
+        self.connect(USRP, MODE_S, FORMAT)
+
+def main():
+    usage="%prog: [options] output_filename"
+    parser = OptionParser(option_class=eng_option, usage=usage)
+    parser.add_option("-R", "--rx-subdev-spec", type="subdev",
+                      help="select USRP Rx side A or B", metavar="SUBDEV")
+    parser.add_option("-f", "--freq", type="eng_float", default=1090.0,
+                      help="set receive frequency to MHz [default=%default]", 
metavar="FREQ")
+    parser.add_option("-g", "--gain", type="int", default=None,
+                      help="set RF gain", metavar="dB")
+    parser.add_option("-d", "--decim", type="int", default=8,
+                      help="set fgpa decimation rate to DECIM 
[default=%default]")
+    parser.add_option("-T", "--thresh", type="int", default=10,
+                      help="set valid pulse threshold to THRESH 
[default=%default]")
+    parser.add_option("-a","--output-all", action="store_true", default=False,
+                          help="output all frames")
+    (options, args) = parser.parse_args()
+    if len(args) != 1:
+        parser.print_help()
+        raise SystemExit, 1
+    filename = args[0]
+
+    options.freq *= 1e6
+
+    queue = gr.msg_queue()
+
+    fg = app_flow_graph(options, args, queue)
+    try:
+        fileHandle = open(filename, "w")
+        fg.start()
+       while 1:
+           msg = queue.delete_head() # Blocking read
+            # print msg.to_string()
+            fileHandle.write( msg.to_string()+"\n")
+            fileHandle.flush()
+    except KeyboardInterrupt:
+        fg.stop()
+        fileHandle.close()
+
+if __name__ == "__main__":
+    main()


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_mode_s_logfile.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_oscope_ms.py
===================================================================
--- gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_oscope_ms.py 
                        (rev 0)
+++ gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_oscope_ms.py 
2007-07-03 16:25:59 UTC (rev 5897)
@@ -0,0 +1,297 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005,2006,2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 2, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+# print "Loading revised usrp_oscope with additional options for scopesink..."
+
+from gnuradio import gr, gru, blks, air
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from gnuradio.wxgui import stdgui, fftsink, waterfallsink, scopesink, form, 
slider
+from optparse import OptionParser
+import wx
+import sys
+
+risetime_threshold_db = 48.0   # The minimum change for pulse leading edge in 
dB per bit time (Assume value for 8 MHz BW)
+data_rate = 1000000.0        # Data rate in bits per second
+chip_rate = data_rate*2.0     # Two chips to a bit so rate is double
+
+def pick_subdevice(u):
+    """
+    The user didn't specify a subdevice on the command line.
+    If there's a daughterboard on A, select A.
+    If there's a daughterboard on B, select B.
+    Otherwise, select A.
+    """
+    if u.db[0][0].dbid() >= 0:       # dbid is < 0 if there's no d'board or a 
problem
+        return (0, 0)
+    if u.db[1][0].dbid() >= 0:
+        return (1, 0)
+    return (0, 0)
+
+
+class app_flow_graph(stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__(self)
+
+        self.frame = frame
+        self.panel = panel
+
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-R", "--rx-subdev-spec", type="subdev", 
default=None,
+                          help="select USRP Rx side A or B (default=first one 
with a daughterboard)")
+        parser.add_option("-d", "--decim", type="int", default=8,
+                          help="set fgpa decimation rate to DECIM 
[default=%default]")
+       parser.add_option("-f", "--freq", type="eng_float", default=1090.0,
+                          help="set receive frequency to MHz 
[default=%default]", metavar="FREQ")
+        parser.add_option("-g", "--gain", type="eng_float", default=None,
+                          help="set gain in dB (default is midpoint)")
+        parser.add_option("-8", "--width-8", action="store_true", 
default=False,
+                          help="Enable 8-bit samples across USB")
+        parser.add_option("-n", "--frame-decim", type="int", default=1,
+                          help="set oscope frame decimation factor to n 
[default=1]")
+        parser.add_option("-v", "--v-scale", type="eng_float", default=200,
+                          help="set oscope initial V/div to SCALE 
[default=%default]")
+        parser.add_option("-t", "--t-scale", type="eng_float", default=24e-6,
+                          help="set oscope initial s/div to SCALE 
[default=25us]")
+       parser.add_option("-T", "--thresh", type="int", default=10,
+                          help="set valid pulse threshold to THRESH 
[default=%default]")
+        (options, args) = parser.parse_args()
+        if len(args) != 0:
+            parser.print_help()
+            sys.exit(1)
+
+        self.show_debug_info = True
+
+       options.freq *= 1e6
+
+        # build the graph
+
+       if options.decim < 8:
+               self.fpga_filename="std_4rx_0tx.rbf" #Min decimation of this 
firmware is 4. contains 4 Rx paths without halfbands and 0 tx paths.
+               self.u = usrp.source_c(decim_rate=options.decim, 
fpga_filename=self.fpga_filename)
+       else :
+                #standard fpga firmware "std_2rxhb_2tx.rbf" contains 2 Rx 
paths with halfband filters and 2 tx paths (the default) min decimation 8
+               self.u = usrp.source_c(decim_rate=options.decim)
+        if options.rx_subdev_spec is None:
+            options.rx_subdev_spec = pick_subdevice(self.u)
+        self.u.set_mux(usrp.determine_rx_mux_value(self.u, 
options.rx_subdev_spec))
+
+        if options.width_8:
+            width = 8
+            shift = 8
+            format = self.u.make_format(width, shift)
+            #print "format =", hex(format)
+            r = self.u.set_format(format)
+            #print "set_format =", r
+
+        # determine the daughterboard subdevice we're using
+        self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)
+       #self.subdev.set_bw(5e6)  # only valid for dbsrx
+
+       chan_rate = 8000000
+        input_rate = self.u.adc_freq() / self.u.decim_rate()
+       if input_rate < chan_rate:
+            raise ValueError, "Invalid input rate %d. Must be 8000000 sps or 
higher" % (input_rate)
+       if input_rate >= 10000000:
+               chan_rate = 10000000    # Higher Performance Receiver
+       # if rate is not supported then resample
+       if input_rate != chan_rate:
+               interp = gru.lcm(input_rate, chan_rate)/input_rate
+               decim  = gru.lcm(input_rate, chan_rate)/chan_rate
+               print interp, decim
+               self.resamp = blks.rational_resampler_ccf(self, interp, decim)
+
+       # Calculate the leading edge threshold per sample time
+       leading_edge = risetime_threshold_db/(chan_rate/data_rate)
+       # The number of following samples above threshold needed to make a 
sample a valid pulse position
+       valid_pulse_position = 2
+       if chan_rate == 10000000:
+               valid_pulse_position = 3
+       self.mag = gr.complex_to_mag()
+       self.detect = air.ms_pulse_detect(leading_edge, options.thresh, 
valid_pulse_position)
+       self.sync = air.ms_preamble(chan_rate)
+       self.frame = air.ms_framer(chan_rate)
+       self.cvt = air.ms_cvt_float()
+        self.scope = scopesink.scope_sink_f(self, panel, sample_rate=chan_rate,
+                                            frame_decim=options.frame_decim,
+                                            v_scale=options.v_scale,
+                                            t_scale=options.t_scale)
+       #if chan_rate == 10000000:
+        #self.connect(self.u, self.resamp, self.mag, self.detect)
+       #else :
+        self.connect(self.u, self.mag, self.detect)
+       self.connect((self.detect, 0), (self.sync, 0))
+       self.connect((self.detect, 1), (self.sync, 1))
+       self.connect((self.sync, 0), (self.frame, 0))
+       self.connect((self.sync, 1), (self.frame, 1))
+        self.connect((self.frame, 0), (self.cvt, 0))
+        self.connect((self.frame, 1), (self.cvt, 1))
+        self.connect((self.cvt, 0), (self.scope, 0))
+        self.connect((self.cvt, 1), (self.scope,1))
+        self.connect((self.cvt, 2), (self.scope,2))
+
+        self._build_gui(vbox)
+
+        # set initial values
+
+        if options.gain is None:
+            # if no gain was specified, use the mid-point in dB
+            g = self.subdev.gain_range()
+            options.gain = float(g[0]+g[1])/2
+
+
+        self.set_gain(options.gain)
+
+        if self.show_debug_info:
+            self.myform['decim'].set_value(self.u.decim_rate())
+            self.myform['address@hidden'].set_value(self.u.adc_freq() / 
self.u.decim_rate())
+            self.myform['dbname'].set_value(self.subdev.name())
+            self.myform['baseband'].set_value(0)
+            self.myform['ddc'].set_value(0)
+
+        if not(self.set_freq(options.freq)):
+            self._set_status_msg("Failed to set initial frequency")
+
+
+    def _set_status_msg(self, msg):
+        self.frame.GetStatusBar().SetStatusText(msg, 0)
+
+    def _build_gui(self, vbox):
+
+        def _form_set_freq(kv):
+            return self.set_freq(kv['freq'])
+
+        vbox.Add(self.scope.win, 10, wx.EXPAND)
+
+        # add control area at the bottom
+        self.myform = myform = form.form()
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.Add((5,0), 0, 0)
+        myform['freq'] = form.float_field(
+            parent=self.panel, sizer=hbox, label="Center freq", weight=1,
+            callback=myform.check_input_and_call(_form_set_freq, 
self._set_status_msg))
+
+        hbox.Add((5,0), 0, 0)
+        g = self.subdev.gain_range()
+        myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, 
label="Gain",
+                                           weight=3,
+                                           min=int(g[0]), max=int(g[1]),
+                                           callback=self.set_gain)
+
+        hbox.Add((5,0), 0, 0)
+        vbox.Add(hbox, 0, wx.EXPAND)
+
+        self._build_subpanel(vbox)
+
+    def _build_subpanel(self, vbox_arg):
+        # build a secondary information panel (sometimes hidden)
+
+        # FIXME figure out how to have this be a subpanel that is always
+        # created, but has its visibility controlled by foo.Show(True/False)
+
+        def _form_set_decim(kv):
+            return self.set_decim(kv['decim'])
+
+        if not(self.show_debug_info):
+            return
+
+        panel = self.panel
+        vbox = vbox_arg
+        myform = self.myform
+
+        #panel = wx.Panel(self.panel, -1)
+        #vbox = wx.BoxSizer(wx.VERTICAL)
+
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.Add((5,0), 0)
+
+        myform['decim'] = form.int_field(
+            parent=panel, sizer=hbox, label="Decim",
+            callback=myform.check_input_and_call(_form_set_decim, 
self._set_status_msg))
+
+        hbox.Add((5,0), 1)
+        myform['address@hidden'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="address@hidden")
+
+        hbox.Add((5,0), 1)
+        myform['dbname'] = form.static_text_field(
+            parent=panel, sizer=hbox)
+
+        hbox.Add((5,0), 1)
+        myform['baseband'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="Analog BB")
+
+        hbox.Add((5,0), 1)
+        myform['ddc'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="DDC")
+
+        hbox.Add((5,0), 0)
+        vbox.Add(hbox, 0, wx.EXPAND)
+
+
+    def set_freq(self, target_freq):
+        """
+        Set the center frequency we're interested in.
+
+        @param target_freq: frequency in Hz
+        @rypte: bool
+
+        Tuning is a two step process.  First we ask the front-end to
+        tune as close to the desired frequency as it can.  Then we use
+        the result of that operation and our target_frequency to
+        determine the value for the digital down converter.
+        """
+        r = usrp.tune(self.u, 0, self.subdev, target_freq)
+
+        if r:
+            self.myform['freq'].set_value(target_freq)     # update displayed 
value
+            if self.show_debug_info:
+                self.myform['baseband'].set_value(r.baseband_freq)
+                self.myform['ddc'].set_value(r.dxc_freq)
+            return True
+
+        return False
+
+    def set_gain(self, gain):
+        self.myform['gain'].set_value(gain)     # update displayed value
+        self.subdev.set_gain(gain)
+
+    def set_decim(self, decim):
+       # For now disallow setting
+       print "set_decim not allowed"
+        #ok = self.u.set_decim_rate(decim)
+        #if not ok:
+        #    print "set_decim failed"
+        input_rate = self.u.adc_freq() / self.u.decim_rate()
+        self.scope.set_sample_rate(input_rate)
+        if self.show_debug_info:  # update displayed values
+            self.myform['decim'].set_value(self.u.decim_rate())
+            self.myform['address@hidden'].set_value(self.u.adc_freq() / 
self.u.decim_rate())
+        return ok
+
+def main ():
+    app = stdgui.stdapp(app_flow_graph, "USRP Mode S O'scope", nstatus=1)
+    app.MainLoop()
+
+if __name__ == '__main__':
+    main ()


Property changes on: 
gnuradio/branches/developers/wb1hbu/wip/gr-air/src/python/usrp_oscope_ms.py
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]