GNU Radio's RDS Package
encoder_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Bastian Bloessl <bloessl@ccs-labs.org>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef INCLUDED_RDS_ENCODER_IMPL_H
18 #define INCLUDED_RDS_ENCODER_IMPL_H
19 
20 #include <rds/encoder.h>
21 #include <gnuradio/thread/thread.h>
22 
23 namespace gr {
24 namespace rds {
25 
26 class encoder_impl : public encoder
27 {
28 public:
29  encoder_impl(unsigned char pty_locale, int pty, bool ms, std::string ps,
30  double af1, bool tp, bool ta, int pi_country_code,
31  int pi_coverage_area, int pi_reference_number,
32  std::string radiotext);
33 
34  virtual void set_ps(std::string ps);
35 
36 private:
37  ~encoder_impl();
38 
39  int work(int noutput_items,
40  gr_vector_const_void_star &input_items,
41  gr_vector_void_star &output_items);
42 
43  unsigned int infoword[4];
44  unsigned int checkword[4];
45  unsigned int block[4];
46  unsigned char **buffer;
47  unsigned char pty_locale;
48 
49  // FIXME make this a struct (or a class)
50  unsigned char PTY;
51  unsigned char radiotext[64];
52  unsigned char PS[8];
53  bool TA;
54  bool TP;
55  bool MS;
56  unsigned int PI;
57  double AF1;
58 
59  int DP;
60  int extent;
61  int event;
62  int location;
63  gr::thread::mutex d_mutex;
64 
65 /* each type 0 group contains 2 out of 8 PS characters;
66  * this is used to count 0..3 and send all PS characters */
67  int d_g0_counter;
68 /* each type 2A group contains 4 out of 64 RadioText characters;
69  * each type 2B group contains 2 out of 32 RadioText characters;
70  * this is used to count 0..15 and send all RadioText characters */
71  int d_g2_counter;
72 /* points to the current buffer being prepared/streamed
73  * used in create_group() and in work() */
74  int d_current_buffer;
75 /* loops through the buffer, pushing out the symbols */
76  int d_buffer_bit_counter;
77  int groups[32];
78 /* nbuffers might be != ngroups, e.g. group 0A needs 4 buffers */
79  int nbuffers;
80 
81 // Functions
82  void rebuild();
83  void set_ms(bool ms);
84  void set_tp(bool tp);
85  void set_ta(bool ta);
86  void set_af1(double af1);
87  void set_pty(unsigned int pty);
88  void set_pi(unsigned int pty);
89  void set_radiotext(std::string text);
90 
91  void count_groups();
92  void create_group(const int, const bool);
93  void prepare_group0(const bool);
94  void prepare_group1a();
95  void prepare_group2(const bool);
96  void prepare_group3a();
97  void prepare_group4a();
98  void prepare_group8a();
99  void prepare_group11a();
100  void prepare_buffer(int);
101  unsigned int encode_af(double);
102  unsigned int calc_syndrome(unsigned long, unsigned char);
103  void rds_in(pmt::pmt_t msg);
104 };
105 
106 } /* namespace rds */
107 } /* namespace gr */
108 
109 #endif /* INCLUDED_RDS_ENCODER_IMPL_H */
Definition: encoder_impl.h:27
encoder_impl(unsigned char pty_locale, int pty, bool ms, std::string ps, double af1, bool tp, bool ta, int pi_country_code, int pi_coverage_area, int pi_reference_number, std::string radiotext)
virtual void set_ps(std::string ps)
Definition: encoder.h:27
Definition: decoder.h:23