[PATCH] libosmocore[master]: utils/conv_gen.py: improve application flexibility

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
Thu Jan 12 20:44:41 UTC 2017


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

utils/conv_gen.py: improve application flexibility

This change makes the conv_gen application more interactive
and flexible, allowing to generate not only code definitions
but also the test vectors and header files in the future.
Moreover, it becomes possible to select exact code family,
such as GSM, GMR etc.

Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28
---
M src/gsm/Makefile.am
M utils/conv_gen.py
2 files changed, 34 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/1584/1

diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 4ec441f..653bdb9 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -35,6 +35,6 @@
 
 # Convolutional codes generation
 gsm0503_conv.c:
-	$(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py
+	$(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py gen_codes gsm
 
 CLEANFILES = gsm0503_conv.c
diff --git a/utils/conv_gen.py b/utils/conv_gen.py
index 60580ed..57e9ca6 100644
--- a/utils/conv_gen.py
+++ b/utils/conv_gen.py
@@ -261,6 +261,8 @@
 	f.write("#include <stdint.h>\n")
 	f.write("#include <osmocom/core/conv.h>\n\n")
 
+	sys.stderr.write("Generating convolutional codes...\n")
+
 	# Print shared tables first
 	if hasattr(codes, "shared_polys"):
 		print_shared(f, codes.shared_polys)
@@ -279,12 +281,39 @@
 
 		code.gen_tables(prefix, f, shared_tables = shared)
 
+def print_help(error = None):
+	print("Usage: python %s action code_type [path]" % sys.argv[0])
+
+	print("\nAvailable actions:")
+	print("  gen_codes - generate convolutional code definitions")
+
+	print("\nAvailable code types:")
+	print("  gsm - GSM specific codes")
+
+	if error is not None:
+		print("\n%s" % error)
+
 if __name__ == '__main__':
-	path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
+	if len(sys.argv) < 3:
+		print_help()
+		sys.exit(1)
 
-	sys.stderr.write("Generating convolutional codes...\n")
+	action = sys.argv[1]
+	code_type = sys.argv[2]
+	path = sys.argv[3] if len(sys.argv) > 3 else os.getcwd()
 
-	# Generate GSM specific codes
-	generate_codes(conv_codes_gsm, path, "gsm0503")
+	# Determine convolutional code type
+	if code_type == "gsm":
+		codes = conv_codes_gsm
+	else:
+		print_help("Error: Unknown code type!")
+		sys.exit(1)
+
+	# What to generate?
+	if action == "gen_codes":
+		generate_codes(codes, path, "gsm0503")
+	else:
+		print_help("Error: Unknown action!")
+		sys.exit(1)
 
 	sys.stderr.write("Generation complete.\n")

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list