Blame view
redpitaya/client/gr_rp_blocks/redpitaya_gnuradio.py
2.85 KB
9d344927e 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 minor fixes |
19 |
import socket, os |
9d344927e first commit |
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
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): |
145da201a - |
41 |
def __init__(self, addr, port, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw): |
9d344927e first commit |
42 43 44 45 46 47 48 49 50 |
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)) |
145da201a - |
51 |
self.set_nco(device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw) |
9d344927e first commit |
52 |
|
145da201a - |
53 54 55 |
def set_nco(self, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw): self.ctrl_sock.send('%s;%s;%i;%i;%i;%i;%i;%i '%(self.name, device, freq_ref, freq_dds, acc_size, offset, pinc_sw, poff_sw)) |
ed4b2fee6 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) ''' |