6 #include <msdd_source_simple.h>
7 #include <gr_io_signature.h>
8 #include <gr_sync_block.h>
16 msdd_source_simple_sptr
17 msdd_make_source_simple ( const char *src, unsigned short port_src)
19 return msdd_source_simple_sptr (new msdd_source_simple ( src, port_src));
23 msdd_source_simple::msdd_source_simple (
25 unsigned short port_src)
26 : gr_sync_block("MSDD_SOURCE_SIMPLE",
27 gr_make_io_signature (0,0,0),
28 gr_make_io_signature (1, 1, sizeof (short)))
30 rcv = new MSDD6000((char*)src);
34 msdd_source_simple::work (int noutput_items,
35 gr_vector_const_void_star &input_items,
36 gr_vector_void_star &output_items)
39 #define BUF_LEN (366*sizeof(short)*2 + 6)
41 float* out1 =(float*) output_items[0];
44 rcv->read( &buffer[0], BUF_LEN );
46 int seq = *((int*) &buffer[2]);
48 if(d_lastseq == -366){
53 // THROW AWAY SAMPLES WE ARE NOT STARTED YET!
59 int samples_missed = seq - d_lastseq - 366;
60 if(samples_missed > 0){
61 printf("dropped %d samples.\n", samples_missed);
66 if(noutput_items< 366*2){
67 printf("NOT ENOUGH SPACE IN OUTPUT BUFFER!!! >:-(\n");
70 memcpy(&out1[0], &buffer[6], BUF_LEN - 6);
72 // for(int i = 0; i < 366*2; i++){
73 // out1[i] = (float) (*((short*) &buffer[6+2*i]) );
79 bool msdd_source_simple::set_decim_rate(unsigned int rate)
81 rcv->set_decim(log2(rate));
86 bool msdd_source_simple::set_rx_freq(int channel, double freq)
88 long new_fc = (long)freq;
89 rcv->set_fc( new_fc/1000000, new_fc%1000000);
94 bool msdd_source_simple::set_pga(int which, double gain)
96 if(gain < 0 || gain > 10){
97 printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n");
100 // ok i lied this is not really a pga, its decimation gain
101 rcv->set_ddc_gain((int)gain);
106 msdd_source_simple::~msdd_source_simple ()
112 bool msdd_source_simple::start()
118 bool msdd_source_simple::stop()
123 int msdd_source_simple::ninput_bytes_reqd_for_noutput_items(int out){
127 long msdd_source_simple::adc_freq(){
131 int msdd_source_simple::decim_rate(){
132 return pow(2, rcv->d_decim);
136 std::vector<int> msdd_source_simple::gain_range(){
137 static std::vector<int> r;
143 std::vector<float> msdd_source_simple::freq_range(){
144 std::vector<float> r;
145 r.push_back(30.0*1000*1000);
146 r.push_back(6.0*1000*1000*1000);