Changeset 8942
- Timestamp:
- 07/18/08 19:39:57
- Files:
-
- gnuradio/branches/developers/eb/msdd/config/grc_gr_msdd6000.m4 (modified) (1 diff)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd.i (modified) (4 diffs)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd6000.cc (modified) (5 diffs)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd6000.h (modified) (1 diff)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_base.cc (modified) (5 diffs)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_c.cc (modified) (2 diffs)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_s.cc (modified) (2 diffs)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_simple.cc (modified) (10 diffs)
- gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_simple.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/developers/eb/msdd/config/grc_gr_msdd6000.m4
r8782 r8942 29 29 GRC_CHECK_DEPENDENCY(gr-msdd6000, gnuradio-core) 30 30 31 AC_CHECK_HEADERS(netinet/in.h arpa/inet.h sys/socket.h netdb.h) 32 31 33 GRC_BUILD_CONDITIONAL([gr-msdd6000],[ 32 34 dnl run_tests is created from run_tests.in. Make it executable. gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd.i
r8783 r8942 51 51 unsigned short port_src 52 52 ) throw (std::runtime_error); 53 54 /*!55 * \brief return number of msdd input bytes required to produce noutput items.56 */57 int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;58 53 59 54 /*! … … 225 220 ) throw (std::runtime_error); 226 221 227 virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);228 229 222 public: 230 223 ~msdd_source_s (); … … 250 243 ) throw (std::runtime_error); 251 244 252 virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items);253 254 245 public: 255 246 ~msdd_source_c (); … … 277 268 public: 278 269 ~msdd_source_c(); 279 int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0;280 270 int work (int noutput_items, 281 271 gr_vector_const_void_star &input_items, gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd6000.cc
r8782 r8942 1 #include "msdd6000.h" 1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2008 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 along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 */ 21 #ifdef HAVE_CONFIG_H 22 #include <config.h> 23 #endif 24 #include <msdd6000.h> 2 25 3 26 #include <stdio.h> 4 #include <netinet/in.h>5 #include <sys/socket.h>6 27 #include <string.h> 7 28 #include <unistd.h> 8 29 9 void optimize_socket(int socket); 10 11 MSDD6000::MSDD6000(char* addr){ 30 #ifdef HAVE_ARPA_INET_H 31 #include <arpa/inet.h> 32 #endif 33 #ifdef HAVE_NETINET_IN_H 34 #include <netinet/in.h> 35 #endif 36 #ifdef HAVE_SYS_SOCKET_H 37 #include <sys/socket.h> 38 #endif 39 40 #define DEBUG(A) printf("=debug=> %s\n", A) 41 42 static void 43 optimize_socket(int socket); 44 45 /* 46 * Holds types that need autoconf help. They're here and not in the .h file because 47 * here we've got access to config.h 48 */ 49 class MSDD6000::detail { 50 public: 51 struct sockaddr_in d_sockaddr; 52 }; 53 54 55 MSDD6000::MSDD6000(char* addr) 56 : d_detail(new MSDD6000::detail()) 57 { 12 58 d_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); 13 59 … … 17 63 // set up remote sockaddr 18 64 // int s = inet_aton(addr, &d_adx); 19 d_ sockaddr.sin_family = AF_INET;20 d_ sockaddr.sin_port = htons(10000);21 int s = inet_aton(addr, &d_ sockaddr.sin_addr);65 d_detail->d_sockaddr.sin_family = AF_INET; 66 d_detail->d_sockaddr.sin_port = htons(10000); 67 int s = inet_aton(addr, &d_detail->d_sockaddr.sin_addr); 22 68 23 69 // set up local sockaddr 70 struct in_addr d_myadx; 71 struct sockaddr_in d_mysockaddr; 24 72 short int port = 10010; 25 73 d_myadx.s_addr = INADDR_ANY; … … 38 86 39 87 40 void optimize_socket(int socket){ 88 static void 89 optimize_socket(int socket){ 41 90 #define BANDWIDTH 1000000000/8 42 91 #define DELAY 0.5 43 92 int ret; 44 93 45 int sock_buf_size = 2*BANDWIDTH*DELAY;94 int sock_buf_size = static_cast<int>(2*BANDWIDTH*DELAY); 46 95 char textbuf[512]; 47 s printf(textbuf, "%d", sock_buf_size);96 snprintf(textbuf, sizeof(textbuf), "%d", sock_buf_size); 48 97 printf("sock_buf_size = %d\n", sock_buf_size); 49 98 50 ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF,51 (char *)&sock_buf_size, sizeof(sock_buf_size));52 53 ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF,54 (char *)&sock_buf_size, sizeof(sock_buf_size));99 ret = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, 100 &sock_buf_size, sizeof(sock_buf_size)); 101 102 ret = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, 103 &sock_buf_size, sizeof(sock_buf_size)); 55 104 56 105 int uid = getuid(); … … 62 111 63 112 // SET UP SOME SYSTEM WIDE TCP SOCKET PARAMETERS 113 // FIXME seems like kind of a big hammer. Are you sure you need this? 64 114 FILE* fd = fopen("/proc/sys/net/core/netdev_max_backlog", "w"); 65 fwrite("10000", 1, strlen("10000"), fd); 66 fclose(fd); 115 if (fd){ 116 fwrite("10000", 1, strlen("10000"), fd); 117 fclose(fd); 118 } 67 119 68 120 fd = fopen("/proc/sys/net/core/rmem_max", "w"); 69 fwrite(textbuf, 1, strlen(textbuf), fd); 70 fclose(fd); 121 if (fd){ 122 fwrite(textbuf, 1, strlen(textbuf), fd); 123 fclose(fd); 124 } 71 125 72 126 fd = fopen("/proc/sys/net/core/wmem_max", "w"); 73 fwrite(textbuf, 1, strlen(textbuf), fd); 74 fclose(fd); 127 if (fd){ 128 fwrite(textbuf, 1, strlen(textbuf), fd); 129 fclose(fd); 130 } 75 131 76 132 // just incase these were rejected before because of max sizes... … … 135 191 printf("sending: %s\n", buff); 136 192 int flags = 0; 137 sendto( d_sock, buff, strlen(buff)+1, flags, (const sockaddr*)&d_sockaddr, sizeof(d_sockaddr)); 193 sendto( d_sock, buff, strlen(buff)+1, flags, 194 (const sockaddr*)&(d_detail->d_sockaddr), sizeof(d_detail->d_sockaddr)); 138 195 } 139 196 gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd6000.h
r8782 r8942 2 2 #define MSDD6000_H 3 3 4 #include <netinet/in.h> 5 #include <arpa/inet.h> 6 #include <linux/socket.h> 7 8 #define DEBUG(A) printf("=debug=> %s\n", A) 9 10 #define STATE_STOPPED 0 11 #define STATE_STARTED 1 4 #include <boost/scoped_ptr.hpp> 12 5 13 6 class MSDD6000 { 14 public: 15 MSDD6000(char* addr); 16 17 void set_decim(int decim_pow2); 18 void set_fc(int center_mhz, int offset_hz); 19 void set_ddc_gain(int gain); 20 void set_rf_attn(int attn); 7 class detail; 21 8 22 void set_output(int mode, void* arg); 9 //! holds objects with system dependent types 10 boost::scoped_ptr<detail> d_detail; 23 11 24 void start(); 25 void stop(); 12 public: 13 14 enum state { 15 STATE_STOPPED, STATE_STARTED, 16 }; 17 18 MSDD6000(char* ip_addr); 19 ~MSDD6000(); 20 21 void set_decim(int decim_pow2); 22 void set_fc(int center_mhz, int offset_hz); 23 void set_ddc_gain(int gain); 24 void set_rf_attn(int attn); 25 26 void set_output(int mode, void* arg); 27 28 void start(); 29 void stop(); 26 30 27 void send_request(float,float,float,float,float);28 int read(char*, int);31 void send_request(float,float,float,float,float); 32 int read(char*, int); 29 33 30 int d_decim; 31 int d_fc_mhz; 32 int d_offset_hz; 33 int d_rf_attn; 34 int d_ddc_gain; 34 int d_decim; 35 int d_fc_mhz; 36 int d_offset_hz; 37 int d_rf_attn; 38 int d_ddc_gain; 39 int d_sock; 40 state d_state; 35 41 36 // in_addr d_adx;37 in_addr d_myadx;38 39 struct sockaddr_in d_sockaddr;40 struct sockaddr_in d_mysockaddr;41 42 int d_sock;43 int d_state;44 42 }; 45 43 46 44 47 48 49 50 51 45 #endif gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_base.cc
r8782 r8942 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2004 Free Software Foundation, Inc.3 * Copyright 2004,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This file is part of GNU Radio … … 25 25 26 26 #ifdef HAVE_CONFIG_H 27 #include "config.h"27 #include <config.h> 28 28 #endif 29 29 … … 31 31 #include <gr_io_signature.h> 32 32 #include <assert.h> 33 #include <netdb.h>34 33 #include <omnithread.h> 35 34 #include <stdexcept> 35 #include <iostream> 36 #ifdef HAVE_NETDB_H 37 #include <netdb.h> 38 #endif 39 #ifdef HAVE_SYS_SOCKET_H 36 40 #include <sys/socket.h> 41 #endif 42 #ifdef HAVE_ARPA_INET_H 37 43 #include <arpa/inet.h> 44 #endif 45 38 46 39 47 #ifdef MSDD_DEBUG_TRUE 40 #include <iostream>41 48 #define MSDD_DEBUG(x) std::cout << x << std::endl; 42 49 #else … … 46 53 47 54 #ifdef MSDD_DEBUG2_TRUE 48 #include <iostream>49 55 #define MSDD_DEBUG2(x) std::cout << x << std::endl; 50 56 #else … … 52 58 #endif 53 59 54 #include <iostream>55 60 56 61 namespace { gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_c.cc
r8782 r8942 22 22 23 23 #ifdef HAVE_CONFIG_H 24 #include "config.h"24 #include <config.h> 25 25 #endif 26 #include <msdd_source_c.h> 27 #include <gr_io_signature.h> 26 28 27 29 //#define MSDD_DEBUG2_TRUE … … 34 36 #endif 35 37 36 #include <msdd_source_c.h>37 #include <gr_io_signature.h>38 38 39 39 namespace { gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_s.cc
r8782 r8942 22 22 23 23 #ifdef HAVE_CONFIG_H 24 #include "config.h"24 #include <config.h> 25 25 #endif 26 #include <msdd_source_s.h> 27 #include <gr_io_signature.h> 26 28 27 29 #define MSDD_DEBUG2_TRUE … … 34 36 #endif 35 37 36 #include <msdd_source_s.h>37 #include <gr_io_signature.h>38 38 39 39 namespace { gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_simple.cc
r8782 r8942 1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2008 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 along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 */ 1 21 #ifdef HAVE_CONFIG_H 2 #include "config.h"22 #include <config.h> 3 23 #endif 4 24 5 #include <vector>6 25 #include <msdd_source_simple.h> 7 26 #include <gr_io_signature.h> 8 #include <gr_sync_block.h>9 10 #ifndef FALSE11 #define FALSE (0==1)12 #define TRUE (0==0)13 #endif14 27 15 28 … … 25 38 unsigned short port_src) 26 39 : gr_sync_block("MSDD_SOURCE_SIMPLE", 27 gr_make_io_signature (0,0,0), 28 gr_make_io_signature (1, 1, sizeof (short))) 40 gr_make_io_signature (0,0,0), 41 gr_make_io_signature (1, 1, sizeof (short))), 42 rcv(new MSDD6000((char*) src)), d_lastseq(0) 29 43 { 30 rcv = new MSDD6000((char*)src);31 44 } 45 46 msdd_source_simple::~msdd_source_simple () 47 { 48 } 49 32 50 33 51 int … … 46 64 int seq = *((int*) &buffer[2]); 47 65 66 // FIXME get rid of these magic 366's! 48 67 if(d_lastseq == -366){ 49 68 // not started case … … 79 98 bool msdd_source_simple::set_decim_rate(unsigned int rate) 80 99 { 81 rcv->set_decim(log2(rate)); 82 return TRUE; 100 // FIXME seems buggy. How about a floor or ceil? 101 rcv->set_decim((int) log2(rate)); 102 return true; 83 103 } 84 104 … … 88 108 long new_fc = (long)freq; 89 109 rcv->set_fc( new_fc/1000000, new_fc%1000000); 90 return TRUE;110 return true; 91 111 } 92 112 … … 96 116 if(gain < 0 || gain > 10){ 97 117 printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n"); 98 return FALSE;118 return false; 99 119 } 100 120 // ok i lied this is not really a pga, its decimation gain 101 121 rcv->set_ddc_gain((int)gain); 102 return TRUE; 103 } 104 105 106 msdd_source_simple::~msdd_source_simple () 107 { 108 delete rcv; 122 return true; 109 123 } 110 124 … … 113 127 { 114 128 rcv->start(); 129 return true; 115 130 } 116 131 … … 119 134 { 120 135 rcv->stop(); 121 } 122 123 int msdd_source_simple::ninput_bytes_reqd_for_noutput_items(int out){ 124 return 0; 136 return true; 125 137 } 126 138 … … 130 142 131 143 int msdd_source_simple::decim_rate(){ 132 return pow(2, rcv->d_decim);144 return 1 << rcv->d_decim; 133 145 } 134 146 … … 147 159 return r; 148 160 } 149 gnuradio/branches/developers/eb/msdd/gr-msdd6000/src/msdd_source_simple.h
r8782 r8942 1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2008 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 along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 */ 1 21 #ifndef INCLUDED_MSDD_SOURCE_SIMPLE_H 2 22 #define INCLUDED_MSDD_SOURCE_SIMPLE_H 3 23 4 #include <stdexcept>5 #include <sys/socket.h>6 #include <netinet/in.h>7 #include <arpa/inet.h>8 #include <stdio.h>9 24 #include <gr_sync_block.h> 10 25 #include <msdd6000.h> 26 #include <boost/scoped_ptr.hpp> 11 27 12 28 … … 20 36 21 37 22 23 38 class msdd_source_simple : public gr_sync_block { 24 39 private: … … 26 41 msdd_make_source_simple ( const char *src, unsigned short port_src); 27 42 28 MSDD6000*rcv;43 boost::scoped_ptr<MSDD6000> rcv; 29 44 int d_lastseq; 30 45 … … 34 49 public: 35 50 ~msdd_source_simple (); 36 int ninput_bytes_reqd_for_noutput_items(int out);37 51 bool stop(); 38 52 bool start();
