Clean up of comments and removal of a broken piece of test code that no longer works...
authorn4hy <n4hy@221aa14e-8319-0410-a670-987f0aec2ac5>
Sun, 13 Jul 2008 21:18:48 +0000 (21:18 +0000)
committern4hy <n4hy@221aa14e-8319-0410-a670-987f0aec2ac5>
Sun, 13 Jul 2008 21:18:48 +0000 (21:18 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8881 221aa14e-8319-0410-a670-987f0aec2ac5

gr-msdd6000/src/README
gr-msdd6000/src/non_gr_snapshot_tool/Makefile [deleted file]
gr-msdd6000/src/non_gr_snapshot_tool/client5.cc [deleted file]
gr-msdd6000/src/non_gr_snapshot_tool/msdd6000.cc [deleted file]
gr-msdd6000/src/non_gr_snapshot_tool/msdd6000.h [deleted file]
gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py [deleted file]
gr-msdd6000/src/non_gr_snapshot_tool/spectrogram.py [deleted file]
gr-msdd6000/src/python-examples/msdd_plot_psd.py [deleted file]

index 82a4fc04899df784cbac331d3a855fc9d681ebb9..230b7b6cfeb142ddd3d480e44c3f2175d3d0049c 100644 (file)
@@ -1,24 +1,9 @@
-Softronics/GR Driver Info
-
-Jul 9, 2008
-TJO
+This block implements an interface between the Softronics MSDD6000 and GR
 
+Jul 13, 2008
 
 Tools / Waveforms
        
-       - non_gr_snapshot_tool
-               simple tool to capture
-               fixed length snapshots to a file
-               compile with make and run 
-               with ./cap4
-               edit client5.cc variables to 
-               set parameters.
-
-               ./plot_psd.py <cap file>
-               and
-               ./spectrogram.py <cap file>
-       
-               may be used for analysis
 
        - python-examples/new_msdd/fft.py
                A clone of the original usrp_fft.py
@@ -47,7 +32,3 @@ GNU Radio Blocks,
                data was never streamed
                without discontinuities
                through this method.
-
-
-
-
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/Makefile b/gr-msdd6000/src/non_gr_snapshot_tool/Makefile
deleted file mode 100644 (file)
index 213d68e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-CCFLAGS        = -O3
-LDFLAGS        = -lpthread
-FFTW_LDFLAGS = -lfftw3f
-
-
-all:   
-       g++ $(CCFLAGS) -c client5.cc
-       g++ $(CCFLAGS) -c msdd6000.cc
-       g++ $(CCFLAGS) -o cap4 client5.o msdd6000.o $(LDFLAGS)
-
-
-clean:
-       rm test.out*
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/client5.cc b/gr-msdd6000/src/non_gr_snapshot_tool/client5.cc
deleted file mode 100644 (file)
index fe753be..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "msdd6000.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-
-#define MSDD_HOST      "192.168.1.200"
-int decim = 2;
-float fc = 3500000000.0;
-int gain = 1;
-
-//long target_buf_size = 256*1024*1024; // 2 gig output when converted to floats
-long target_buf_size = 1024*1024;
-#define CHUNK_SIZE     (366*2)*sizeof(short)+6
-#define OUTPUT_FILE    "CAPTURE_FILE.DAT"
-
-char* buffer;
-long int buffer_size;
-sem_t buf_sem;
-sem_t lock;
-
-long int in_ptr;
-long int out_ptr;
-char** argvg;
-
-
-int main(int argc, char* argv[]){
-               
-       int prio = getpriority(PRIO_PROCESS, getpid());
-       printf("prio = %d\n", prio);
-
-       // renice to -20
-       setpriority(PRIO_PROCESS, getpid(), -20);
-
-       prio = getpriority(PRIO_PROCESS, getpid());
-       printf("new prio = %d\n", prio);
-
-       
-       argvg = argv;
-
-       // instantiate our reciever instance
-       MSDD6000 rcv((char*)MSDD_HOST);
-       
-       // set up desired rcv parameters
-       
-       int tune_mhz = long(fc)/1000000;
-       int tune_hz = long(fc)%1000000;
-       printf("mhz = %d   hz = %d\n", tune_mhz, tune_hz);
-       
-       rcv.set_decim(decim);
-       rcv.set_fc(tune_mhz, tune_hz); // tune frequency in mhz, and ddc fine tuning in hz
-       rcv.set_ddc_gain(gain); // careful, too much gain will cause bit-clipping (this simply chooses which 16 bits to map in 0=high order)
-       rcv.set_rf_attn(10);  // adjusted variable attenuator in front of adc (0-32dB i think)
-       
-       // send start command
-       rcv.start();
-       
-       // allocate our recieve buffer
-
-       buffer_size = ((long)CHUNK_SIZE) * (target_buf_size/CHUNK_SIZE);
-
-       printf("Allocating Intermediate Buffer.  %f MB\n", ((float)buffer_size)/(1024.0*1024));
-       buffer = (char*)malloc(buffer_size);
-       in_ptr = out_ptr = 0;
-       printf("malloc returns %x.\n", buffer);
-       
-       while(in_ptr + CHUNK_SIZE < buffer_size){
-               rcv.read( &buffer[in_ptr], CHUNK_SIZE );
-               in_ptr+=CHUNK_SIZE;
-               }
-       
-       printf("done.\n");
-               
-       int lastseq = -1;
-       int discont = 0;
-
-       float fbuf[366*2];
-
-       FILE* fd = fopen(OUTPUT_FILE, "w");
-
-       for(long long i=0;i<buffer_size;i += CHUNK_SIZE){
-               int seq = *((int*) &buffer[i + 2] );
-               if(seq == 0){
-//                     printf( "seq = %d, lastseq = %d at i = %d\n", seq, lastseq, i);
-               }
-               if(lastseq == -1){
-                       if(seq==0){
-//                             printf("found start... starting...\n");
-                               lastseq = seq;
-                       }
-               } else {
-                       if(seq != lastseq+366){
-//                             printf("seq gap, %d -> %d\n", lastseq, seq);
-                               if(seq==0){
-//                                     printf("stopping at i=%d\n", i);
-                                       break;
-                                       } else {
-//                                     printf("this is a bad discontinuity!!! :{\n");
-                                       discont++;
-                                       }
-                       } else {
-                               // this is good data, and we are started
-                               for(int j = 0; j<366*2; j++){
-                                       long ptr = i+6+j*2;
-//                                     printf("%x %x \n", buffer[ptr], buffer[ptr+1]);
-                                       short int sample_data = (*(( signed short*) &buffer[ptr]));
-//                                     printf("%d\n", sample_data);
-                                       fbuf[j] = (float) sample_data;
-//                                     printf("%f\n", fbuf[j]);
-                                       
-                               }       
-                               fwrite(fbuf, sizeof(float), 366*2, fd);
-                       }
-                       lastseq = seq;
-               }
-       }
-
-       fclose(fd);
-       
-       printf("total discontinuities = %d\n", discont);
-       
-}
-
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/msdd6000.cc b/gr-msdd6000/src/non_gr_snapshot_tool/msdd6000.cc
deleted file mode 100644 (file)
index a205587..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "msdd6000.h"
-
-#include <stdio.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <string.h>
-#include <unistd.h>
-
-void optimize_socket(int socket);
-
-MSDD6000::MSDD6000(char* addr){
-       d_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
-       
-       optimize_socket(d_sock);
-       
-       
-       // set up remote sockaddr
-//     int s = inet_aton(addr, &d_adx); 
-       d_sockaddr.sin_family = AF_INET;
-       d_sockaddr.sin_port = htons(10000);
-       int s = inet_aton(addr, &d_sockaddr.sin_addr);
-       
-       // set up local sockaddr
-       short int port = 10010;
-       d_myadx.s_addr = INADDR_ANY;
-       d_mysockaddr.sin_family = AF_INET;
-       d_mysockaddr.sin_port = htons(port);
-       memcpy(&d_mysockaddr.sin_addr.s_addr, &d_myadx.s_addr, sizeof(in_addr));
-       //d_sockaddr.sin_addr = INADDR_ANY;
-       s = bind(d_sock, (const sockaddr*) &d_mysockaddr, sizeof(d_mysockaddr));
-       
-       // set default values
-       d_decim = 2;
-       d_ddc_gain = 2;
-       d_rf_attn = 0;
-       d_state = STATE_STOPPED;
-}
-
-
-void optimize_socket(int socket){
-#define BANDWIDTH      1000000000/8
-#define DELAY          0.5
-       int ret;
-
-       int sock_buf_size = 2*BANDWIDTH*DELAY;
-       char textbuf[512];
-       sprintf(textbuf, "%d", sock_buf_size);
-       printf("sock_buf_size = %d\n", sock_buf_size);
-       
-       ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF,
-                   (char *)&sock_buf_size, sizeof(sock_buf_size) );
-
-       ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF,
-                   (char *)&sock_buf_size, sizeof(sock_buf_size) );
-       
-       int uid = getuid();
-       if(uid!=0){
-               printf(" ****** COULD NOT OPTIMIZE SYSTEM NETWORK PARAMETERS BECAUSE YOU ARE NOT RUNNING AS ROOT *******\n ****** YOUR MSDD6000 RECIEVER PERFORMANCE IS GOING TO BE TERRIBLE *******\n");
-               return;
-       }
-
-
-       // SET UP SOME SYSTEM WIDE TCP SOCKET PARAMETERS
-       FILE* fd = fopen("/proc/sys/net/core/netdev_max_backlog", "w");
-       fwrite("10000", 1, strlen("10000"), fd);
-       fclose(fd);
-
-       fd = fopen("/proc/sys/net/core/rmem_max", "w");
-       fwrite(textbuf, 1, strlen(textbuf), fd);
-       fclose(fd);
-
-       fd = fopen("/proc/sys/net/core/wmem_max", "w");
-       fwrite(textbuf, 1, strlen(textbuf), fd);
-       fclose(fd);
-
-       // just incase these were rejected before because of max sizes...
-
-       ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF,
-                   (char *)&sock_buf_size, sizeof(sock_buf_size) );
-
-       ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF,
-                   (char *)&sock_buf_size, sizeof(sock_buf_size) );
-       
-}
-
-
-void MSDD6000::set_decim(int decim_pow2){
-       DEBUG("SETTING NEW DECIM");
-       d_decim = decim_pow2;
-
-       if(d_state==STATE_STARTED)
-               send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
-}
-
-void MSDD6000::set_rf_attn(int attn){
-       DEBUG("SETTING NEW RF ATTN");
-       d_rf_attn = attn;
-       if(d_state==STATE_STARTED)
-               send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
-}
-
-void MSDD6000::set_ddc_gain(int gain){
-       DEBUG("SETTING NEW DDC GAIN");
-       d_ddc_gain = gain;
-       if(d_state==STATE_STARTED)
-               send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
-}
-
-void MSDD6000::set_fc(int center_mhz, int offset_hz){
-       DEBUG("SETTING NEW FC");
-       d_fc_mhz = center_mhz;
-       d_offset_hz = offset_hz;
-       
-       if(d_state==STATE_STARTED)
-               send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
-}
-
-
-void MSDD6000::start(){
-       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz);
-       d_state = STATE_STARTED;
-       }
-
-
-void MSDD6000::stop(){
-       // new request with 0 decim tells it to halt
-       send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, 0, d_offset_hz);
-       d_state = STATE_STOPPED;
-       }
-
-
-void MSDD6000::send_request(float freq_mhz, float rf_attn, float ddc_gain, float ddc_dec, float ddc_offset_hz){
-       static char buff[512];
-       sprintf(buff, "%f %f %f %f %f\n",freq_mhz, rf_attn, ddc_gain, ddc_dec, ddc_offset_hz);
-       printf("sending: %s\n", buff);
-        int flags = 0;
-       sendto( d_sock, buff, strlen(buff)+1, flags, (const sockaddr*)&d_sockaddr, sizeof(d_sockaddr));
-       }
-
-
-int  MSDD6000::read(char* buf, int size){
-       int flags = 0;
-       return recv(d_sock, buf, size, flags);
-       }
-
-
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/msdd6000.h b/gr-msdd6000/src/non_gr_snapshot_tool/msdd6000.h
deleted file mode 100644 (file)
index 06fedcc..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef MSDD6000_H
-#define MSDD6000_H
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <linux/socket.h>
-
-#define DEBUG(A)       printf("=debug=> %s\n", A)
-
-#define STATE_STOPPED  0
-#define STATE_STARTED  1
-
-class MSDD6000 {
-       public:
-               MSDD6000(char* addr);
-               
-               void set_decim(int decim_pow2);
-               void set_fc(int center_mhz, int offset_hz);     
-               void set_ddc_gain(int gain);
-               void set_rf_attn(int attn);
-
-               void set_output(int mode, void* arg);
-
-               void start();
-               void stop();
-       
-               void send_request(float,float,float,float,float);       
-               int read(char*, int);
-
-       private:
-               int d_decim;
-               int d_fc_mhz;
-               int d_offset_hz;
-               int d_rf_attn;
-               int d_ddc_gain;
-
-//             in_addr d_adx;  
-               in_addr d_myadx;        
-
-               struct sockaddr_in d_sockaddr;
-               struct sockaddr_in d_mysockaddr;
-       
-               int d_sock;
-               int d_state;
-};
-
-
-
-
-
-
-#endif
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py b/gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py
deleted file mode 100755 (executable)
index 66d5ae6..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/python
-import struct;
-from pylab import *;
-import sys;
-
-#a = fft([1,2,3,4]);
-#print a;
-
-if(len(sys.argv)<2):
-       print "usage ./plot_psd.py <filename>"
-       sys.exit(-1);
-
-filename = sys.argv[1];
-
-#a = open("test.out_002", "r");
-a = open(filename, "r");
-samples = [];
-i_arr = [];
-q_arr = [];
-while(True):
-       d = a.read(1024*1024*4);
-       if(len(d) <= 0):
-               break;
-       
-       for i in range(0,(len(d))/8):
-               [s_i, s_q] = struct.unpack_from("<ff", d, i*8);
-               samples.append(complex(s_i, s_q));
-               i_arr.append(s_i);
-               q_arr.append(s_q);
-       break;
-
-fft_data = fftshift(fft(samples));
-for i in range(0,len(fft_data)):
-       if(fft_data[i] == 0):
-               fft_data[i] = 0.01;
-
-plot(20*log10(abs(fft_data)));
-figure();
-subplot(2,1,1);
-plot(i_arr);
-subplot(2,1,2);
-plot(q_arr);
-show();
-
-
-a.close();
-
-
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/spectrogram.py b/gr-msdd6000/src/non_gr_snapshot_tool/spectrogram.py
deleted file mode 100755 (executable)
index 5ce40de..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/python
-
-fft_bins = 1024;
-stride = 256;
-
-#filename = "output.dat";
-#decim = 4;
-#Fs = (102.4/decim) * 1e6;
-
-
-from gnuradio import gr;
-from Numeric import *;
-import FFT;
-import numpy.fft;
-from numpy import *;
-from pylab import *;
-import sys;
-
-if len(sys.argv) <2: 
-       print "usage:  %s <filename> (sample_rate_in_MSPS) (stride_samples)"%(sys.argv[0]);
-       sys.exit(-1);
-
-filename = sys.argv[1];
-fs = 0;
-if(len(sys.argv)>2):
-       fs = float(sys.argv[2])*1000000;
-print "opening %s.\n"%(filename);
-
-if(len(sys.argv)>=4):
-       stride = int(sys.argv[3]);
-       print "using stride = %d"%(stride);
-
-
-tb = gr.top_block();
-src = gr.file_source(gr.sizeof_gr_complex, filename, False)
-sink = gr.vector_sink_c();
-tb.connect(src,sink);
-tb.run();
-
-data = sink.data();
-dataa = array(data);
-datalen = len( data );
-
-time_bins = (datalen - fft_bins) / stride;
-
-print "output vector :: fft_bins = %d, time_bins = %d\n"%(fft_bins,time_bins);
-
-start_idx = 0;
-
-b = numpy.zeros((time_bins, fft_bins), complex);
-l = [];
-
-window = numpy.blackman(fft_bins);
-
-for i in range(0,time_bins):
-       
-       time_chunk = take( dataa, range(start_idx,start_idx + fft_bins), 0);
-       time_chunk = time_chunk * window;
-       fft_chunk = numpy.fft.fftshift(numpy.fft.fft(time_chunk));
-       psd = 10*log10(fft_chunk * conj(fft_chunk)+0.001);
-
-       b[i] = psd.real;
-       l.append( psd.real.tolist() );
-
-       start_idx = start_idx + stride;
-
-#c = array(b, 10);
-
-print b[0];
-c = array(b);
-#l = c.tolist();
-print size(l);
-
-x = range(0,time_bins);
-print size(x);
-y = range(0,fft_bins);
-print size(y);
-
-print size(l);
-
-contourf(l);
-#contourf([x,y], l);
-colorbar();
-show();
-
-#print c[1,1];
-
-
diff --git a/gr-msdd6000/src/python-examples/msdd_plot_psd.py b/gr-msdd6000/src/python-examples/msdd_plot_psd.py
deleted file mode 100755 (executable)
index 16869af..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/python
-
-address = "10.45.4.43";
-fc = 3.5;
-decim = 8;
-num_avg = 10
-
-fs = 102.4;
-packet_size=1400;
-gain = 0;
-port = 10001;
-
-import math;
-import time;
-import Numeric;
-from gnuradio import msdd,gr,window,wimax;
-from pylab import *;
-
-src = msdd.source_simple(address, port)  # build source object
-
-fft_size = 2048;
-
-w = window.blackmanharris(fft_size);
-s2v = gr.stream_to_vector(2*gr.sizeof_float, fft_size);
-fft = gr.fft_vcc(fft_size, True, w, True);
-conj = wimax.conj_vcc(fft_size);
-mul = gr.multiply_vcc(fft_size);
-norm = wimax.norm_cf();
-avg = wimax.average_vXX(gr.sizeof_float, 2*fft_size, num_avg);
-v2s = gr.vector_to_stream(2*gr.sizeof_float, fft_size);
-#sink = gr.vector_sink_f();
-
-src.set_decim_rate(decim);
-
-src.set_pga(0,gain);
-src.set_rx_freq(0,fc);
-
-q = gr.msg_queue(fft_size);
-sink = gr.message_sink(gr.sizeof_float, q, True);
-
-tb = gr.top_block();
-tb.connect(src,s2v,fft,(mul,0),avg,v2s,norm,sink);
-tb.connect(fft,conj,(mul,1));
-
-tb.start();
-
-print "running"
-
-v = []
-x = [];
-
-bw = fs/(pow(2,decim));
-for i in range(0,fft_size):
-       norm_freq = (i - fft_size/2.0)/fft_size;
-       bin_frequency = fc + norm_freq * bw;
-       x.append( norm_freq );
-
-
-
-for i in range(0,fft_size):
-
-       d = q.delete_head();
-       d =  d.to_string();
-       d =  Numeric.fromstring(d, Numeric.Float32);
-       d = 10*log10(d);
-
-       print "plotting\n";
-       plot(x,d);
-       show();
-       print "done\n"
-
-
-
-