GNU Radio's HIQSDR Package
source_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013 Stefan Goerg stefan@dl2stg.de
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_HIQSDR_SOURCE_IMPL_H
22 #define INCLUDED_HIQSDR_SOURCE_IMPL_H
23 
24 #include <hiqsdr/source.h>
25 
26 #define NLUT 128
27 
28 typedef std::complex<double> dcplx;
29 extern dcplx lut1[NLUT];
30 extern dcplx lut[NLUT];
31 extern int lutn[NLUT];
32 extern double lutPartAv[NLUT];
33 extern int lutPartUsed[NLUT];
34 extern int gr_hiqsdr_tx_samples;
35 extern int dpdState;
36 extern int testSig;
37 
38 #define DPD_OFF 0
39 #define DPD_SYNC_SEARCH_CORR 1
40 #define DPD_SYNC_SEARCH_FINE 2
41 #define DPD_LEARN 3
42 #define DPD_READY 4
43 #define DPD_READY_OFF 5
44 
45 #define TEST_SIG_NONE 0
46 #define TEST_SIG_TONE 1
47 #define TEST_SIG_2TONE 2
48 #define TEST_SIG_FM_NOICE 3
49 
50 
51 namespace gr {
52  namespace hiqsdr {
53 
54  class source_impl : public source
55  {
56  private:
57  size_t d_itemsize;
58  int d_payload_size; // maximum transmission unit (packet length)
59  bool d_eof; // zero-length packet is EOF
60  int d_socket; // handle to socket
61  // gruel::mutex d_mutex; // protects d_socket and d_connected
62  unsigned char *d_temp_buff; // hold buffer between between call
63  int byteMode;
64  unsigned char seqNr;
65  gr_complex outBuf[8192];
66  int outBufPos;
67  int rxRate,txRate;
68 
69  unsigned char ctlBuf[22];
70  unsigned char firBuf[80];
71  int c_socket;
72  int rx_fir_socket;
73  int tx_fir_socket;
74  int firmVersion;
75  bool cwMode;
76  int clockCorr;
77  bool dpd;
78  int lutParts;
79 
80  void hiqSend();
81  void closeSocket(int socket);
82  int openSocket (const char *host, unsigned short port);
83  void printDPDState();
84 
85  //void connect( const char *host, unsigned short port );
86 
87  void disconnect();
88  void calcDPD(std::vector<dcplx> rxData, std::vector<dcplx> txData);
89  std::vector<dcplx> rxData;
90  std::vector<dcplx> txData;
91  std::vector<dcplx> rxDelay;
92  std::vector<dcplx> fracDelay(std::vector<dcplx> &in, int fDelay);
93  int maxIdx1;
94  int rxDel,rxDel1,rxDel2;
95  double maxRx;
96  int cnt,found,sStep;
97 
98  public:
99  source_impl(size_t itemsize, const char *host,unsigned short port, unsigned short c_port, unsigned short rx_fir_port,
100  unsigned short tx_fir_port, int payload_size,bool eof, bool wait, int rxfreq, int txfreq, int rate,bool ant,
101  int presel, int att, int txLevel, bool ptt, int txRate, int clockCorr,
102  std::vector<gr_complex> rxFirTaps, std::vector<gr_complex> txFirTaps, bool dpd);
103  ~source_impl();
104 
105  // Where all the action really happens
106  int work(int noutput_items,
107  gr_vector_const_void_star &input_items,
108  gr_vector_void_star &output_items);
109 
110 
111  int payload_size() { return d_payload_size; }
112  int get_port();
113  void setRXFreq(int f);
114  void setTXFreq(int f);
115  void setSampleRate(int rate);
116  void setAnt(bool);
117  void setPresel(int);
118  void setAttenuator(int);
119  void setTXLevel(int l);
120  void setPtt(bool on);
121  void setTXRate(int);
122  void setCWMode(bool);
123  void setFilter(std::vector<gr_complex> coef, int dest=0);
124  void setClockCorr(int diff);
125  void setDPD(bool on);
126 
127  };
128 
129  } // namespace hiqsdr
130 } // namespace gr
131 
132 #endif /* INCLUDED_HIQSDR_SOURCE_IMPL_H */
133 
void setFilter(std::vector< gr_complex > coef, int dest=0)
int lutn[NLUT]
Definition: source_impl.h:54
dcplx lut[NLUT]
int gr_hiqsdr_tx_samples
int payload_size()
Definition: source_impl.h:111
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void setClockCorr(int diff)
int dpdState
void setSampleRate(int rate)
Definition: sink.h:28
std::complex< double > dcplx
Definition: source_impl.h:28
<+description of block+>
Definition: source.h:51
#define NLUT
Definition: source_impl.h:26
dcplx lut1[NLUT]
int testSig
source_impl(size_t itemsize, const char *host, unsigned short port, unsigned short c_port, unsigned short rx_fir_port, unsigned short tx_fir_port, int payload_size, bool eof, bool wait, int rxfreq, int txfreq, int rate, bool ant, int presel, int att, int txLevel, bool ptt, int txRate, int clockCorr, std::vector< gr_complex > rxFirTaps, std::vector< gr_complex > txFirTaps, bool dpd)
int lutPartUsed[NLUT]
double lutPartAv[NLUT]