apps/grgsm_trx: add cmd line arguments for TX chain
diff --git a/apps/grgsm_trx b/apps/grgsm_trx
index 7886b12..670d919 100755
--- a/apps/grgsm_trx
+++ b/apps/grgsm_trx
@@ -43,7 +43,10 @@
# PHY specific
phy_sample_rate = 2000000
- phy_gain = 30
+ phy_tx_antenna = "TX/RX"
+ phy_rx_antenna = "RX2"
+ phy_rx_gain = 30
+ phy_tx_gain = 10
phy_args = ""
phy_ppm = 0
@@ -57,7 +60,9 @@
def run(self):
# Init Radio interface
self.radio = radio_if(self.phy_args, self.phy_sample_rate,
- self.phy_gain, self.phy_ppm, self.remote_addr, self.base_port)
+ self.phy_rx_gain, self.phy_tx_gain, self.phy_ppm,
+ self.phy_rx_antenna, self.phy_tx_antenna,
+ self.remote_addr, self.base_port)
# Power measurement emulation
# Noise: -120 .. -105
@@ -90,24 +95,28 @@
# TRX specific
s += " TRX interface specific\n" \
- " -s --remote-addr Set remote address (default 127.0.0.1)\n" \
+ " -i --remote-addr Set remote address (default 127.0.0.1)\n" \
" -p --base-port Set base port number (default 5700)\n\n"
# PHY specific
s += " Radio interface specific\n" \
" -a --device-args Set device arguments\n" \
- " -s --sample-rate Set PHY sample rate (default 2000000)\n" \
- " -g --gain Set PHY gain (default 30)\n" \
- " --ppm Set PHY frequency correction (default 0)\n"
+ " -s --sample-rate Set sample rate (default 2000000)\n" \
+ " -g --rx-gain Set RX gain (default 30)\n" \
+ " -G --tx-gain Set TX gain (default 10)\n" \
+ " --rx-antenna Set RX antenna (default RX2)\n" \
+ " --tx-antenna Set TX antenna (default TX/RX)\n" \
+ " --ppm Set frequency correction (default 0)\n"
print(s)
def parse_argv(self):
try:
opts, args = getopt.getopt(sys.argv[1:],
- "a:p:i:s:g:h",
+ "i:p:a:s:g:G:h",
["help", "remote-addr=", "base-port=", "device-args=",
- "gain=", "sample-rate=", "ppm="])
+ "sample-rate=", "rx-gain=", "tx-gain=", "ppm=",
+ "rx-antenna", "tx-antenna"])
except getopt.GetoptError as err:
# Print(help and exit)
self.print_help()
@@ -132,10 +141,16 @@
# PHY specific
elif o in ("-a", "--device-args"):
self.phy_args = v
- elif o in ("-g", "--gain"):
- self.phy_gain = int(v)
elif o in ("-s", "--sample-rate"):
self.phy_sample_rate = int(v)
+ elif o in ("-g", "--rx-gain"):
+ self.phy_rx_gain = int(v)
+ elif o in ("-G", "--tx-gain"):
+ self.phy_tx_gain = int(v)
+ elif o in ("--rx-antenna"):
+ self.phy_rx_antenna = v
+ elif o in ("--tx-antenna"):
+ self.phy_tx_antenna = v
elif o in ("--ppm"):
self.phy_ppm = int(v)
diff --git a/python/trx/radio_if.py b/python/trx/radio_if.py
index a6cd23c..0164cde 100644
--- a/python/trx/radio_if.py
+++ b/python/trx/radio_if.py
@@ -45,18 +45,17 @@
trx_started = False
fc_set = False
- def __init__(self, phy_args, phy_sample_rate, phy_gain, phy_ppm,
+ def __init__(self, phy_args, phy_sample_rate,
+ phy_rx_gain, phy_tx_gain, phy_ppm,
+ phy_rx_antenna, phy_tx_antenna,
trx_remote_addr, trx_base_port):
- print("[i] Init Radio interface")
- # TRX block specific variables
- self.trx_remote_addr = trx_remote_addr
- self.trx_base_port = trx_base_port
+ print("[i] Init Radio interface")
# PHY specific variables
self.samp_rate = phy_sample_rate
- self.device_args = phy_args
- self.gain = phy_gain
+ self.rx_gain = phy_rx_gain
+ self.tx_gain = phy_tx_gain
self.ppm = phy_ppm
gr.top_block.__init__(self, "GR-GSM TRX")
@@ -65,8 +64,7 @@
##################################################
# PHY Definition
##################################################
- self.phy = osmosdr.source(
- args = "numchan=%d %s" % (1, self.device_args))
+ self.phy = osmosdr.source(args = "numchan=%d %s" % (1, phy_args))
self.phy.set_bandwidth(250e3 + abs(self.shiftoff), 0)
self.phy.set_center_freq(shift_fc, 0)
@@ -75,10 +73,10 @@
self.phy.set_iq_balance_mode(2, 0)
self.phy.set_dc_offset_mode(2, 0)
self.phy.set_gain_mode(False, 0)
- self.phy.set_gain(self.gain, 0)
+ self.phy.set_gain(self.rx_gain, 0)
self.phy.set_if_gain(20, 0)
self.phy.set_bb_gain(20, 0)
- self.phy.set_antenna("", 0)
+ self.phy.set_antenna(phy_rx_antenna, 0)
##################################################
# GR-GSM Magic
@@ -99,7 +97,7 @@
self.gsm_ts_filter.set_policy(grgsm.FILTER_POLICY_DROP_ALL)
self.gsm_trx_burst_if = grgsm.trx_burst_if(
- self.trx_remote_addr, str(self.trx_base_port))
+ trx_remote_addr, str(trx_base_port))
##################################################
# Connections