gr-baz Package
baz_acars_decoder.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 /*
24  * gr-baz by Balint Seeber (http://spench.net/contact)
25  * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz
26  */
27 
28 #ifndef INCLUDED_BAZ_ACARS_H
29 #define INCLUDED_BAZ_ACARS_H
30 
31 #include <gnuradio/sync_block.h>
32 #include <gnuradio/msg_queue.h>
33 #include <string>
34 
35 class baz_acars_decoder;
36 
37 /*
38  * We use boost::shared_ptr's instead of raw pointers for all access
39  * to gr::blocks (and many other data structures). The shared_ptr gets
40  * us transparent reference counting, which greatly simplifies storage
41  * management issues. This is especially helpful in our hybrid
42  * C++ / Python system.
43  *
44  * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
45  *
46  * As a convention, the _sptr suffix indicates a boost::shared_ptr
47  */
48 typedef boost::shared_ptr<baz_acars_decoder> baz_acars_decoder_sptr;
49 
50 /*!
51  * \brief Return a shared_ptr to a new instance of baz_acars_decoder.
52  *
53  * To avoid accidental use of raw pointers, baz_acars_decoder's
54  * constructor is private. baz_acars_decoder is the public
55  * interface for creating new instances.
56  */
57 baz_acars_decoder_sptr baz_make_acars_decoder (gr::msg_queue::sptr msgq);
58 
59 /*!
60  * \brief acars a stream of floats.
61  * \ingroup block
62  *
63  * This uses the preferred technique: subclassing gr::sync_block.
64  */
65 class baz_acars_decoder : public gr::sync_block
66 {
67 private:
68  // The friend declaration allows baz_acars_decoder to
69  // access the private constructor.
70  friend baz_acars_decoder_sptr baz_make_acars_decoder (gr::msg_queue::sptr msgq);
71 
72  baz_acars_decoder (gr::msg_queue::sptr msgq); // private constructor
73 
74  enum state_t
75  {
76  STATE_SEARCHING,
77  //STATE_BITSYNC,
78  //STATE_CHARSYNC,
79  STATE_ASSEMBLE,
80  //STATE_DLE,
81  //STATE_END
82  };
83 
84  const static int MAX_ACARS_PACKET_SIZE = 252;
85 
86  enum flags_t
87  {
88  FLAG_NONE = 0x00,
89  FLAG_SOH = 0x01,
90  FLAG_STX = 0x02,
91  FLAG_ETX = 0x04,
92  FLAG_DEL = 0x08
93  };
94 
95 #pragma pack(push)
96 #pragma pack(1)
97  struct packet
98  {
99  float reference_level;
100  float prekey_average;
101  int prekey_ones;
102  unsigned char byte_data[MAX_ACARS_PACKET_SIZE];
103  unsigned char byte_error[MAX_ACARS_PACKET_SIZE];
104  int parity_error_count;
105  int byte_count;
106  unsigned char flags;
107  int etx_index;
108  };
109 #pragma pack(pop)
110 
111  state_t d_state;
112  unsigned long d_preamble_state;
113  int d_preamble_threshold;
114  struct packet d_current_packet;
115  int d_bit_counter;
116  unsigned char d_current_byte;
117  int d_byte_counter;
118  unsigned char d_flags;
119  gr::msg_queue::sptr d_msgq;
120  unsigned char d_prev_bit;
121  float d_frequency;
122  std::string d_station_name;
123 
124 public:
125  ~baz_acars_decoder (); // public destructor
126 
127  void set_preamble_threshold(int threshold);
128  void set_frequency(float frequency);
129  void set_station_name(const char* station_name);
130 
131  inline int preamble_threshold() const
132  { return d_preamble_threshold; }
133  inline float frequency() const
134  { return d_frequency; }
135  inline const char* station_name() const
136  { return d_station_name.c_str(); }
137 
138  int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
139 };
140 
141 #endif /* INCLUDED_BAZ_ACARS_CC_H */
void set_station_name(const char *station_name)
void set_frequency(float frequency)
int preamble_threshold() const
Definition: baz_acars_decoder.h:131
const char * station_name() const
Definition: baz_acars_decoder.h:135
float frequency() const
Definition: baz_acars_decoder.h:133
friend baz_acars_decoder_sptr baz_make_acars_decoder(gr::msg_queue::sptr msgq)
Return a shared_ptr to a new instance of baz_acars_decoder.
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
baz_acars_decoder_sptr baz_make_acars_decoder(gr::msg_queue::sptr msgq)
Return a shared_ptr to a new instance of baz_acars_decoder.
acars a stream of floats.This uses the preferred technique: subclassing gr::sync_block.
Definition: baz_acars_decoder.h:65
void set_preamble_threshold(int threshold)