|
gr-baz Package
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2004 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 /* 00024 * gr-baz by Balint Seeber (http://spench.net/contact) 00025 * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz 00026 */ 00027 00028 #ifndef INCLUDED_BAZ_ACARS_H 00029 #define INCLUDED_BAZ_ACARS_H 00030 00031 #include <gr_sync_block.h> 00032 #include <gr_msg_queue.h> 00033 #include <string> 00034 00035 class baz_acars_decoder; 00036 00037 /* 00038 * We use boost::shared_ptr's instead of raw pointers for all access 00039 * to gr_blocks (and many other data structures). The shared_ptr gets 00040 * us transparent reference counting, which greatly simplifies storage 00041 * management issues. This is especially helpful in our hybrid 00042 * C++ / Python system. 00043 * 00044 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 00045 * 00046 * As a convention, the _sptr suffix indicates a boost::shared_ptr 00047 */ 00048 typedef boost::shared_ptr<baz_acars_decoder> baz_acars_decoder_sptr; 00049 00050 /*! 00051 * \brief Return a shared_ptr to a new instance of baz_acars_decoder. 00052 * 00053 * To avoid accidental use of raw pointers, baz_acars_decoder's 00054 * constructor is private. baz_acars_decoder is the public 00055 * interface for creating new instances. 00056 */ 00057 baz_acars_decoder_sptr baz_make_acars_decoder (gr_msg_queue_sptr msgq); 00058 00059 /*! 00060 * \brief acars a stream of floats. 00061 * \ingroup block 00062 * 00063 * This uses the preferred technique: subclassing gr_sync_block. 00064 */ 00065 class baz_acars_decoder : public gr_sync_block 00066 { 00067 private: 00068 // The friend declaration allows baz_acars_decoder to 00069 // access the private constructor. 00070 friend baz_acars_decoder_sptr baz_make_acars_decoder (gr_msg_queue_sptr msgq); 00071 00072 baz_acars_decoder (gr_msg_queue_sptr msgq); // private constructor 00073 00074 enum state_t 00075 { 00076 STATE_SEARCHING, 00077 //STATE_BITSYNC, 00078 //STATE_CHARSYNC, 00079 STATE_ASSEMBLE, 00080 //STATE_DLE, 00081 //STATE_END 00082 }; 00083 00084 #define MAX_PACKET_SIZE 252 00085 00086 enum flags_t 00087 { 00088 FLAG_NONE = 0x00, 00089 FLAG_SOH = 0x01, 00090 FLAG_STX = 0x02, 00091 FLAG_ETX = 0x04, 00092 FLAG_DEL = 0x08 00093 }; 00094 00095 #pragma pack(push) 00096 #pragma pack(1) 00097 struct packet 00098 { 00099 float reference_level; 00100 float prekey_average; 00101 int prekey_ones; 00102 unsigned char byte_data[MAX_PACKET_SIZE]; 00103 unsigned char byte_error[MAX_PACKET_SIZE]; 00104 int parity_error_count; 00105 int byte_count; 00106 unsigned char flags; 00107 int etx_index; 00108 }; 00109 #pragma pack(pop) 00110 00111 state_t d_state; 00112 unsigned long d_preamble_state; 00113 int d_preamble_threshold; 00114 struct packet d_current_packet; 00115 int d_bit_counter; 00116 unsigned char d_current_byte; 00117 int d_byte_counter; 00118 unsigned char d_flags; 00119 gr_msg_queue_sptr d_msgq; 00120 unsigned char d_prev_bit; 00121 float d_frequency; 00122 std::string d_station_name; 00123 00124 public: 00125 ~baz_acars_decoder (); // public destructor 00126 00127 void set_preamble_threshold(int threshold); 00128 void set_frequency(float frequency); 00129 void set_station_name(const char* station_name); 00130 00131 inline int preamble_threshold() const 00132 { return d_preamble_threshold; } 00133 inline float frequency() const 00134 { return d_frequency; } 00135 inline const char* station_name() const 00136 { return d_station_name.c_str(); } 00137 00138 int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); 00139 }; 00140 00141 #endif /* INCLUDED_BAZ_ACARS_CC_H */