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();
30 
31 private:
32  ~encoder_impl();
33 
34  int work(int noutput_items,
35  gr_vector_const_void_star &input_items,
36  gr_vector_void_star &output_items);
37 
38  unsigned int infoword[4];
39  unsigned int checkword[4];
40  unsigned int block[4];
41  unsigned char **buffer;
42 
43  // FIXME make this a struct (or a class)
44  unsigned char PTY;
45  char radiotext[64];
46  char PS[8];
47  bool TA;
48  bool TP;
49  bool MS;
50  unsigned int PI;
51  double AF1;
52  double AF2;
53 
54  int DP;
55  int extent;
56  int event;
57  int location;
58  gr::thread::mutex d_mutex;
59 
60 /* each type 0 group contains 2 out of 8 PS characters;
61  * this is used to count 0..3 and send all PS characters */
62  int d_g0_counter;
63 /* each type 2A group contains 4 out of 64 RadioText characters;
64  * each type 2B group contains 2 out of 32 RadioText characters;
65  * this is used to count 0..15 and send all RadioText characters */
66  int d_g2_counter;
67 /* points to the current buffer being prepared/streamed
68  * used in create_group() and in work() */
69  int d_current_buffer;
70 /* loops through the buffer, pushing out the symbols */
71  int d_buffer_bit_counter;
72  int groups[32];
73 /* nbuffers might be != ngroups, e.g. group 0A needs 4 buffers */
74  int nbuffers;
75 
76 // Functions
77  void rebuild();
78  void set_ms(bool ms);
79  void set_tp(bool tp);
80  void set_ta(bool ta);
81  void set_af1(double af1);
82  void set_af2(double af2);
83  void set_pty(unsigned int pty);
84  void set_pi(unsigned int pty);
85  void set_radiotext(std::string text);
86  void set_ps(std::string text);
87  void count_groups();
88  void create_group(const int, const bool);
89  void prepare_group0(const bool);
90  void prepare_group1a();
91  void prepare_group2(const bool);
92  void prepare_group3a();
93  void prepare_group4a();
94  void prepare_group8a();
95  void prepare_group11a();
96  void prepare_buffer(int);
97  unsigned int encode_af(double);
98  unsigned int calc_syndrome(unsigned long, unsigned char);
99  void rds_in(pmt::pmt_t msg);
100 };
101 
102 } /* namespace rds */
103 } /* namespace gr */
104 
105 #endif /* INCLUDED_RDS_ENCODER_IMPL_H */
106 
107 
Definition: encoder_impl.h:26
Definition: decoder.h:23
Definition: encoder.h:26