Change in gr-gsm[master]: python/trx: get rid of FakePM class

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
Sat Jan 19 04:37:13 UTC 2019


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


Change subject: python/trx: get rid of FakePM class
......................................................................

python/trx: get rid of FakePM class

Change-Id: Ie96eb9735ecaa3329135c7be976ffd277a2f64f4
---
M apps/grgsm_trx
M python/trx/CMakeLists.txt
M python/trx/__init__.py
M python/trx/ctrl_if_bb.py
D python/trx/fake_pm.py
M python/trx/radio_if.py
6 files changed, 8 insertions(+), 69 deletions(-)



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

diff --git a/apps/grgsm_trx b/apps/grgsm_trx
index 7eeea50..c3e83d9 100755
--- a/apps/grgsm_trx
+++ b/apps/grgsm_trx
@@ -31,7 +31,6 @@
 
 from grgsm.trx import CTRLInterfaceBB
 from grgsm.trx import RadioInterface
-from grgsm.trx import FakePM
 
 COPYRIGHT = \
 	"Copyright (C) 2016-2018 by Vadim Yanitskiy <axilirator at gmail.com>\n" \
@@ -65,16 +64,11 @@
 			self.phy_freq_offset, self.bind_addr,
 			self.remote_addr, self.base_port)
 
-		# Power measurement emulation
-		# Noise: -120 .. -105
-		# BTS: -75 .. -50
-		self.pm = FakePM(-120, -105, -75, -50)
-
 		# Init TRX CTRL interface
 		self.server = CTRLInterfaceBB(
 			self.remote_addr, self.base_port + 101,
 			self.bind_addr, self.base_port + 1,
-			self.radio, self.pm)
+			self.radio)
 
 		print("[i] Init complete")
 
diff --git a/python/trx/CMakeLists.txt b/python/trx/CMakeLists.txt
index ffe5234..4333407 100644
--- a/python/trx/CMakeLists.txt
+++ b/python/trx/CMakeLists.txt
@@ -23,7 +23,6 @@
     udp_link.py
     ctrl_if.py
     ctrl_if_bb.py
-    fake_pm.py
     radio_if.py
     radio_if_grc.py
     dict_toggle_sign.py
diff --git a/python/trx/__init__.py b/python/trx/__init__.py
index c512262..7b20699 100644
--- a/python/trx/__init__.py
+++ b/python/trx/__init__.py
@@ -23,7 +23,6 @@
 from udp_link import UDPLink
 from ctrl_if import CTRLInterface
 from ctrl_if_bb import CTRLInterfaceBB
-from fake_pm import FakePM
 from radio_if_grc import RadioInterfaceGRC
 from radio_if import RadioInterface
 
diff --git a/python/trx/ctrl_if_bb.py b/python/trx/ctrl_if_bb.py
index 781c35c..f9840d4 100644
--- a/python/trx/ctrl_if_bb.py
+++ b/python/trx/ctrl_if_bb.py
@@ -27,7 +27,7 @@
 from ctrl_if import CTRLInterface
 
 class CTRLInterfaceBB(CTRLInterface):
-	def __init__(self, remote_addr, remote_port, bind_addr, bind_port, tb, pm):
+	def __init__(self, remote_addr, remote_port, bind_addr, bind_port, tb):
 		CTRLInterface.__init__(self, remote_addr, remote_port,
 			bind_addr, bind_port)
 
@@ -35,8 +35,6 @@
 
 		# Set link to the follow graph (top block)
 		self.tb = tb
-		# Power measurement
-		self.pm = pm
 
 	def parse_cmd(self, request):
 		# Power control
@@ -137,10 +135,7 @@
 
 			# TODO: check freq range
 			meas_freq = int(request[1]) * 1000
-
-			# HACK: send fake low power values
-			# until actual power measurement is implemented
-			meas_dbm = str(self.pm.measure(meas_freq))
+			meas_dbm = str(self.tb.measure(meas_freq))
 
 			return (0, [meas_dbm])
 
diff --git a/python/trx/fake_pm.py b/python/trx/fake_pm.py
deleted file mode 100644
index 1d76916..0000000
--- a/python/trx/fake_pm.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python2
-# -*- coding: utf-8 -*-
-
-# Virtual Um-interface (fake transceiver)
-# Power measurement emulation for BB
-#
-# (C) 2017 by Vadim Yanitskiy <axilirator at gmail.com>
-#
-# All Rights Reserved
-#
-# 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.
-
-from random import randint
-
-class FakePM:
-	# Freq. list for good power level
-	bts_list = []
-
-	def __init__(self, noise_min, noise_max, bts_min, bts_max):
-		# Save power level ranges
-		self.noise_min = noise_min
-		self.noise_max = noise_max
-		self.bts_min = bts_min
-		self.bts_max = bts_max
-
-	def measure(self, bts):
-		if bts in self.bts_list:
-			return randint(self.bts_min, self.bts_max)
-		else:
-			return randint(self.noise_min, self.noise_max)
-
-	def update_bts_list(self, new_list):
-		self.bts_list = new_list
-
-	def add_bts_list(self, add_list):
-		self.bts_list += add_list
-
-	def del_bts_list(self, del_list):
-		for item in del_list:
-			if item in self.bts_list:
-				self.bts_list.remove(item)
diff --git a/python/trx/radio_if.py b/python/trx/radio_if.py
index 55c8d92..32b767a 100644
--- a/python/trx/radio_if.py
+++ b/python/trx/radio_if.py
@@ -26,6 +26,7 @@
 import pmt
 import time
 import grgsm
+import random
 
 from math import pi
 
@@ -290,3 +291,7 @@
 		print("[i] Setting TA value %d" % ta)
 		advance_time_sec = ta * self.GSM_SYM_PERIOD_uS * 1e-6
 		self.tx_time_setter.set_timing_advance(advance_time_sec)
+
+	def measure(self, freq):
+		# HACK: generate a random low RSSI value
+		return random.randint(-120, -100)

-- 
To view, visit https://gerrit.osmocom.org/12631
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: Ie96eb9735ecaa3329135c7be976ffd277a2f64f4
Gerrit-Change-Number: 12631
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/20190119/a08c092f/attachment.htm>


More information about the gerrit-log mailing list