[PATCH] osmocom-bb[master]: fake_trx/burst_gen.py: check argv separately

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 15:33:41 UTC 2018


Review at  https://gerrit.osmocom.org/6827

fake_trx/burst_gen.py: check argv separately

Change-Id: I35b5475d3b6df6dc92a1981c693afb63df866c87
---
M src/target/fake_trx/burst_gen.py
1 file changed, 12 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/27/6827/1

diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py
index 68ba0ec..66d8e89 100755
--- a/src/target/fake_trx/burst_gen.py
+++ b/src/target/fake_trx/burst_gen.py
@@ -53,6 +53,7 @@
 	def __init__(self):
 		self.print_copyright()
 		self.parse_argv()
+		self.check_argv()
 
 		# Set up signal handlers
 		signal.signal(signal.SIGINT, self.sig_handler)
@@ -65,9 +66,6 @@
 		elif self.conn_mode == "L1":
 			self.data_if = DATAInterface(self.remote_addr,
 				self.base_port + 102, self.base_port + 2)
-		else:
-			self.print_help("[!] Unknown connection type")
-			sys.exit(2)
 
 		# Init random burst generator
 		self.gen = RandBurstGen()
@@ -89,10 +87,6 @@
 				buf = self.gen.gen_sb()
 			elif self.burst_type == "AB":
 				buf = self.gen.gen_ab()
-			else:
-				self.print_help("[!] Unknown burst type")
-				self.shutdown()
-				sys.exit(2)
 
 			print("[i] Sending %d/%d %s burst (fn=%u) to %s..."
 				% (i + 1, self.burst_count, self.burst_type,
@@ -178,6 +172,17 @@
 			elif o in ("-l", "--power-level"):
 				self.pwr = abs(int(v))
 
+	def check_argv(self):
+		# Check connection mode
+		if self.conn_mode not in ("TRX", "L1"):
+			self.print_help("[!] Unknown connection type")
+			sys.exit(2)
+
+		# Check connection mode
+		if self.burst_type not in ("NB", "FB", "SB", "AB"):
+			self.print_help("[!] Unknown burst type")
+			sys.exit(2)
+
 	def shutdown(self):
 		self.data_if.shutdown()
 

-- 
To view, visit https://gerrit.osmocom.org/6827
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35b5475d3b6df6dc92a1981c693afb63df866c87
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list