From ac5f590ca9665b98c5792b5d2646e815d20c93be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sun, 16 Mar 2014 22:49:35 +0100 Subject: [PATCH] cleaned up --- sensors2osc/sensors2osc/ehealth2osc.py | 7 ++++--- sensors2osc/sensors2osc/ekg2osc.py | 3 +++ sensors2osc/sensors2osc/pulse2osc.py | 3 ++- sensors2osc/sensors2osc/socat_ehealth_test.py | 10 ++++------ sensors2osc/sensors2osc/socat_ekg_test.py | 10 ++++------ sensors2osc/sensors2osc/socat_pulse_test.py | 11 +++-------- sensors2osc/setup.py | 4 ++-- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sensors2osc/sensors2osc/ehealth2osc.py b/sensors2osc/sensors2osc/ehealth2osc.py index 994f61f..45291ef 100644 --- a/sensors2osc/sensors2osc/ehealth2osc.py +++ b/sensors2osc/sensors2osc/ehealth2osc.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from sensors2osc.common import * - +import time def main(): @@ -32,13 +32,13 @@ def main(): while 1: try: data = platform.serial_sock.readline()[:-2] - print repr(data) + #print repr(data) except socket.error, msg: # got disconnected? print "serial socket error!!!", msg platform.reconnect() - print "got data", repr(data) + #print "got data", repr(data) try: airFlow, emg, temp = data.split(";") except ValueError, e: @@ -88,6 +88,7 @@ def main(): except socket.error, msg: print "cannot connect to chaosc", msg continue + time.sleep(0.1) diff --git a/sensors2osc/sensors2osc/ekg2osc.py b/sensors2osc/sensors2osc/ekg2osc.py index 609bca0..7bc211d 100644 --- a/sensors2osc/sensors2osc/ekg2osc.py +++ b/sensors2osc/sensors2osc/ekg2osc.py @@ -20,6 +20,8 @@ from __future__ import absolute_import +import time + from sensors2osc.common import * @@ -50,6 +52,7 @@ def main(): except socket.error, msg: print "cannot connect to chaosc" continue + time.sleep(0.1) if __name__ == '__main__': diff --git a/sensors2osc/sensors2osc/pulse2osc.py b/sensors2osc/sensors2osc/pulse2osc.py index 32cd7c2..a99a31e 100644 --- a/sensors2osc/sensors2osc/pulse2osc.py +++ b/sensors2osc/sensors2osc/pulse2osc.py @@ -20,7 +20,7 @@ from __future__ import absolute_import - +import time from datetime import datetime from sensors2osc.common import * @@ -115,6 +115,7 @@ def main(): except socket.error, msg: print "cannot connect to chaosc" continue + time.sleep(0.1) if __name__ == '__main__': diff --git a/sensors2osc/sensors2osc/socat_ehealth_test.py b/sensors2osc/sensors2osc/socat_ehealth_test.py index c14808f..2d75cef 100644 --- a/sensors2osc/sensors2osc/socat_ehealth_test.py +++ b/sensors2osc/sensors2osc/socat_ehealth_test.py @@ -21,17 +21,15 @@ # used this line before opening that script # socat -d -d PTY,raw,echo=0,link=/tmp/pty1,b115200,user=stefan PTY,raw,echo=0,link=/tmp/pty2,b115200,user=stefan -import serial +import serial, sys, time, random, struct serial_sock = serial.Serial() - -serial_sock = serial.Serial() -serial_sock.port = "/tmp/pty2" +serial_sock.port = sys.argv[1] serial_sock.baudrate = 115200 serial_sock.timeout = 0 serial_sock.open() -import time, random, struct + while 1: serial_sock.write("%d;%d;%d\r\n" % (random.randint(0,1023), random.randint(0,1023), random.randint(0,1023))) - #time.sleep(.5) + time.sleep(0.1) diff --git a/sensors2osc/sensors2osc/socat_ekg_test.py b/sensors2osc/sensors2osc/socat_ekg_test.py index 4349b09..02a89be 100644 --- a/sensors2osc/sensors2osc/socat_ekg_test.py +++ b/sensors2osc/sensors2osc/socat_ekg_test.py @@ -21,17 +21,15 @@ # used this line before opening that script # socat -d -d PTY,raw,echo=0,link=/tmp/pty1,b115200,user=stefan PTY,raw,echo=0,link=/tmp/pty2,b115200,user=stefan -import serial +import serial, sys, time, random, struct serial_sock = serial.Serial() - -serial_sock = serial.Serial() -serial_sock.port = "/tmp/pty2" +serial_sock.port = sys.argv[1] serial_sock.baudrate = 115200 serial_sock.timeout = 0 serial_sock.open() -import time, random, struct + while 1: serial_sock.write(struct.pack("B", random.randint(0,255))) - #time.sleep(.5) + time.sleep(0.1) diff --git a/sensors2osc/sensors2osc/socat_pulse_test.py b/sensors2osc/sensors2osc/socat_pulse_test.py index 1f99269..b27e48a 100644 --- a/sensors2osc/sensors2osc/socat_pulse_test.py +++ b/sensors2osc/sensors2osc/socat_pulse_test.py @@ -23,19 +23,14 @@ from __future__ import absolute_import -import time, random +import serial, time, random, sys, random, struct -import serial serial_sock = serial.Serial() - -serial_sock = serial.Serial() -serial_sock.port = "/tmp/pty2" +serial_sock.port = sys.argv[1] serial_sock.baudrate = 115200 serial_sock.timeout = 0 serial_sock.open() -import time, random, struct - class DataGenenerator(object): @@ -64,4 +59,4 @@ r = DataGenenerator() while 1: serial_sock.write(struct.pack("B", r.read())) - time.sleep(0.5) + time.sleep(0.1) diff --git a/sensors2osc/setup.py b/sensors2osc/setup.py index f9b4bd8..f4aaaa9 100644 --- a/sensors2osc/setup.py +++ b/sensors2osc/setup.py @@ -41,8 +41,8 @@ setup( author = "Stefan Kögl", # FIXME: add author email - author_email = "", - description = "osc filtering application level gateway", + author_email = "hotte@ctdo.de", + description = "tools for sending osc messages from olimex and ehealth biofeedback platforms to OSC", # FIXME: add long_description long_description = """