Browse Source

flowchart: rename serial source block

Fabian Peter Hammerle 3 years ago
parent
commit
a5482deaeb
3 changed files with 42 additions and 42 deletions
  1. 1 1
      arduino-sketch.ino
  2. 39 39
      scope.grc
  3. 2 2
      serial_source_block.py

+ 1 - 1
arduino-sketch.ino

@@ -4,7 +4,7 @@ void setup() {
 }
 
 void loop() {
-    // effective sample rate measured in epy_block_0.py
+    // effective sample rate measured with "Probe Rate" block
     delayMicroseconds(800);
     // > On ATmega based boards [...], it takes about 100 microseconds
     // > (0.0001 s) > to read an analog input, [...]

+ 39 - 39
scope.grc

@@ -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

+ 2 - 2
epy_block_0.py → serial_source_block.py

@@ -3,12 +3,12 @@ import numpy
 import serial
 
 
-class ArduinoAnalogReadings(gnuradio.gr.sync_block):
+class SerialSourceBlock(gnuradio.gr.sync_block):
     def __init__(
         self, port="/dev/ttyUSB0", baud_rate=115200, buffer_max_length=10, timeout=2
     ):
         gnuradio.gr.sync_block.__init__(
-            self, name="Arduino Analog Readings", in_sig=None, out_sig=[numpy.int16]
+            self, name="Serial Source Block", in_sig=None, out_sig=[numpy.int16]
         )
         self._serial_port = serial.Serial(
             port=port, baudrate=baud_rate, bytesize=serial.EIGHTBITS, timeout=timeout