GNU Radio's DAB Package
dab_measure_ber_b.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2007 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 #ifndef INCLUDED_DAB_MEASURE_BER_B_H
24 #define INCLUDED_DAB_MEASURE_BER_B_H
25 
26 #include <gr_sync_block.h>
27 
28 class dab_measure_ber_b;
29 typedef boost::shared_ptr<dab_measure_ber_b> dab_measure_ber_b_sptr;
30 
31 dab_measure_ber_b_sptr dab_make_measure_ber_b();
32 
33 /*!
34  * \brief Measure bit error rate of a byte stream
35  *
36  * input: port 0: actual byte stream
37  * input: port 1: expected byte stream
38  *
39  * \ingroup sink
40  */
41 class dab_measure_ber_b : public gr_sync_block
42 {
43  friend dab_measure_ber_b_sptr dab_make_measure_ber_b();
44 
45  private:
46  unsigned long d_bytes;
47  unsigned long d_errors;
48 
49  protected:
50  unsigned int bits_set(char byte);
52 
53  public:
54  /*! clear error and byte count */
55  void clear() { d_errors=0; d_bytes=0; }
56  /*! \return bit error rate */
57  float ber() { return (float)d_errors/(float)(d_bytes*8); }
58  /*! \return number of received bytes */
59  unsigned long bytecount() { return d_bytes; }
60  /*! \return number of received bits */
61  unsigned long bitcount() { return 8*d_bytes; }
62  /*! \return number of received bits with errors */
63  unsigned long errorcount() { return d_errors; }
64 
65  int work(int noutput_items,
66  gr_vector_const_void_star &input_items,
67  gr_vector_void_star &output_items);
68 };
69 
70 #endif /* INCLUDED_DAB_MEASURE_BER_B_H */
friend dab_measure_ber_b_sptr dab_make_measure_ber_b()
float ber()
Definition: dab_measure_ber_b.h:57
void clear()
Definition: dab_measure_ber_b.h:55
dab_measure_ber_b_sptr dab_make_measure_ber_b()
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
unsigned long bitcount()
Definition: dab_measure_ber_b.h:61
unsigned int bits_set(char byte)
unsigned long bytecount()
Definition: dab_measure_ber_b.h:59
Measure bit error rate of a byte stream.
Definition: dab_measure_ber_b.h:41
unsigned long errorcount()
Definition: dab_measure_ber_b.h:63