{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "37a4d718", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'lo' (status: 0, multicast: 1, broadcast: 0)\n", "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'eth0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'wlan0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'p2p0' (status: 4096, multicast: 0, broadcast: 2)\n", "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'lo' (status: 0, multicast: 1, broadcast: 0)\n", "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'eth0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.506 ( 0.018s) [python3 ] netinterfaces.cpp:102 INFO| \tIPv4 addr: c0a80172\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'wlan0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:102 INFO| \tIPv4 addr: c0a80001\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'lo' (status: 0, multicast: 1, broadcast: 0)\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'eth0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:105 INFO| \tIPv6 addr: fd24:dec0:e89c::b8b\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'eth0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:105 INFO| \tIPv6 addr: fd24:dec0:e89c:0:57e3:6122:3c71:7ca4\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'eth0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:105 INFO| \tIPv6 addr: fe80::1d2b:5fd6:c05d:9642%eth0\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:91 INFO| netif 'wlan0' (status: 4096, multicast: 1, broadcast: 2)\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] netinterfaces.cpp:105 INFO| \tIPv6 addr: fe80::7ed9:5cff:feb2:5133%wlan0\n", "2022-03-25 20:14:39.507 ( 0.018s) [python3 ] api_config.cpp:270 INFO| Loaded default config\n", "2022-03-25 20:14:39.509 ( 0.020s) [python3 ] common.cpp:65 INFO| v1.15.2-108-g6cdcf74d\n", "2022-03-25 20:14:39.509 ( 0.021s) [python3 ] udp_server.cpp:82 WARN| Could not bind multicast responder for ff02:113d:6fdd:2c17:a643:ffe2:1bd1:3cd2 to interface fd24:dec0:e89c:0:57e3:6122:3c71:7ca4 (Address already in use)\n", "2022-03-25 20:14:39.509 ( 0.021s) [python3 ] udp_server.cpp:82 WARN| Could not bind multicast responder for ff02:113d:6fdd:2c17:a643:ffe2:1bd1:3cd2 to interface fe80::7ed9:5cff:feb2:5133%wlan0 (Address already in use)\n", "2022-03-25 20:14:39.509 ( 0.021s) [python3 ] udp_server.cpp:82 WARN| Could not bind multicast responder for ff05:113d:6fdd:2c17:a643:ffe2:1bd1:3cd2 to interface fd24:dec0:e89c:0:57e3:6122:3c71:7ca4 (Address already in use)\n", "2022-03-25 20:14:39.510 ( 0.021s) [python3 ] udp_server.cpp:82 WARN| Could not bind multicast responder for ff05:113d:6fdd:2c17:a643:ffe2:1bd1:3cd2 to interface fe80::7ed9:5cff:feb2:5133%wlan0 (Address already in use)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "now sending data...\n" ] }, { "ename": "KeyboardInterrupt", "evalue": "", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", "\u001b[0;32m/tmp/ipykernel_3906/1992969341.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 42\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0.01\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 44\u001b[0;31m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/tmp/ipykernel_3906/1992969341.py\u001b[0m in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0msent_samples\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0mrequired_samples\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 41\u001b[0m \u001b[0;31m# now send it and wait for a bit before trying again.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 42\u001b[0;31m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0.01\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 43\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 44\u001b[0m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], "source": [ "\"\"\"Example program to demonstrate how to send a multi-channel time series to\n", "LSL.\"\"\"\n", "import sys\n", "import getopt\n", "\n", "import time\n", "from random import random as rand\n", "\n", "from pylsl import StreamInfo, StreamOutlet, local_clock\n", "\n", "\n", "def main():\n", " srate = 100\n", " name = 'BioSemi'\n", " type = 'EEG'\n", " n_channels = 8\n", "\n", " # first create a new stream info (here we set the name to BioSemi,\n", " # the content-type to EEG, 8 channels, 100 Hz, and float-valued data) The\n", " # last value would be the serial number of the device or some other more or\n", " # less locally unique identifier for the stream as far as available (you\n", " # could also omit it but interrupted connections wouldn't auto-recover)\n", " info = StreamInfo(name, type, n_channels, srate, 'float32', 'myuid34234')\n", "\n", " # next make an outlet\n", " outlet = StreamOutlet(info)\n", "\n", " print(\"now sending data...\")\n", " start_time = local_clock()\n", " sent_samples = 0\n", " while True:\n", " elapsed_time = local_clock() - start_time\n", " required_samples = int(srate * elapsed_time) - sent_samples\n", " for sample_ix in range(required_samples):\n", " # make a new random n_channels sample; this is converted into a\n", " # pylsl.vectorf (the data type that is expected by push_sample)\n", " mysample = [rand() for _ in range(n_channels)]\n", " # now send it\n", " outlet.push_sample(mysample)\n", " sent_samples += required_samples\n", " # now send it and wait for a bit before trying again.\n", " time.sleep(0.01)\n", "\n", "main()" ] }, { "cell_type": "code", "execution_count": null, "id": "e67e094c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 5 }