|
@@ -134,6 +134,19 @@ blocks:
|
|
|
coordinate: [1116, 324]
|
|
|
rotation: 0
|
|
|
state: enabled
|
|
|
+- name: blocks_message_debug_0
|
|
|
+ id: blocks_message_debug
|
|
|
+ parameters:
|
|
|
+ affinity: ''
|
|
|
+ alias: ''
|
|
|
+ comment: ''
|
|
|
+ states:
|
|
|
+ bus_sink: false
|
|
|
+ bus_source: false
|
|
|
+ bus_structure: null
|
|
|
+ coordinate: [991, 817]
|
|
|
+ rotation: 0
|
|
|
+ state: true
|
|
|
- name: blocks_multiply_const_vxx_0
|
|
|
id: blocks_multiply_const_vxx
|
|
|
parameters:
|
|
@@ -152,6 +165,25 @@ blocks:
|
|
|
coordinate: [816, 324]
|
|
|
rotation: 0
|
|
|
state: enabled
|
|
|
+- name: blocks_probe_rate_0
|
|
|
+ id: blocks_probe_rate
|
|
|
+ parameters:
|
|
|
+ affinity: ''
|
|
|
+ alias: ''
|
|
|
+ alpha: '0.15'
|
|
|
+ comment: ''
|
|
|
+ maxoutbuf: '0'
|
|
|
+ minoutbuf: '0'
|
|
|
+ mintime: '10000.0'
|
|
|
+ type: short
|
|
|
+ vlen: '1'
|
|
|
+ states:
|
|
|
+ bus_sink: false
|
|
|
+ bus_source: false
|
|
|
+ bus_structure: null
|
|
|
+ coordinate: [391, 781]
|
|
|
+ rotation: 0
|
|
|
+ state: true
|
|
|
- name: blocks_short_to_float_0
|
|
|
id: blocks_short_to_float
|
|
|
parameters:
|
|
@@ -172,29 +204,19 @@ blocks:
|
|
|
- name: epy_block_0
|
|
|
id: epy_block
|
|
|
parameters:
|
|
|
- _source_code: "import time\n\nimport 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,\
|
|
|
+ _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 self._samples_counter\
|
|
|
- \ = 0\n self._sample_rate_report_timestamp = None\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 self._samples_counter += buffer_samples_count\n\
|
|
|
- \ current_timestamp = time.time()\n if not self._sample_rate_report_timestamp:\n\
|
|
|
- \ self._sample_rate_report_timestamp = current_timestamp\n \
|
|
|
- \ elif (current_timestamp - self._sample_rate_report_timestamp) > 8:\n \
|
|
|
- \ sample_rate_hz = self._samples_counter / (\n current_timestamp\
|
|
|
- \ - self._sample_rate_report_timestamp\n )\n print(f\"\
|
|
|
- {sample_rate_hz:.01f} Hz\")\n self._samples_counter = 0\n \
|
|
|
- \ self._sample_rate_report_timestamp = current_timestamp\n return\
|
|
|
- \ buffer_samples_count\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'
|
|
@@ -619,9 +641,11 @@ connections:
|
|
|
- [blocks_add_const_vxx_0, '0', qtgui_number_sink_0, '0']
|
|
|
- [blocks_add_const_vxx_0, '0', qtgui_time_sink_x_0, '0']
|
|
|
- [blocks_multiply_const_vxx_0, '0', blocks_add_const_vxx_0, '0']
|
|
|
+- [blocks_probe_rate_0, rate, blocks_message_debug_0, print]
|
|
|
- [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']
|
|
|
|