diff options
author | max <max@65a5c917-d112-43f1-993d-58c26a4786be> | 2013-04-03 01:01:31 +0000 |
---|---|---|
committer | max <max@65a5c917-d112-43f1-993d-58c26a4786be> | 2013-04-03 01:01:31 +0000 |
commit | f1cc160cab383bc399656e5192746efc853267a4 (patch) | |
tree | 9135f605fcdb142185d8e79783c5a98fe7b64fde | |
parent | f190b7fd6abf412d53fb827aba8da68eb7967e4d (diff) |
add new complex symbol rx mode
git-svn-id: http://op25.osmocom.org/svn/trunk@313 65a5c917-d112-43f1-993d-58c26a4786be
-rw-r--r-- | repeater/src/lib/repeater.i | 4 | ||||
-rw-r--r-- | repeater/src/lib/repeater_chan_usrp_rx.cc | 43 | ||||
-rw-r--r-- | repeater/src/lib/repeater_chan_usrp_rx.h | 13 |
3 files changed, 43 insertions, 17 deletions
diff --git a/repeater/src/lib/repeater.i b/repeater/src/lib/repeater.i index f764821..f788019 100644 --- a/repeater/src/lib/repeater.i +++ b/repeater/src/lib/repeater.i @@ -163,13 +163,13 @@ private: // ---------------------------------------------------------------- GR_SWIG_BLOCK_MAGIC(repeater,chan_usrp_rx); -repeater_chan_usrp_rx_sptr repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug); +repeater_chan_usrp_rx_sptr repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size); class repeater_chan_usrp_rx : public gr_block { private: - repeater_chan_usrp_rx (const char* udp_host, int port, int debug); // private constructor + repeater_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size); // private constructor public: void unkey(void); diff --git a/repeater/src/lib/repeater_chan_usrp_rx.cc b/repeater/src/lib/repeater_chan_usrp_rx.cc index be83401..02775ba 100644 --- a/repeater/src/lib/repeater_chan_usrp_rx.cc +++ b/repeater/src/lib/repeater_chan_usrp_rx.cc @@ -19,10 +19,11 @@ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * + * This file is part of OP25 + * repeater_chan_usrp_rx Copyright 2010-2013 KA1RBI + * */ -static const int phase_table[4] = {+1, +3, -1, -3}; - /* * config.h is generated by configure. It contains the results * of probing for features, options etc. It should be the first @@ -54,29 +55,39 @@ static const int phase_table[4] = {+1, +3, -1, -3}; #define min(a,b) ((a<b)?a:b) #endif +static const int phase_table[4] = {+1, +3, -1, -3}; +static const int COMPLEX_FRAME_SIZE = 96 * sizeof(gr_complex); // 4800 * 0.02 + /* * Create a new instance of repeater_chan_usrp_rx and return * a boost shared_ptr. This is effectively the public constructor. */ repeater_chan_usrp_rx_sptr -repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug) +repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size) { - return repeater_chan_usrp_rx_sptr (new repeater_chan_usrp_rx(udp_host, port, debug)); + return repeater_chan_usrp_rx_sptr (new repeater_chan_usrp_rx(udp_host, port, debug, input_size)); } /* * The private constructor */ -repeater_chan_usrp_rx::repeater_chan_usrp_rx (const char* udp_host, int port, int debug) +repeater_chan_usrp_rx::repeater_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size) : gr_block ("chan_usrp_rx", - gr_make_io_signature (1, 1, sizeof(short)), + gr_make_io_signature (1, 1, input_size), gr_make_io_signature (0, 0, 0)), d_udp_host(udp_host), d_port(port), d_debug(debug), d_sampbuf_ct(0), - d_sendseq(0) + d_sendseq(0), + d_input_size(input_size), + d_buf_data_size ((input_size == sizeof(gr_complex)) ? COMPLEX_FRAME_SIZE : USRP_VOICE_FRAME_SIZE), + d_max_sampbuf_ct(d_buf_data_size / d_input_size) { + assert(input_size == sizeof(int16_t) || input_size == sizeof(gr_complex)); + + write_buf = new char[sizeof(struct _chan_usrp_bufhdr) + d_buf_data_size]; + init_sock(udp_host, port); } @@ -84,6 +95,8 @@ repeater_chan_usrp_rx::~repeater_chan_usrp_rx () { if (write_sock > 0) close(write_sock); + + delete [] write_buf; } static int sends, samps; @@ -95,8 +108,13 @@ repeater_chan_usrp_rx::general_work (int noutput_items, gr_vector_void_star &output_items) { struct timeval tv; + const int16_t *in = (const int16_t *) input_items[0]; int16_t *sampbuf = (int16_t *) &write_buf[sizeof(struct _chan_usrp_bufhdr)]; + + const gr_complex *in_c = (const gr_complex *) input_items[0]; + gr_complex *sampbuf_c = (gr_complex *) &write_buf[sizeof(struct _chan_usrp_bufhdr)]; + struct _chan_usrp_bufhdr *bufhdrp = (struct _chan_usrp_bufhdr*) write_buf; gettimeofday(&tv, NULL); // fprintf(stderr, "sec %lu usec %lu output %d\n", tv.tv_sec, tv.tv_usec, noutput_items); @@ -104,16 +122,19 @@ repeater_chan_usrp_rx::general_work (int noutput_items, int consumed = 0; for (int i = 0; i < noutput_items; i++) { - int16_t samp = in[i]; - sampbuf[d_sampbuf_ct++] = samp; + if (d_input_size == sizeof(gr_complex)) { + sampbuf_c[d_sampbuf_ct++] = in_c[i]; + } else { + sampbuf[d_sampbuf_ct++] = in[i]; + } consumed++; - if (d_sampbuf_ct >= (USRP_VOICE_FRAME_SIZE>>1)) { + if (d_sampbuf_ct >= d_max_sampbuf_ct) { d_sampbuf_ct = 0; memset(bufhdrp, 0, sizeof(struct _chan_usrp_bufhdr)); memcpy(bufhdrp->eye, "USRP", 4); bufhdrp->seq = htonl(d_sendseq++); bufhdrp->keyup = htonl(1); - int rc = sendto(write_sock, write_buf, sizeof(struct _chan_usrp_bufhdr) + USRP_VOICE_FRAME_SIZE, 0, (struct sockaddr *)&write_sock_addr, sizeof(write_sock_addr)); + int rc = sendto(write_sock, write_buf, sizeof(struct _chan_usrp_bufhdr) + d_buf_data_size, 0, (struct sockaddr *)&write_sock_addr, sizeof(write_sock_addr)); // gettimeofday(&tv, NULL); // fprintf(stderr, "rc %d sends %d samps %u sec %lu usec %lu\n", rc, sends++, samps, tv.tv_sec, tv.tv_usec); break; diff --git a/repeater/src/lib/repeater_chan_usrp_rx.h b/repeater/src/lib/repeater_chan_usrp_rx.h index 0391766..ca95ed1 100644 --- a/repeater/src/lib/repeater_chan_usrp_rx.h +++ b/repeater/src/lib/repeater_chan_usrp_rx.h @@ -57,7 +57,7 @@ typedef std::deque<uint8_t> dibit_queue; * constructor is private. repeater_make_chan_usrp_rx is the public * interface for creating new instances. */ -repeater_chan_usrp_rx_sptr repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug); +repeater_chan_usrp_rx_sptr repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size); class repeater_chan_usrp_rx : public gr_block { @@ -67,9 +67,9 @@ private: void init_sock(const char* udp_host, int udp_port); - friend repeater_chan_usrp_rx_sptr repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug); + friend repeater_chan_usrp_rx_sptr repeater_make_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size); - repeater_chan_usrp_rx (const char* udp_host, int port, int debug); + repeater_chan_usrp_rx (const char* udp_host, int port, int debug, int input_size); // internal functions // internal data @@ -83,7 +83,12 @@ private: unsigned int d_sampbuf_ct; unsigned int d_sendseq; - char write_buf[ sizeof(struct _chan_usrp_bufhdr) + USRP_VOICE_FRAME_SIZE*sizeof(int16_t) ]; +// char write_buf[ sizeof(struct _chan_usrp_bufhdr) + USRP_VOICE_FRAME_SIZE*sizeof(int16_t) ]; + char *write_buf; + + int d_input_size; + int d_buf_data_size; + unsigned int d_max_sampbuf_ct; public: ~repeater_chan_usrp_rx (); // public destructor |