|
@@ -192,30 +192,34 @@ blocks:
|
|
id: epy_block
|
|
id: epy_block
|
|
parameters:
|
|
parameters:
|
|
_source_code: "import gnuradio\nimport numpy\nimport serial\n\n\nclass SerialSourceBlock(gnuradio.gr.sync_block):\n\
|
|
_source_code: "import gnuradio\nimport numpy\nimport serial\n\n\nclass SerialSourceBlock(gnuradio.gr.sync_block):\n\
|
|
- \ def __init__(\n self, port=\"/dev/ttyUSB0\", baud_rate=115200, buffer_max_length=10,\
|
|
|
|
- \ timeout=2\n ):\n gnuradio.gr.sync_block.__init__(\n self,\
|
|
|
|
- \ name=\"Serial Source Block\", in_sig=None, out_sig=[numpy.uint8]\n \
|
|
|
|
- \ )\n self._serial_port = serial.Serial(\n port=port, baudrate=baud_rate,\
|
|
|
|
- \ bytesize=serial.EIGHTBITS, timeout=timeout\n )\n self._buffer_max_length\
|
|
|
|
- \ = buffer_max_length\n\n def work(self, input_items, output_items):\n \
|
|
|
|
- \ # pylint: disable=unused-argument\n buffer = self._serial_port.read(\n\
|
|
|
|
- \ min(len(output_items[0]), self._buffer_max_length)\n )\n\
|
|
|
|
- \ output_items[0][: len(buffer)] = numpy.frombuffer(buffer, dtype=\"\
|
|
|
|
- u1\")\n assert output_items[0][: len(buffer)].max() <= 1, \"invalid value\"\
|
|
|
|
- \n return len(buffer)\n"
|
|
|
|
|
|
+ \ def __init__(\n self,\n port=\"/dev/ttyUSB0\",\n baud_rate=115200,\n\
|
|
|
|
+ \ buffer_max_length=10,\n timeout=2,\n invert=False,\n\
|
|
|
|
+ \ ):\n # pylint: disable=too-many-arguments\n gnuradio.gr.sync_block.__init__(\n\
|
|
|
|
+ \ self, name=\"Serial Source Block\", in_sig=None, out_sig=[numpy.uint8]\n\
|
|
|
|
+ \ )\n self._serial_port = serial.Serial(\n port=port,\
|
|
|
|
+ \ baudrate=baud_rate, bytesize=serial.EIGHTBITS, timeout=timeout\n )\n\
|
|
|
|
+ \ self._buffer_max_length = buffer_max_length\n self._invert =\
|
|
|
|
+ \ invert\n\n def work(self, input_items, output_items):\n # pylint:\
|
|
|
|
+ \ disable=unused-argument\n buffer = self._serial_port.read(\n \
|
|
|
|
+ \ min(len(output_items[0]), self._buffer_max_length)\n )\n \
|
|
|
|
+ \ output_items[0][: len(buffer)] = numpy.frombuffer(buffer, dtype=\"u1\")\n\
|
|
|
|
+ \ if self._invert:\n output_items[0] ^= 1\n assert\
|
|
|
|
+ \ output_items[0][: len(buffer)].max() <= 1, \"invalid value\"\n return\
|
|
|
|
+ \ len(buffer)\n"
|
|
affinity: ''
|
|
affinity: ''
|
|
alias: ''
|
|
alias: ''
|
|
baud_rate: '115200'
|
|
baud_rate: '115200'
|
|
buffer_max_length: int(sample_rate_hz/4)
|
|
buffer_max_length: int(sample_rate_hz/4)
|
|
comment: ''
|
|
comment: ''
|
|
|
|
+ invert: 'False'
|
|
maxoutbuf: '0'
|
|
maxoutbuf: '0'
|
|
minoutbuf: '0'
|
|
minoutbuf: '0'
|
|
port: '''/dev/ttyUSB0'''
|
|
port: '''/dev/ttyUSB0'''
|
|
timeout: '2'
|
|
timeout: '2'
|
|
states:
|
|
states:
|
|
_io_cache: ('Serial Source Block', 'SerialSourceBlock', [('port', "'/dev/ttyUSB0'"),
|
|
_io_cache: ('Serial Source Block', 'SerialSourceBlock', [('port', "'/dev/ttyUSB0'"),
|
|
- ('baud_rate', '115200'), ('buffer_max_length', '10'), ('timeout', '2')], [],
|
|
|
|
- [('0', 'byte', 1)], '', [])
|
|
|
|
|
|
+ ('baud_rate', '115200'), ('buffer_max_length', '10'), ('timeout', '2'), ('invert',
|
|
|
|
+ 'False')], [], [('0', 'byte', 1)], '', [])
|
|
bus_sink: false
|
|
bus_sink: false
|
|
bus_source: false
|
|
bus_source: false
|
|
bus_structure: null
|
|
bus_structure: null
|