summaryrefslogtreecommitdiff
path: root/gr-blocks/examples/ctrlport/usrp_source_controller.py
blob: 77a6cb482b62c8c217d6524945453c327e1969f2 (plain)
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
#!/usr/bin/env python

import sys
import pmt
from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient

args = sys.argv
if(len(args) < 4):
    sys.stderr.write('Not enough arguments: usrp_source_controller.py <host> <port> <command> <value>\n')
    sys.stderr.write('See the "UHD Interface" section of the manual for available commands.\n\n')
    sys.exit(1)

alias = 'usrp_source0'
port = 'command'

hostname = args[1]
portnum = int(args[2])
cmd = args[3].lower()

if(cmd == "antenna"):
    val = pmt.intern(args[4])
else:
    val = pmt.from_double(float(args[4]))

argv = [None, hostname, portnum]
radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
radio = radiosys.client

radio.postMessage(alias, port, pmt.cons(pmt.intern(cmd), val))