commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4364 - gnuradio/branches/developers/jcorgan/digital/g


From: jcorgan
Subject: [Commit-gnuradio] r4364 - gnuradio/branches/developers/jcorgan/digital/gnuradio-examples/python/digital
Date: Sat, 3 Feb 2007 19:14:23 -0700 (MST)

Author: jcorgan
Date: 2007-02-03 19:14:23 -0700 (Sat, 03 Feb 2007)
New Revision: 4364

Modified:
   
gnuradio/branches/developers/jcorgan/digital/gnuradio-examples/python/digital/benchmark_tx.py
Log:
Adds --from-file to benchmark_tx.py, allowing the digital benchmark
code to send pre-defined packet contents.


Modified: 
gnuradio/branches/developers/jcorgan/digital/gnuradio-examples/python/digital/benchmark_tx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/digital/gnuradio-examples/python/digital/benchmark_tx.py
       2007-02-03 01:10:38 UTC (rev 4363)
+++ 
gnuradio/branches/developers/jcorgan/digital/gnuradio-examples/python/digital/benchmark_tx.py
       2007-02-04 02:14:23 UTC (rev 4364)
@@ -71,7 +71,8 @@
                       help="set megabytes to transmit [default=%default]")
     parser.add_option("","--discontinuous", action="store_true", default=False,
                       help="enable discontinous transmission (bursts of 5 
packets)")
-
+    parser.add_option("","--from-file", default=None,
+                      help="use file for packet contents")
     transmit_path.add_options(parser, expert_grp)
 
     for mod in mods.values():
@@ -89,6 +90,9 @@
         parser.print_help(sys.stderr)
         sys.exit(1)
 
+    if options.from_file is not None:
+        source_file = open(options.from_file, 'r')
+
     # build the graph
     fg = my_graph(mods[options.modulation], options)
 
@@ -98,7 +102,6 @@
 
     fg.start()                       # start flow graph
 
-
     # generate and send packets
     nbytes = int(1e6 * options.megabytes)
     n = 0
@@ -106,8 +109,15 @@
     pkt_size = int(options.size)
 
     while n < nbytes:
-        send_pkt(struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff))
-        n += pkt_size
+        if options.from_file is None:
+            data = struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 
0xff) 
+        else:
+            data = struct.pack('!H', pktno) + source_file.read(pkt_size - 2)
+            if data == '':
+                break
+
+        send_pkt(data)
+        n += len(data)
         sys.stderr.write('.')
         if options.discontinuous and pktno % 5 == 4:
             time.sleep(1)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]