redpitaya_gnuradio.py
2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
#!/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.
import socket
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\n'%(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\n'%(self.name, device, freq_ref, freq_dds, acc_size, offset))