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 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 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