Blame view

redpitaya/gnuradio_blocks/redpitaya_gnuradio.py 2.77 KB
9d344927e   bmarechal   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #!/usr/bin/env python
  
  # GNU Radio blocks for the Red Pitaya transceiver
  # Copyright (C) 2015  Renzo Davoli
  #
  # This program is free software; you can redistribute it and/or
  # modify it under the terms of the GNU General Public License
  # as published by the Free Software Foundation; either version 2
  # of the License, or (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
ed4b2fee6   bmarechal   minor fixes
19
  import socket, os
9d344927e   bmarechal   first commit
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  from gnuradio import gr, blocks
  
  class add_const_set_offset(gr.hier_block2):
      def __init__(self, addr, port, device, const):
          self.name = "add_const_set_offset"
          gr.hier_block2.__init__(
              self,
              name = self.name,
              input_signature = gr.io_signature(0, 0, 0),
              output_signature = gr.io_signature(0, 0, 0)
          )
          self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.ctrl_sock.connect((addr, port))
          self.set_const(device, const)
  
      def set_const(self, device, const):
          self.ctrl_sock.send('%s;%s;%i
  '%(self.name, device, const))
  
  
  class nco_counter_send_conf(gr.hier_block2):
      def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset):
          self.name = "nco_counter_send_conf"
          gr.hier_block2.__init__(
              self,
              name = self.name,
              input_signature = gr.io_signature(0, 0, 0),
              output_signature = gr.io_signature(0, 0, 0)
          )
          self.ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.ctrl_sock.connect((addr, port))
          self.set_nco(device, freq_ref, freq_dds, acc_size, offset)
  
      def set_nco(self, device, freq_ref, freq_dds, acc_size, offset):
          self.ctrl_sock.send('%s;%s;%i;%i;%i;%i
  '%(self.name, device, freq_ref, freq_dds, acc_size, offset))
ed4b2fee6   bmarechal   minor fixes
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  
  '''~
  class source_test(gr.hier_block2):
      def __init__(self):
          self.name = "source_test"
          gr.hier_block2.__init__(
              self,
              name = self.name,
              input_signature = gr.io_signature(0, 0, 0),
              output_signature = gr.io_signature(1, 1, gr.sizeof_gr_complex)
          )
          self.data_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.data_sock.connect((addr, port))
          self.data_sock.send('%s'%self.name)
          fd = os.dup(self.data_sock.fileno())
          self.connect(blocks.file_descriptor_source(gr.sizeof_gr_complex, fd), self)
  '''