gr-baz Package

baz_fastrak_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_FASTRAK_DECODER_H
29#define INCLUDED_BAZ_FASTRAK_DECODER_H
30
31#include <gnuradio/sync_block.h>
32
33 class BAZ_API baz_fastrak_decoder;
34
35/*
36 * We use boost::shared_ptr's instead of raw pointers for all access
37 * to gr_blocks (and many other data structures). The shared_ptr gets
38 * us transparent reference counting, which greatly simplifies storage
39 * management issues. This is especially helpful in our hybrid
40 * C++ / Python system.
41 *
42 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
43 *
44 * As a convention, the _sptr suffix indicates a boost::shared_ptr
45 */
46 typedef boost::shared_ptr<baz_fastrak_decoder> baz_fastrak_decoder_sptr;
47
48/*!
49 * \brief Return a shared_ptr to a new instance of baz_fastrak_decoder.
50 *
51 * To avoid accidental use of raw pointers, baz_fastrak_decoder's
52 * constructor is private. baz_make_fastrak_decoder is the public
53 * interface for creating new instances.
54 */
55 BAZ_API baz_fastrak_decoder_sptr baz_make_fastrak_decoder (int sample_rate);
56
57/*!
58 * \brief square2 a stream of floats.
59 * \ingroup block
60 *
61 * This uses the preferred technique: subclassing gr_sync_block.
62 */
63 class BAZ_API baz_fastrak_decoder : public gr::sync_block
64{
65 private:
66 // The friend declaration allows baz_make_fastrak_decoder to access the private constructor.
67 friend BAZ_API baz_fastrak_decoder_sptr baz_make_fastrak_decoder (int sample_rate);
68
69 baz_fastrak_decoder (int sample_rate); // private constructor
70
71 float d_sync_threshold;
72 int d_sample_rate;
73 int d_oversampling;
74 std::string d_last_id_string;
75 typedef enum state
76 {
77 STATE_UNKNOWN,
78 STATE_SEARCHING,
79 STATE_SYNC,
80 STATE_TYPE,
81 STATE_DECODE,
82 STATE_CRC,
83 STATE_DONE
84 } state_t;
85 typedef enum packet_type
86 {
87 PT_UNKNOWN = 0xFFFF,
88 PT_ID = 0x0001
89 } packet_type_t;
90 packet_type_t d_current_packet_type;
91 typedef std::map<packet_type_t,int> TypeLengthMap;
92 TypeLengthMap d_type_length_map;
93 state_t d_state;
94 unsigned long long d_bit_buffer;
95 int d_bit_counter;
96 int d_sub_symbol_counter;
97 int d_payload_bit_counter;
98 unsigned int d_id;
99 unsigned short d_crc;
100 unsigned char d_crc_buffer;
101 int d_total_bit_counter;
102 bool d_compute_crc;
103 int d_crc_bit_counter;
104 unsigned int d_last_id;
105 unsigned int d_last_id_count;
106
107 void enter_state(state_t state);
108 public:
109 ~baz_fastrak_decoder (); // public destructor
110
111 void set_sync_threshold(float threshold);
112 unsigned int last_id_count(bool reset = false);
113
114 //inline std::string last_id() const
115 //{ return d_last_id_string; }
116 inline unsigned int last_id() const
117 { return d_last_id; }
118
119 int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
120};
121
122#endif /* INCLUDED_BAZ_FASTRAK_DECODER_H */
BAZ_API
#define BAZ_API
Definition: api.h:19
baz_make_fastrak_decoder
BAZ_API baz_fastrak_decoder_sptr baz_make_fastrak_decoder(int sample_rate)
Return a shared_ptr to a new instance of baz_fastrak_decoder.
baz_fastrak_decoder
class BAZ_API baz_fastrak_decoder
Definition: baz_fastrak_decoder.h:33
baz_fastrak_decoder
square2 a stream of floats.
Definition: baz_fastrak_decoder.h:64
baz_fastrak_decoder::~baz_fastrak_decoder
~baz_fastrak_decoder()
baz_fastrak_decoder::last_id
unsigned int last_id() const
Definition: baz_fastrak_decoder.h:116
baz_fastrak_decoder::work
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
baz_fastrak_decoder::set_sync_threshold
void set_sync_threshold(float threshold)
baz_fastrak_decoder::last_id_count
unsigned int last_id_count(bool reset=false)
baz_fastrak_decoder::baz_make_fastrak_decoder
friend BAZ_API baz_fastrak_decoder_sptr baz_make_fastrak_decoder(int sample_rate)
Return a shared_ptr to a new instance of baz_fastrak_decoder.