Change in gr-gsm[master]: apps/grgsm_trx: add baseband frequency shift feature

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Tue Sep 4 19:20:42 UTC 2018


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/10770


Change subject: apps/grgsm_trx: add baseband frequency shift feature
......................................................................

apps/grgsm_trx: add baseband frequency shift feature

An ability to shift the baseband frequency would allow one to
run both base stations and (OsmocomBB-based) mobile stations on
any frequency (e.g. in 2.4 GHz WiFi band)!

This is achieved by adding a given frequency offset to the
result of "ARFCN -> RX/TX frequency" calculation.

Usage example:

  grgsm_trx --freq-offset -500M

Both RX (Downlink) and TX (Uplink) frequencies will be shifted
by 500 MHz back, e.g. tuning request to ARFCN 105 would result
in tuning the radio to 456.0 MHz (instead of 956.0 MHz).

Related: OS#3520 (https://osmocom.org/versions/136)
Change-Id: I42e397e47402a87f4141ef31b25eff4c8c1267e2
---
M apps/grgsm_trx
M python/trx/radio_if.py
2 files changed, 23 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/gr-gsm refs/changes/70/10770/1

diff --git a/apps/grgsm_trx b/apps/grgsm_trx
index 1c0581f..45312e6 100755
--- a/apps/grgsm_trx
+++ b/apps/grgsm_trx
@@ -25,6 +25,8 @@
 import getopt
 import sys
 
+from gnuradio import eng_notation
+
 from grgsm.trx import ctrl_if_bb
 from grgsm.trx import radio_if
 from grgsm.trx import fake_pm
@@ -45,6 +47,7 @@
 
 	# PHY specific
 	phy_sample_rate = 4 * 1625000 / 6
+	phy_freq_offset_hz = None
 	phy_tx_antenna = "TX/RX"
 	phy_rx_antenna = "RX2"
 	phy_rx_gain = 30
@@ -67,6 +70,10 @@
 			self.bind_addr, self.remote_addr,
 			self.base_port)
 
+		# Optional frequency offset
+		if self.phy_freq_offset_hz is not None:
+			self.radio.freq_offset_hz = self.phy_freq_offset_hz
+
 		# Power measurement emulation
 		# Noise: -120 .. -105
 		# BTS: -75 .. -50
@@ -110,6 +117,7 @@
 			 "  -G --tx-gain      Set TX gain (default %d)\n" \
 			 "     --rx-antenna   Set RX antenna (default %s)\n" \
 			 "     --tx-antenna   Set TX antenna (default %s)\n" \
+			 "     --freq-offset  Shift baseband freq. (e.g. -500M)\n" \
 			 "     --ppm          Set frequency correction (default %d)\n"
 
 		print(s % (
@@ -128,7 +136,7 @@
 				"i:b:p:a:s:g:G:h",
 				["help", "remote-addr=", "bind-addr=", "base-port=",
 				"device-args=", "sample-rate=", "rx-gain=", "tx-gain=",
-				"ppm=", "rx-antenna=", "tx-antenna="])
+				"ppm=", "rx-antenna=", "tx-antenna=", "freq-offset="])
 		except getopt.GetoptError as err:
 			# Print(help and exit)
 			self.print_help()
@@ -167,6 +175,10 @@
 				self.phy_tx_antenna = v
 			elif o in ("--ppm"):
 				self.phy_ppm = int(v)
+			elif o in ("--freq-offset"):
+				# Convert /\d+(\.\d+)?(M|k)?/ to Hz
+				offset_hz = eng_notation.str_to_num(v)
+				self.phy_freq_offset_hz = offset_hz
 
 	def sig_handler(self, signum, frame):
 		print("Signal %d received" % signum)
diff --git a/python/trx/radio_if.py b/python/trx/radio_if.py
index d2afcf6..71d771b 100644
--- a/python/trx/radio_if.py
+++ b/python/trx/radio_if.py
@@ -4,7 +4,7 @@
 # GR-GSM based transceiver
 # Follow graph implementation
 #
-# (C) 2016-2017 by Vadim Yanitskiy <axilirator at gmail.com>
+# (C) 2016-2018 by Vadim Yanitskiy <axilirator at gmail.com>
 # (C) 2017      by Piotr Krysik <ptrkrysik at gmail.com>
 #
 # All Rights Reserved
@@ -59,6 +59,7 @@
 
 class radio_if(gr.top_block):
 	# PHY specific variables
+	freq_offset_hz = None
 	rx_freq = 935e6
 	tx_freq = 890e6
 	osr = 4
@@ -274,11 +275,19 @@
 		return self.ppm / 1.0e6 * 2 * pi * fc / self.sample_rate
 
 	def set_rx_freq(self, fc):
+		if self.freq_offset_hz is not None:
+			fc += self.freq_offset_hz
+			print("[#] Shifting RX freq. to %d MHz (offset is %d Hz)"
+				% (fc / 1e6, self.freq_offset_hz))
 		self.phy_src.set_center_freq(fc, 0)
 		self.rotator_src.set_phase_inc(self.calc_phase_inc(fc))
 		self.rx_freq = fc
 
 	def set_tx_freq(self, fc):
+		if self.freq_offset_hz is not None:
+			fc += self.freq_offset_hz
+			print("[#] Shifting TX freq. to %d MHz (offset is %d Hz)"
+				% (fc / 1e6, self.freq_offset_hz))
 		self.phy_sink.set_center_freq(fc, 0)
 		self.rotator_sink.set_phase_inc(-self.calc_phase_inc(fc))
 		self.tx_freq = fc

-- 
To view, visit https://gerrit.osmocom.org/10770
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: gr-gsm
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42e397e47402a87f4141ef31b25eff4c8c1267e2
Gerrit-Change-Number: 10770
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180904/97c5634a/attachment.htm>


More information about the gerrit-log mailing list