|
@@ -201,41 +201,6 @@ blocks:
|
|
|
coordinate: [483, 324]
|
|
|
rotation: 0
|
|
|
state: true
|
|
|
-- name: epy_block_0
|
|
|
- id: epy_block
|
|
|
- parameters:
|
|
|
- _source_code: "import gnuradio\nimport numpy\nimport serial\n\n\nclass ArduinoAnalogReadings(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=\"Arduino Analog Readings\", in_sig=None, out_sig=[numpy.int16]\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 2 * min(len(output_items[0]), self._buffer_max_length)\n\
|
|
|
- \ )\n assert len(buffer) % 2 == 0\n buffer_samples_count\
|
|
|
- \ = len(buffer) // 2\n output_items[0][:buffer_samples_count] = numpy.frombuffer(buffer,\
|
|
|
- \ dtype=\">u2\")\n assert output_items[0][:buffer_samples_count].max()\
|
|
|
- \ < 1024, \"lost sync?\"\n return buffer_samples_count\n"
|
|
|
- affinity: ''
|
|
|
- alias: ''
|
|
|
- baud_rate: '115200'
|
|
|
- buffer_max_length: int(sample_rate_hz/4)
|
|
|
- comment: ''
|
|
|
- maxoutbuf: '0'
|
|
|
- minoutbuf: '0'
|
|
|
- port: '''/dev/ttyUSB0'''
|
|
|
- timeout: '2'
|
|
|
- states:
|
|
|
- _io_cache: ('Arduino Analog Readings', 'ArduinoAnalogReadings', [('port', "'/dev/ttyUSB0'"),
|
|
|
- ('baud_rate', '115200'), ('buffer_max_length', '10'), ('timeout', '2')], [],
|
|
|
- [('0', 'short', 1)], '', [])
|
|
|
- bus_sink: false
|
|
|
- bus_source: false
|
|
|
- bus_structure: null
|
|
|
- coordinate: [15, 276]
|
|
|
- rotation: 0
|
|
|
- state: true
|
|
|
- name: qtgui_freq_sink_x_0
|
|
|
id: qtgui_freq_sink_x
|
|
|
parameters:
|
|
@@ -633,9 +598,44 @@ blocks:
|
|
|
bus_sink: false
|
|
|
bus_source: false
|
|
|
bus_structure: null
|
|
|
- coordinate: [896, 636]
|
|
|
+ coordinate: [881, 627]
|
|
|
rotation: 0
|
|
|
state: disabled
|
|
|
+- name: serial_source_block
|
|
|
+ id: epy_block
|
|
|
+ parameters:
|
|
|
+ _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.int16]\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 2 * min(len(output_items[0]), self._buffer_max_length)\n\
|
|
|
+ \ )\n assert len(buffer) % 2 == 0\n buffer_samples_count\
|
|
|
+ \ = len(buffer) // 2\n output_items[0][:buffer_samples_count] = numpy.frombuffer(buffer,\
|
|
|
+ \ dtype=\">u2\")\n assert output_items[0][:buffer_samples_count].max()\
|
|
|
+ \ < 1024, \"lost sync?\"\n return buffer_samples_count\n"
|
|
|
+ affinity: ''
|
|
|
+ alias: ''
|
|
|
+ baud_rate: '115200'
|
|
|
+ buffer_max_length: int(sample_rate_hz/4)
|
|
|
+ comment: ''
|
|
|
+ maxoutbuf: '0'
|
|
|
+ minoutbuf: '0'
|
|
|
+ port: '''/dev/ttyUSB0'''
|
|
|
+ timeout: '2'
|
|
|
+ states:
|
|
|
+ _io_cache: ('Serial Source Block', 'SerialSourceBlock', [('port', "'/dev/ttyUSB0'"),
|
|
|
+ ('baud_rate', '115200'), ('buffer_max_length', '10'), ('timeout', '2')], [],
|
|
|
+ [('0', 'short', 1)], '', [])
|
|
|
+ bus_sink: false
|
|
|
+ bus_source: false
|
|
|
+ bus_structure: null
|
|
|
+ coordinate: [15, 276]
|
|
|
+ rotation: 0
|
|
|
+ state: true
|
|
|
|
|
|
connections:
|
|
|
- [blocks_add_const_vxx_0, '0', qtgui_number_sink_0, '0']
|
|
@@ -645,9 +645,9 @@ connections:
|
|
|
- [blocks_short_to_float_0, '0', blocks_multiply_const_vxx_0, '0']
|
|
|
- [blocks_short_to_float_0, '0', qtgui_freq_sink_x_0, '0']
|
|
|
- [blocks_short_to_float_0, '0', qtgui_time_sink_x_0_0, '0']
|
|
|
-- [epy_block_0, '0', blocks_probe_rate_0, '0']
|
|
|
-- [epy_block_0, '0', blocks_short_to_float_0, '0']
|
|
|
-- [epy_block_0, '0', qtgui_number_sink_0_0, '0']
|
|
|
+- [serial_source_block, '0', blocks_probe_rate_0, '0']
|
|
|
+- [serial_source_block, '0', blocks_short_to_float_0, '0']
|
|
|
+- [serial_source_block, '0', qtgui_number_sink_0_0, '0']
|
|
|
|
|
|
metadata:
|
|
|
file_format: 1
|