commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6449 - in grc/trunk: examples src src/Graphics src/Si


From: jblum
Subject: [Commit-gnuradio] r6449 - in grc/trunk: examples src src/Graphics src/SignalBlockDefs
Date: Sat, 15 Sep 2007 17:26:50 -0600 (MDT)

Author: jblum
Date: 2007-09-15 17:26:49 -0600 (Sat, 15 Sep 2007)
New Revision: 6449

Modified:
   grc/trunk/examples/packet_mod_demod.grc.xml
   grc/trunk/src/Constants.py
   grc/trunk/src/Graphics/Dialogs.py
   grc/trunk/src/Graphics/USRPDiagnostics.py
   grc/trunk/src/SignalBlockDefs/Misc.py
   grc/trunk/src/SignalBlockDefs/Modulators.py
   grc/trunk/src/SignalBlockDefs/Packet.py
   grc/trunk/src/SignalBlockDefs/SignalBlockTree.py
   grc/trunk/src/SignalBlockDefs/Sinks.py
Log:
packet mod and demod

Modified: grc/trunk/examples/packet_mod_demod.grc.xml
===================================================================
--- grc/trunk/examples/packet_mod_demod.grc.xml 2007-09-15 18:10:46 UTC (rev 
6448)
+++ grc/trunk/examples/packet_mod_demod.grc.xml 2007-09-15 23:26:49 UTC (rev 
6449)
@@ -1,8 +1,8 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <flow_graph>
-  <timestamp>1182980737.28</timestamp>
+  <timestamp>1189898583.51</timestamp>
   <hostname>tiggle</hostname>
-  <version>0.70 alpha</version>
+  <version>0.69 beta</version>
   <valid>True</valid>
   <window_width>1600</window_width>
   <window_height>1200</window_height>
@@ -16,10 +16,10 @@
     </var>
     <var>
       <key>freq</key>
-      <value>2500</value>
+      <value>500</value>
       <min>0</min>
-      <max>5000</max>
-      <step>50.0</step>
+      <max>1000</max>
+      <step>10.0</step>
     </var>
     <var>
       <key>amp</key>
@@ -105,22 +105,6 @@
       </params>
     </signal_block>
     <signal_block>
-      <tag>Packet Modulator</tag>
-      <id>Packet Modulator0</id>
-      <x_coordinate>129</x_coordinate>
-      <y_coordinate>19</y_coordinate>
-      <rotation>0</rotation>
-      <params>
-        <param>1</param>
-        <param>0</param>
-        <param>2</param>
-        <param>512</param>
-        <param/>
-        <param>0</param>
-        <param>1</param>
-      </params>
-    </signal_block>
-    <signal_block>
       <tag>GMSK Modulator</tag>
       <id>GMSK Modulator0</id>
       <x_coordinate>399</x_coordinate>
@@ -168,6 +152,21 @@
         <param>1</param>
       </params>
     </signal_block>
+    <signal_block>
+      <tag>Packet Modulator</tag>
+      <id>Packet Modulator0</id>
+      <x_coordinate>129</x_coordinate>
+      <y_coordinate>19</y_coordinate>
+      <rotation>0</rotation>
+      <params>
+        <param>1</param>
+        <param>2</param>
+        <param>1</param>
+        <param>512</param>
+        <param/>
+        <param>0</param>
+      </params>
+    </signal_block>
   </signal_blocks>
   <connections>
     <connection>

Modified: grc/trunk/src/Constants.py
===================================================================
--- grc/trunk/src/Constants.py  2007-09-15 18:10:46 UTC (rev 6448)
+++ grc/trunk/src/Constants.py  2007-09-15 23:26:49 UTC (rev 6449)
@@ -36,6 +36,9 @@
 ##The current version of this code
 VERSION = '0.69 beta'
 
+##The release date for this version as a unix timestamp
+RELEASE_STAMP = None
+
 ##The name to appear in the main window for a flow graph that has not been 
saved to file.
 NEW_FLOGRAPH_TITLE = 'untitled'
 

Modified: grc/trunk/src/Graphics/Dialogs.py
===================================================================
--- grc/trunk/src/Graphics/Dialogs.py   2007-09-15 18:10:46 UTC (rev 6448)
+++ grc/trunk/src/Graphics/Dialogs.py   2007-09-15 23:26:49 UTC (rev 6449)
@@ -132,6 +132,9 @@
                gtk.AboutDialog.__init__(self)
                self.set_version(VERSION)
                self.set_name(MAIN_WINDOW_PREFIX)       
+               self.set_license(__doc__)
+               self.set_copyright('Copyright 2007 Free Software Foundation, 
Inc.')
+               
self.set_website('http://gnuradio.org/trac/wiki/GNURadioCompanion')
                self.set_comments("""\
 Thank you to all those from the mailing list who tested GNU Radio Companion 
and offered advice.
 --
@@ -141,12 +144,7 @@
 William R. Kenan Jr. Fund -> usrp & computers
 Patrick Strasser -> the GRC icon
 Achilleas Anastasopoulos -> trellis support
---
-GNU Radio Companion, \
-This file is part of GNU Radio
-GRC comes with ABSOLUTELY NO WARRANTY. \
-This is free software, \
-and you are welcome to redistribute it.""")
+--""")
                self.run()
                self.destroy()
                                        

Modified: grc/trunk/src/Graphics/USRPDiagnostics.py
===================================================================
--- grc/trunk/src/Graphics/USRPDiagnostics.py   2007-09-15 18:10:46 UTC (rev 
6448)
+++ grc/trunk/src/Graphics/USRPDiagnostics.py   2007-09-15 23:26:49 UTC (rev 
6449)
@@ -50,11 +50,12 @@
                self.USRP_number = Int(0, min=0)
                self.USRP_type = Enum([('Receive', 'rx'), ('Transmit', 'tx'),])
                self.USRP_subdev = Enum([
-                       ('Side A:0', (0, 0)), 
-                       ('Side B:0', (1, 0)),
-                       ('Side A:1', (0, 1)), 
-                       ('Side B:1', (1, 1)),
-               ])
+                               ('Side A:0', (0, 0)), 
+                               ('Side B:0', (1, 0)),
+                               ('Side A:1', (0, 1)), 
+                               ('Side B:1', (1, 1)),
+                       ]
+               )
                self.vbox.pack_start(GraphicalParam('Unit Number', 
self.USRP_number).get_input_object(), False)
                self.vbox.pack_start(GraphicalParam('Transmit/Receive', 
self.USRP_type).get_input_object(), False)
                self.vbox.pack_start(GraphicalParam('Side:Subdevice', 
self.USRP_subdev).get_input_object(), False)
@@ -94,6 +95,11 @@
                        msg = "%s\nFreq Range (min, max, step 
size):\n\t%s\n\t%s\n\t%s\n"%(msg, freq_min, freq_max, freq_step)
                        self.query_buffer.set_text(msg)
                except Exception, e:    #display the error message
-                       self.query_buffer.set_text('>>> Error\n%s'%str(e))      
        
+                       self.query_buffer.set_text('''\
+>>> Error\n%s
+
+If the USRP cannot be found, make sure that the USRP is plugged-in and restart 
this program. \
+If the problem persists, there may be a problem with you gnuradio installation 
or USB 2.0.
+'''%str(e))            
                
                
\ No newline at end of file

Modified: grc/trunk/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Misc.py       2007-09-15 18:10:46 UTC (rev 
6448)
+++ grc/trunk/src/SignalBlockDefs/Misc.py       2007-09-15 23:26:49 UTC (rev 
6449)
@@ -189,9 +189,7 @@
        sb.add_param('Num Outputs', Int(1, min=1, max=MAX_NUM_SOCKETS), 
                show_label=False, output_sockets_controller=True)
        sb.add_param('Vector Length', vlen)
-       sb.set_docs('''Forward data from the input index to the output index.
-       
-Warning: this block is experimental and may cause the flow graph to lock up 
when variables are changed.''')    
+       sb.set_docs('''Forward data from the input index to the output 
index.''')       
        def make(fg, type, input_index, output_index, num_inputs, num_outputs, 
vlen):
                item_size = type.parse().get_num_bytes()*vlen.parse()
                block = SelectorHelper(
@@ -214,9 +212,7 @@
        sb.add_param('Type', type, False, type=True)
        sb.add_param('Open', Int(0), variable=True)     
        sb.add_param('Vector Length', vlen)
-       sb.set_docs('''When open is 0, the valve will forward data.
-       
-Warning: this block is experimental and may cause the flow graph to lock up 
when variables are changed.''')    
+       sb.set_docs('''When open is 0, the valve will forward data.''') 
        def make(fg, type, open, vlen):
                item_size = type.parse().get_num_bytes()*vlen.parse()
                block = SelectorHelper(item_size, 1, 1, 0, open.parse())

Modified: grc/trunk/src/SignalBlockDefs/Modulators.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Modulators.py 2007-09-15 18:10:46 UTC (rev 
6448)
+++ grc/trunk/src/SignalBlockDefs/Modulators.py 2007-09-15 23:26:49 UTC (rev 
6449)
@@ -213,6 +213,7 @@
        sb.add_output_socket('out', Complex())  
        sb.add_param('Type', Enum([
                ('QAM 8', blks2.qam8_mod), 
+               ('QAM 16', blks2.qam16_mod), 
                ('QAM 64', blks2.qam64_mod),
                ('QAM 256', blks2.qam256_mod),
        ]), type=True)
@@ -226,6 +227,7 @@
        sb.add_output_socket('out', Byte())     
        sb.add_param('Type', Enum([
                ('QAM 8', blks2.qam8_demod), 
+               ('QAM 16', blks2.qam16_demod),
                ('QAM 64', blks2.qam64_demod),
                ('QAM 256', blks2.qam256_demod),
        ]), type=True)

Modified: grc/trunk/src/SignalBlockDefs/Packet.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Packet.py     2007-09-15 18:10:46 UTC (rev 
6448)
+++ grc/trunk/src/SignalBlockDefs/Packet.py     2007-09-15 23:26:49 UTC (rev 
6449)
@@ -23,10 +23,263 @@
 import struct
 import os
 from DataTypes import *
-from gnuradio import gr
+from gnuradio import gr, packet_utils
+import gnuradio.gr.gr_threading as threading
 from SignalBlockConstants import all_choices
 
+##payload length in bytes
+DEFAULT_PAYLOAD_LEN = 512
+
+##how many messages in a queue
+DEFAULT_MSGQ_LIMIT = 2
+
+##threshold for unmaking packets
+DEFAULT_THRESHOLD = 12
+
 
#######################################################################################
+##     Packet Mod
+#######################################################################################
+
+class PacketModThread(threading.Thread):
+       """
+       Sample the input message queue and call send payload.           
+       """
+       
+       def __init__(self, msgq, payload_length, send_payload):
+               """!
+               Create the packet_mod_thread.
+               @param msgq the message queue to sample
+               @param payload_length number of bytes in a data-stream slice
+               @param send_payload a function that takes a payload
+               """             
+               self._msgq = msgq
+               self._payload_length = payload_length
+               self._send_payload = send_payload
+               threading.Thread.__init__(self)
+               self.setDaemon(1)
+               self.keep_running = True
+               self.start()
+               
+       def run(self):
+               """
+               Run this thread by sampling the message queue in and cutting 
out chunks of size payload.
+               """
+               s = '' #residual sample
+               while self.keep_running:
+                       msg = self._msgq.delete_head() #blocking read of 
message queue
+                       s = s + msg.to_string() #get the body of the msg as a 
string    
+                       while len(s) >= self._payload_length:           
+                               p = s[0:self._payload_length]
+                               s = s[self._payload_length:]                    
+                               self._send_payload(p)   
+
+class PacketModHelper(gr.hier_block2):
+       """
+       Block-based packet modulator.
+       """
+       
+       def __init__(self, item_size, samples_per_symbol, bits_per_symbol, 
payload_length=None, access_code=None, pad_for_usrp=True):
+               """!
+               Hierarchical block for sending packet based data.               
+               @param item_size the size of the input data stream in bytes
+               @param samples_per_symbol number of samples per symbol
+               @param bits_per_symbol number of bits per symbol
+               @param payload_length number of bytes in a data-stream slice
+               @param access_code AKA sync vector
+               @param pad_for_usrp If true, packets are padded such that they 
end up a multiple of 128 samples
+               """
+               #setup parameters
+               self._item_size = item_size
+               self._samples_per_symbol = samples_per_symbol
+               self._bits_per_symbol = bits_per_symbol
+               self._pad_for_usrp = pad_for_usrp
+               if access_code is None: #get access code
+                       access_code = packet_utils.default_access_code
+               if not packet_utils.is_1_0_string(access_code):
+                       raise ValueError, "Invalid access_code %r. Must be 
string of 1's and 0's" % (access_code,)
+               self._access_code = access_code         
+               if payload_length is None: #get packet length
+                       payload_length = DEFAULT_PAYLOAD_LEN
+               if payload_length%self._item_size != 0: #verify that packet 
length is a multiple of the stream size
+                       raise ValueError, 'The packet length: "%d" is not a 
mutiple of the stream size: "%d".'%(payload_length, item_size)
+               self._payload_length = payload_length
+               self._pad_for_usrp = pad_for_usrp               
+               #create message queues and message blocks
+               self._msgq_in = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
+               msg_sink        = gr.message_sink(self._item_size, 
self._msgq_in, False) #False -> blocking
+               msg_source = gr.message_source(gr.sizeof_char, 
DEFAULT_MSGQ_LIMIT)
+               self._msgq_out = msg_source.msgq()              
+               #initialize hier2
+               gr.hier_block2.__init__(
+                       self, 
+                       "packet_mod",
+                       gr.io_signature(1, 1, self._item_size), # Input 
signature
+                       gr.io_signature(1, 1, gr.sizeof_char) # Output signature
+               )
+               #connect
+               self.connect(self, msg_sink)
+               self.connect(msg_source, self)
+               #start thread
+               PacketModThread(self._msgq_in, self._payload_length, 
self._send_payload)
+               
+       def _send_payload(self, payload):
+               """!
+               Wrap the payload in a packet and push onto the message queue.
+               @param payload data to send
+               """
+               packet = packet_utils.make_packet(
+                       payload,
+                       self._samples_per_symbol,
+                       self._bits_per_symbol,
+                       self._access_code,
+                       self._pad_for_usrp
+               )
+               msg = gr.message_from_string(packet)
+               self._msgq_out.insert_tail(msg)
+
+def PacketMod(sb):
+       type = Enum(all_choices, 1)
+       sb.add_input_socket('in', Variable(type))
+       sb.add_output_socket('out', Byte())             
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Samples/Symbol', Int(1))
+       sb.add_param('Bits/Symbol', Int(1))
+       sb.add_param('Payload Length', Int(DEFAULT_PAYLOAD_LEN))
+       sb.add_param('Access Code', String())
+       sb.add_param('Pad for USRP', Bool(true='Yes', false='No', default=True))
+       sb.set_docs("""\
+Packet modulator block, for use with the gnuradio modulator blocks: gmsk, psk, 
qam.
+
+Access Code: string of 1's and 0's, leave blank for default.
+
+Bits/Symbol should be set accordingly: 
+       gmsk -> 1
+       dbpsk -> 1
+       dqpsk -> 2
+       d8psk -> 3
+       qam8 -> 3
+       qam16 -> 4
+       qam64 -> 6
+       qam256 -> 8
+""")
+       def make(fg, type, samples_per_symbol, bits_per_symbol, payload_length, 
access_code, pad_for_usrp):
+               access_code = access_code.parse()
+               if not access_code: access_code = None
+               return PacketModHelper(
+                       item_size = type.parse().get_num_bytes(),
+                       samples_per_symbol=samples_per_symbol.parse(), 
+                       bits_per_symbol=bits_per_symbol.parse(), 
+                       payload_length=payload_length.parse(), 
+                       access_code=access_code, 
+                       pad_for_usrp=pad_for_usrp.parse(),
+               )
+       return sb, make
+       
+#######################################################################################
+## Packet Demod
+#######################################################################################
+
+class PacketDemodThread(threading.Thread):
+       """
+       Sample the input message queue and call send packet.            
+       """
+       
+       def __init__(self, msgq, recv_packet):
+               """!
+               Create the packet_mod_thread.
+               @param msgq the message queue to sample
+               @param recv_packet a function that takes a packet
+               """             
+               self._msgq = msgq
+               self._recv_packet = recv_packet
+               threading.Thread.__init__(self)
+               self.setDaemon(1)
+               self.keep_running = True
+               self.start()
+               
+       def run(self):
+               """
+               Run this thread by sampling the message queue and calling send 
payload          
+               """
+               while self.keep_running:
+                       msg = self._msgq.delete_head() #blocking read of 
message queue
+                       packet = msg.to_string()        
+                       self._recv_packet(packet)       
+
+class PacketDemodHelper(gr.hier_block2):
+       """
+       Hierarchical block for demodulating and deframing packets.
+       """
+
+       def __init__(self, item_size, access_code=None, threshold=-1):
+               """!
+               PacketDemodHelper contructor.   
+               @param item_size the size of the input data stream in bytes     
+               @param access_code AKA sync vector
+               @param threshold detect access_code with up to threshold bits 
wrong (-1 -> use default)
+               """
+               #setup parameters
+               self._item_size = item_size                     
+               #access code
+               if access_code is None: #get access code
+                       access_code = packet_utils.default_access_code
+               if not packet_utils.is_1_0_string(access_code):
+                       raise ValueError, "Invalid access_code %r. Must be 
string of 1's and 0's" % (access_code,)
+               self._access_code = access_code         
+      #threshold
+               if threshold == -1: threshold = DEFAULT_THRESHOLD 
+               self._threshold = threshold  
+               #initialize hier2
+               gr.hier_block2.__init__(
+                       self,
+                       "packet_demod",
+                       gr.io_signature(1, 1, gr.sizeof_char), # Input signature
+                       gr.io_signature(1, 1, self._item_size), # Output 
signature
+               ) 
+               #blocks
+               self._msgq_in = gr.msg_queue(DEFAULT_MSGQ_LIMIT)          # 
holds packets from the PHY
+               correlator = gr.correlate_access_code_bb(self._access_code, 
self._threshold)
+               framer_sink = gr.framer_sink_1(self._msgq_in)           
+               msg_source = gr.message_source(self._item_size, 
DEFAULT_MSGQ_LIMIT)
+               self._msgq_out = msg_source.msgq()      
+               #connect
+               self.connect(self, correlator, framer_sink)
+               self.connect(msg_source, self)
+               #start thread
+               PacketDemodThread(self._msgq_in, self._recv_packet)
+                       
+       def _recv_packet(self, packet):
+               """!
+               Extract the payload from the packet and push onto message queue.
+               @param packet data received
+               """
+               ok, payload = packet_utils.unmake_packet(packet)
+               msg = gr.message_from_string(payload, 0, self._item_size, 
len(payload)/self._item_size)
+               if ok: self._msgq_out.insert_tail(msg)
+       
+def PacketDemod(sb):
+       type = Enum(all_choices, 1)
+       sb.add_input_socket('in', Byte())
+       sb.add_output_socket('out', Variable(type))             
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Access Code', String())
+       sb.add_param('Threshold', Int(-1))
+       sb.set_docs("""\
+Packet demodulator block, for use with the gnuradio demodulator blocks: gmsk, 
psk, qam.
+
+Access Code: string of 1's and 0's, leave blank for default.
+""")
+       def make(fg, type, access_code, threshold):
+               access_code = access_code.parse()
+               if not access_code: access_code = None
+               return PacketDemodHelper(
+                       item_size = type.parse().get_num_bytes(),
+                       access_code=access_code, 
+                       threshold=threshold.parse(),
+               )
+       return sb, make
+               
+#######################################################################################
 ##     TUN/TAP 
 
#######################################################################################
 

Modified: grc/trunk/src/SignalBlockDefs/SignalBlockTree.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/SignalBlockTree.py    2007-09-15 18:10:46 UTC 
(rev 6448)
+++ grc/trunk/src/SignalBlockDefs/SignalBlockTree.py    2007-09-15 23:26:49 UTC 
(rev 6449)
@@ -158,6 +158,8 @@
                                ('GMSK Demodulator', Modulators.GMSKDemod),
                                ('QAM Modulator', Modulators.QAMMod),
                                ('QAM Demodulator', Modulators.QAMDemod),
+                               ('Packet Modulator', Packet.PacketMod),
+                               ('Packet Demodulator', Packet.PacketDemod),
                        ]),
                        ('Coders', [
                                ('Constellation Decoder', 
Coders.ConstellationDecoder),                         

Modified: grc/trunk/src/SignalBlockDefs/Sinks.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Sinks.py      2007-09-15 18:10:46 UTC (rev 
6448)
+++ grc/trunk/src/SignalBlockDefs/Sinks.py      2007-09-15 23:26:49 UTC (rev 
6449)
@@ -115,12 +115,10 @@
                        complex_data = numpy.fromstring (s, numpy.float32)
                        if len(complex_data) == 2: new_value = "%f + 
%fj"%(complex_data[0], complex_data[1])
                        else: new_value = "%f"%(complex_data[0],)
-                       #MUTEX.lock()   
                        # write the new value #         
                        Variables.reregister(self.var_key, new_value)           
                
                        #       parse the call backs    #                       
        
                        self.fg.parse_callbacks()       
-                       #MUTEX.unlock()
                
 def VariableSink(sb):
        type = Enum(all_choices, 1)





reply via email to

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