diff --git a/build.sh b/build.sh index fafff06..17aada9 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,4 @@ -g++-6 -I/usr/local/include -I/usr/include/python2.7 -fpic -o eeg.o -c eeg_reader.cpp -g++-6 -std=c++11 -shared -Wl,-soname,"libeeg.so" -L/usr/local/lib eeg.o -lboost_python -fpic -o openeeg.so +#! /bin/sh +PYTHON_INCLUDE=${PYTHON_INCLUDE:-/usr/include/python3.11/} +g++ -I/usr/local/include -I "$PYTHON_INCLUDE" -fpic -o eeg.o -c eeg_reader.cpp +g++ -std=c++11 -shared -Wl,-soname,"libeeg.so" -L/usr/local/lib eeg.o -lboost_python -fpic -o openeeg.so diff --git a/processor.py b/processor.py index 5e67573..3ec7d42 100755 --- a/processor.py +++ b/processor.py @@ -1,7 +1,8 @@ -#!/usr/bin/python2 +#! /usr/bin/env python3 import datetime import openeeg import pyqtgraph as pg +import pyqtgraph.Qt as Qt from pyqtgraph.Qt import QtGui, QtCore import numpy as np import threading @@ -10,12 +11,12 @@ print("Starting EEG reader") -data1 = np.ones((1024,), dtype=np.int)*512 -data2 = np.ones((1024,), dtype=np.int)*512 +data1 = np.ones((1024,), dtype=int)*512 +data2 = np.ones((1024,), dtype=int)*512 def qtSlave(): - app = QtGui.QApplication([]) - win = pg.GraphicsWindow(title="My plotting examples") + app = Qt.mkQApp() + win = pg.GraphicsLayoutWidget() win.resize(480,360) win.setWindowTitle('EEG') plotwin1 = win.addPlot(row=0,col=0,title="Channel 1") @@ -24,6 +25,7 @@ def qtSlave(): curve2 = plotwin2.plot(pen='y') plotwin1.setYRange(0,1024,padding=0) plotwin2.setYRange(0,1024,padding=0) + win.show() while True: curve1.setData(y=data1, _callSync='off') curve2.setData(y=data2, _callSync='off') diff --git a/run_eeg.sh b/run_eeg.sh index 11d7c23..d02d4ef 100755 --- a/run_eeg.sh +++ b/run_eeg.sh @@ -1,4 +1,5 @@ -#!/bin/bash -~/eeg/setuptty.sh +#!/bin/sh +set -xeu +./setuptty.sh echo "START" &>> ~/eeg.log -~/eeg/processor.py &>> ~/eeg.log +./processor.py &>> eeg.log diff --git a/setuptty.sh b/setuptty.sh index 0ed3646..9b8d2d2 100755 --- a/setuptty.sh +++ b/setuptty.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/bin/sh +set -xeu sudo stty -F /dev/ttyUSB0 sane 57600 intr undef quit undef erase undef kill undef eof undef eol undef eol2 undef start undef stop undef susp undef rprnt undef werase undef lnext undef flush undef min 1 time 0 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke -sudo chown pi /dev/ttyUSB0 +sudo chown "$(whoami)" /dev/ttyUSB0