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.orgHello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1584 to look at the new patch set (#4). 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, 91 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/84/1584/4 diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 4ec441f..5c3d75c 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -35,6 +35,7 @@ # 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 \ + --action gen_codes --code-family gsm CLEANFILES = gsm0503_conv.c diff --git a/utils/conv_gen.py b/utils/conv_gen.py index 60580ed..de1e00e 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -23,7 +23,7 @@ */ """ -import sys, os, math +import sys, os, math, getopt from functools import reduce import conv_codes_gsm @@ -254,12 +254,14 @@ code = ConvolutionalCode(0, polys, name = name) code.print_state_and_output(fi) -def generate_codes(codes, path, prefix): +def generate_codes(codes, path, prefix, name): # Open a new file for writing - f = open(os.path.join(path, prefix + "_conv.c"), 'w') + f = open(os.path.join(path, name), 'w') f.write(mod_license + "\n") 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"): @@ -279,12 +281,92 @@ code.gen_tables(prefix, f, shared_tables = shared) +def print_help(error = None): + print("Usage: python %s [options]" % sys.argv[0]) + + print("\nOptions:") + print(" -h, --help show this help message") + print(" -a, --action what to generate") + print(" -f, --code-family convolutional code family") + + print("\nAdditional options:") + print(" -p, --prefix internal naming prefix") + print(" -n, --target-name convolutional code family") + print(" -P, --target-path target path for generated file(s)") + + print("\nAvailable actions:") + print(" gen_codes - generate convolutional code definitions") + + print("\nAvailable code families:") + print(" gsm - GSM/GPRS/EDGE specific codes") + + if error is not None: + print("\n%s" % error) + +def parse_argv(): + try: + opts, args = getopt.getopt(sys.argv[1:], + "a:f:p:n:P:h", + [ + "help", "action=", "code-family=", "prefix=", + "target-name=", "target-path=" + ]) + except getopt.GetoptError as err: + # Print help and exit + print_help(str(err)) + sys.exit(2) + + action = None + family = None + prefix = None + name = None + path = None + + for o, v in opts: + if o in ("-h", "--help"): + print_help() + sys.exit(2) + elif o in ("-a", "--action"): + action = v + elif o in ("-f", "--code-family"): + family = v + elif o in ("-p", "--prefix"): + prefix = v + elif o in ("-n", "--target-name"): + name = v + elif o in ("-P", "--target-path"): + path = v + + if path is None: + path = os.getcwd() + if action is None or family is None: + print_help("Error: Please specify both action and code family!") + sys.exit(2) + + return (action, family, prefix, name, path) + if __name__ == '__main__': - path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() + argv = parse_argv() + action = argv[0] + family = argv[1] + prefix = argv[2] + name = argv[3] + path = argv[4] - sys.stderr.write("Generating convolutional codes...\n") + # Determine convolutional code family + if family == "gsm": + codes = conv_codes_gsm + prefix = "gsm0503" if prefix is None else prefix + else: + print_help("Error: Unknown code family!") + sys.exit(1) - # Generate GSM specific codes - generate_codes(conv_codes_gsm, path, "gsm0503") + # What to generate? + if action == "gen_codes": + name = prefix + "_conv.c" if name is None else name + generate_codes(codes, path, prefix, name) + 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: newpatchset Gerrit-Change-Id: I0b476b00234c17f78b41d695cf3bfd13edb64c28 Gerrit-PatchSet: 4 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com> Gerrit-Reviewer: tnt <tnt at 246tNt.com>