commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6682 - grc/trunk/src/SignalBlockDefs


From: jblum
Subject: [Commit-gnuradio] r6682 - grc/trunk/src/SignalBlockDefs
Date: Mon, 22 Oct 2007 18:33:39 -0600 (MDT)

Author: jblum
Date: 2007-10-22 18:33:38 -0600 (Mon, 22 Oct 2007)
New Revision: 6682

Modified:
   grc/trunk/src/SignalBlockDefs/Misc.py
   grc/trunk/src/SignalBlockDefs/SignalBlockTree.py
   grc/trunk/src/SignalBlockDefs/Sinks.py
   grc/trunk/src/SignalBlockDefs/Sources.py
Log:
moved serial block to rs232 source and sink

Modified: grc/trunk/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Misc.py       2007-10-22 23:51:22 UTC (rev 
6681)
+++ grc/trunk/src/SignalBlockDefs/Misc.py       2007-10-23 00:33:38 UTC (rev 
6682)
@@ -161,75 +161,3 @@
                return head_zero
        return sb, make
        
-class SerialHelper(gr.hier_block2):
-       """Make the serial hier2 block."""
-       def __init__(self, item_size, fd):
-               """!
-               SerialHelper constructor.
-               @param item_size the size in bytes of the IO data stream
-               @param fd the file descriptor for the serial device
-               """
-               #create hier block
-               gr.hier_block2.__init__(
-                       self, 'serial', 
-                       gr.io_signature(1, 1, item_size), 
-                       gr.io_signature(1, 1, item_size)
-               )
-               #I/O blocks
-               sink = gr.file_descriptor_sink(item_size, fd)
-               source = gr.file_descriptor_source(item_size, fd)
-               #connect 
-               self.connect(self, sink)
-               self.connect(source, self)      
-               
-def Serial(sb):
-       import serial, os, fcntl
-       type = Enum(all_choices, 1)
-       sb.add_input_socket('in', Variable(type))
-       sb.add_output_socket('out', Variable(type))     
-       sb.add_param('Type', type, False, type=True)
-       sb.add_param('Port', String('/dev/ttyS0'))
-       sb.add_param('Baud Rate', Int(9600, min=0))
-       sb.add_param('Byte Size', Enum([
-                               ('8 bits', serial.EIGHTBITS),   
-                               ('7 bits', serial.SEVENBITS),   
-                               ('6 bits', serial.SIXBITS),     
-                               ('5 bits', serial.FIVEBITS),    
-                       ]
-               )
-       )
-       sb.add_param('Parity', Enum([
-                               ('None', serial.PARITY_NONE),   
-                               ('Even', serial.PARITY_EVEN),   
-                               ('Odd', serial.PARITY_ODD),             
-                       ]
-               )
-       )
-       sb.add_param('Stop Bits', Enum([
-                               ('1 bit', serial.STOPBITS_ONE), 
-                               ('2 bits', serial.STOPBITS_TWO),                
-                       ]
-               )
-       )
-       sb.add_param('Soft Flow Control', Enum([
-                               ('Off', serial.XOFF),   
-                               ('On', serial.XON),             
-                       ]
-               )
-       )
-       def make(fg, type, port, baudrate, bytesize, parity, stopbits, xonxoff):
-               ser = serial.Serial(
-                       port = port.parse(),
-                       baudrate = baudrate.parse(),
-                       bytesize = bytesize.parse(),
-                       parity = parity.parse(),
-                       stopbits = stopbits.parse(),
-                       timeout = None,
-                       xonxoff = xonxoff.parse(),
-               )
-               fd = ser.fileno()
-               fcntl.fcntl(fd, fcntl.F_SETFL, os.O_SYNC | os.O_RDWR | 
os.O_NOCTTY)  #set blocking
-               return SerialHelper(type.parse().get_num_bytes(), fd)
-       return sb, make
-               
-       
\ No newline at end of file

Modified: grc/trunk/src/SignalBlockDefs/SignalBlockTree.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/SignalBlockTree.py    2007-10-22 23:51:22 UTC 
(rev 6681)
+++ grc/trunk/src/SignalBlockDefs/SignalBlockTree.py    2007-10-23 00:33:38 UTC 
(rev 6682)
@@ -49,6 +49,7 @@
                                ('Audio Source', Audio.AudioSource),
                                ('USRP Source', USRP.USRPSource),
                                ('USRP Dual Source', USRP.USRPDualSource),
+                               ('RS232 Source', Sources.RS232Source),
                        ]),
                        ('Sinks', [             
                                ('Variable Sink', Sinks.VariableSink),          
                        
@@ -58,6 +59,7 @@
                                ('Audio Sink', Audio.AudioSink),
                                ('USRP Sink', USRP.USRPSink),
                                ('USRP Dual Sink', USRP.USRPDualSink),
+                               ('RS232 Sink', Sinks.RS232Sink),
                        ]),
                        ('Graphical Sinks', [                   
                                ('Numerical Sink', 
GraphicalSinks.NumericalSink),       
@@ -187,7 +189,6 @@
                                ('Input Terminator', Misc.InputTerminator),
                                ('Copy', Misc.Copy),                            
                                ('Tun Tap', Packet.TunTap),
-                               ('Serial', Misc.Serial),        
                                ('RMS', Misc.RMS),      
                                ('About', Misc.About),
                                ('Note', Misc.Note),    

Modified: grc/trunk/src/SignalBlockDefs/Sinks.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Sinks.py      2007-10-22 23:51:22 UTC (rev 
6681)
+++ grc/trunk/src/SignalBlockDefs/Sinks.py      2007-10-23 00:33:38 UTC (rev 
6682)
@@ -141,4 +141,53 @@
                return throttle
        return sb, make 
        
+def RS232Sink(sb):
+       import serial, os, fcntl
+       type = Enum(all_choices, 1)
+       sb.add_input_socket('in', Variable(type))       
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Port', String('/dev/ttyS0'))
+       sb.add_param('Baud Rate', Int(9600, min=0))
+       sb.add_param('Byte Size', Enum([
+                               ('8 bits', serial.EIGHTBITS),   
+                               ('7 bits', serial.SEVENBITS),   
+                               ('6 bits', serial.SIXBITS),     
+                               ('5 bits', serial.FIVEBITS),    
+                       ]
+               )
+       )
+       sb.add_param('Parity', Enum([
+                               ('None', serial.PARITY_NONE),   
+                               ('Even', serial.PARITY_EVEN),   
+                               ('Odd', serial.PARITY_ODD),             
+                       ]
+               )
+       )
+       sb.add_param('Stop Bits', Enum([
+                               ('1 bit', serial.STOPBITS_ONE), 
+                               ('2 bits', serial.STOPBITS_TWO),                
+                       ]
+               )
+       )
+       sb.add_param('Soft Flow Control', Enum([
+                               ('Off', serial.XOFF),   
+                               ('On', serial.XON),             
+                       ]
+               )
+       )
+       def make(fg, type, port, baudrate, bytesize, parity, stopbits, xonxoff):
+               ser = serial.Serial(
+                       port = port.parse(),
+                       baudrate = baudrate.parse(),
+                       bytesize = bytesize.parse(),
+                       parity = parity.parse(),
+                       stopbits = stopbits.parse(),
+                       timeout = None,
+                       xonxoff = xonxoff.parse(),
+               )
+               fd = ser.fileno()
+               fcntl.fcntl(fd, fcntl.F_SETFL, os.O_SYNC | os.O_WRONLY)  #set 
blocking, and write only
+               return gr.file_descriptor_sink(type.parse().get_num_bytes(), fd)
+       return sb, make
+       
        
\ No newline at end of file

Modified: grc/trunk/src/SignalBlockDefs/Sources.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Sources.py    2007-10-22 23:51:22 UTC (rev 
6681)
+++ grc/trunk/src/SignalBlockDefs/Sources.py    2007-10-23 00:33:38 UTC (rev 
6682)
@@ -157,4 +157,54 @@
        sb.add_param('Payload Size', Int(512, min=1))
        sb.add_param('Vector Length', vlen)
        return sb, lambda fg, type, addr, port, size, vlen: 
fcn(type.parse().get_num_bytes()*vlen.parse(), addr.parse(), port.parse(), 
size.parse())    
+
+def RS232Source(sb):
+       import serial, os, fcntl
+       type = Enum(all_choices, 1)
+       sb.add_output_socket('out', Variable(type))     
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Port', String('/dev/ttyS0'))
+       sb.add_param('Baud Rate', Int(9600, min=0))
+       sb.add_param('Byte Size', Enum([
+                               ('8 bits', serial.EIGHTBITS),   
+                               ('7 bits', serial.SEVENBITS),   
+                               ('6 bits', serial.SIXBITS),     
+                               ('5 bits', serial.FIVEBITS),    
+                       ]
+               )
+       )
+       sb.add_param('Parity', Enum([
+                               ('None', serial.PARITY_NONE),   
+                               ('Even', serial.PARITY_EVEN),   
+                               ('Odd', serial.PARITY_ODD),             
+                       ]
+               )
+       )
+       sb.add_param('Stop Bits', Enum([
+                               ('1 bit', serial.STOPBITS_ONE), 
+                               ('2 bits', serial.STOPBITS_TWO),                
+                       ]
+               )
+       )
+       sb.add_param('Soft Flow Control', Enum([
+                               ('Off', serial.XOFF),   
+                               ('On', serial.XON),             
+                       ]
+               )
+       )
+       def make(fg, type, port, baudrate, bytesize, parity, stopbits, xonxoff):
+               ser = serial.Serial(
+                       port = port.parse(),
+                       baudrate = baudrate.parse(),
+                       bytesize = bytesize.parse(),
+                       parity = parity.parse(),
+                       stopbits = stopbits.parse(),
+                       timeout = None,
+                       xonxoff = xonxoff.parse(),
+               )
+               fd = ser.fileno()
+               fcntl.fcntl(fd, fcntl.F_SETFL, os.O_SYNC | os.O_RDONLY)  #set 
blocking, and read only
+               return gr.file_descriptor_source(type.parse().get_num_bytes(), 
fd)
+       return sb, make
+
        
\ No newline at end of file





reply via email to

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