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

fake_trx/burst_gen.py: add burst capture support

Now all generated bursts can be also written to a capture file,
using a new option called '--output-file'. If a file already
exists, bursts would be appended to the end. Otherwise a new
capture file is created.

Change-Id: I074ff7dbc4d6beecdecce20de9dade5939e707f2
---
M src/target/fake_trx/burst_gen.py
1 file changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/35/6835/1

diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py
index 9141b67..9f36687 100755
--- a/src/target/fake_trx/burst_gen.py
+++ b/src/target/fake_trx/burst_gen.py
@@ -27,6 +27,7 @@
 import sys
 
 from rand_burst_gen import RandBurstGen
+from data_dump import DATADumpFile
 from data_if import DATAInterface
 from gsm_shared import *
 from data_msg import *
@@ -43,6 +44,7 @@
        remote_addr = "127.0.0.1"
        base_port = 5700
        conn_mode = "TRX"
+       output_file = None
 
        burst_type = None
        burst_count = 1
@@ -63,6 +65,10 @@
 
                # Set up signal handlers
                signal.signal(signal.SIGINT, self.sig_handler)
+
+               # Open requested capture file
+               if self.output_file is not None:
+                       self.ddf = DATADumpFile(self.output_file)
 
        def run(self):
                # Init DATA interface with TRX or L1
@@ -133,6 +139,10 @@
                        # Send message
                        self.data_if.send_msg(msg)
 
+                       # Append a new message to the capture
+                       if self.output_file is not None:
+                               self.ddf.append_msg(msg)
+
                self.shutdown()
 
        def print_copyright(self):
@@ -144,6 +154,7 @@
                         "  -h --help           this text\n\n"
 
                s += " TRX interface specific\n" \
+                        "  -o --output-file    Write bursts to a capture 
file\n"        \
                         "  -m --conn-mode      Send bursts to: TRX (default) / 
L1\n"    \
                         "  -r --remote-addr    Set remote address (default 
%s)\n"       \
                         "  -p --base-port      Set base port number (default 
%d)\n\n"
@@ -165,9 +176,10 @@
        def parse_argv(self):
                try:
                        opts, args = getopt.getopt(sys.argv[1:],
-                               "m:r:p:b:c:f:t:h",
+                               "o:m:r:p:b:c:f:t:h",
                                [
                                        "help",
+                                       "output-file="
                                        "conn-mode=",
                                        "remote-addr=",
                                        "base-port=",
@@ -188,6 +200,8 @@
                                self.print_help()
                                sys.exit(2)
 
+                       elif o in ("-o", "--output-file"):
+                               self.output_file = v
                        elif o in ("-m", "--conn-mode"):
                                self.conn_mode = v
                        elif o in ("-r", "--remote-addr"):

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I074ff7dbc4d6beecdecce20de9dade5939e707f2
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to