[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6625 - grc/trunk/src/SignalBlockDefs
From: |
jblum |
Subject: |
[Commit-gnuradio] r6625 - grc/trunk/src/SignalBlockDefs |
Date: |
Fri, 12 Oct 2007 17:27:26 -0600 (MDT) |
Author: jblum
Date: 2007-10-12 17:27:25 -0600 (Fri, 12 Oct 2007)
New Revision: 6625
Modified:
grc/trunk/src/SignalBlockDefs/Misc.py
grc/trunk/src/SignalBlockDefs/SignalBlockTree.py
Log:
added serial block, copy block, input terminator, fixed valve
Modified: grc/trunk/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/trunk/src/SignalBlockDefs/Misc.py 2007-10-12 11:19:32 UTC (rev
6624)
+++ grc/trunk/src/SignalBlockDefs/Misc.py 2007-10-12 23:27:25 UTC (rev
6625)
@@ -127,9 +127,107 @@
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 = blks2.selector(item_size, 1, 1, 0, open.parse())
+ block = fcn(item_size, 1, 1, 0, open.parse())
fg.add_callback_locked(block.set_output_index, open)
return block
return sb, make
+def Copy(sb):
+ fcn = gr.kludge_copy
+ type = Enum(all_choices, 1)
+ vlen = Int(1, min=1)
+ sb.add_input_socket('in', Variable(type), vlen=vlen)
+ sb.add_output_socket('out', Variable(type), vlen=vlen)
+ sb.add_param('Type', type, False, type=True)
+ sb.add_param('Vector Length', vlen)
+ sb.set_docs('''Output[i] = Input[i]''')
+ def make(fg, type, vlen):
+ item_size = type.parse().get_num_bytes()*vlen.parse()
+ return fcn(item_size)
+ return sb, make
+
+def InputTerminator(sb):
+ type = Enum(all_choices, 1)
+ vlen = Int(1, min=1)
+ sb.add_output_socket('out', Variable(type), vlen=vlen)
+ sb.add_param('Type', type, False, type=True)
+ sb.add_param('Vector Length', vlen)
+ sb.set_docs('''Terminate a dangling input. The sample rate is zero.''')
+ def make(fg, type, vlen):
+ item_size = type.parse().get_num_bytes()*vlen.parse()
+ null_source = gr.null_source(item_size)
+ head_zero = gr.head(item_size, 0)
+ fg.connect(null_source, head_zero)
+ 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
+ sb.add_input_socket('in', Byte())
+ sb.add_output_socket('out', Byte())
+ 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, 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(Byte().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-12 11:19:32 UTC
(rev 6624)
+++ grc/trunk/src/SignalBlockDefs/SignalBlockTree.py 2007-10-12 23:27:25 UTC
(rev 6625)
@@ -183,8 +183,11 @@
('Valve', Misc.Valve),
('Selector', Misc.Selector),
('Head', Misc.Head),
- ('Skip Head', Misc.SkipHead),
- ('Tun Tap', Packet.TunTap),
+ ('Skip Head', Misc.SkipHead),
+ ('Input Terminator', Misc.InputTerminator),
+ ('Copy', Misc.Copy),
+ ('Tun Tap', Packet.TunTap),
+ ('Serial', Misc.Serial),
('RMS', Misc.RMS),
('About', Misc.About),
('Note', Misc.Note),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6625 - grc/trunk/src/SignalBlockDefs,
jblum <=