cleaned up

This commit is contained in:
Stefan Kögl 2014-03-16 22:49:35 +01:00
parent 33a2c5b573
commit ac5f590ca9
7 changed files with 22 additions and 26 deletions

View File

@ -21,7 +21,7 @@
from __future__ import absolute_import from __future__ import absolute_import
from sensors2osc.common import * from sensors2osc.common import *
import time
def main(): def main():
@ -32,13 +32,13 @@ def main():
while 1: while 1:
try: try:
data = platform.serial_sock.readline()[:-2] data = platform.serial_sock.readline()[:-2]
print repr(data) #print repr(data)
except socket.error, msg: except socket.error, msg:
# got disconnected? # got disconnected?
print "serial socket error!!!", msg print "serial socket error!!!", msg
platform.reconnect() platform.reconnect()
print "got data", repr(data) #print "got data", repr(data)
try: try:
airFlow, emg, temp = data.split(";") airFlow, emg, temp = data.split(";")
except ValueError, e: except ValueError, e:
@ -88,6 +88,7 @@ def main():
except socket.error, msg: except socket.error, msg:
print "cannot connect to chaosc", msg print "cannot connect to chaosc", msg
continue continue
time.sleep(0.1)

View File

@ -20,6 +20,8 @@
from __future__ import absolute_import from __future__ import absolute_import
import time
from sensors2osc.common import * from sensors2osc.common import *
@ -50,6 +52,7 @@ def main():
except socket.error, msg: except socket.error, msg:
print "cannot connect to chaosc" print "cannot connect to chaosc"
continue continue
time.sleep(0.1)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -20,7 +20,7 @@
from __future__ import absolute_import from __future__ import absolute_import
import time
from datetime import datetime from datetime import datetime
from sensors2osc.common import * from sensors2osc.common import *
@ -115,6 +115,7 @@ def main():
except socket.error, msg: except socket.error, msg:
print "cannot connect to chaosc" print "cannot connect to chaosc"
continue continue
time.sleep(0.1)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -21,17 +21,15 @@
# used this line before opening that script # 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 # 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 = sys.argv[1]
serial_sock = serial.Serial()
serial_sock.port = "/tmp/pty2"
serial_sock.baudrate = 115200 serial_sock.baudrate = 115200
serial_sock.timeout = 0 serial_sock.timeout = 0
serial_sock.open() serial_sock.open()
import time, random, struct
while 1: while 1:
serial_sock.write("%d;%d;%d\r\n" % (random.randint(0,1023), random.randint(0,1023), random.randint(0,1023))) 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)

View File

@ -21,17 +21,15 @@
# used this line before opening that script # 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 # 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 = sys.argv[1]
serial_sock = serial.Serial()
serial_sock.port = "/tmp/pty2"
serial_sock.baudrate = 115200 serial_sock.baudrate = 115200
serial_sock.timeout = 0 serial_sock.timeout = 0
serial_sock.open() serial_sock.open()
import time, random, struct
while 1: while 1:
serial_sock.write(struct.pack("B", random.randint(0,255))) serial_sock.write(struct.pack("B", random.randint(0,255)))
#time.sleep(.5) time.sleep(0.1)

View File

@ -23,19 +23,14 @@
from __future__ import absolute_import 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 = sys.argv[1]
serial_sock = serial.Serial()
serial_sock.port = "/tmp/pty2"
serial_sock.baudrate = 115200 serial_sock.baudrate = 115200
serial_sock.timeout = 0 serial_sock.timeout = 0
serial_sock.open() serial_sock.open()
import time, random, struct
class DataGenenerator(object): class DataGenenerator(object):
@ -64,4 +59,4 @@ r = DataGenenerator()
while 1: while 1:
serial_sock.write(struct.pack("B", r.read())) serial_sock.write(struct.pack("B", r.read()))
time.sleep(0.5) time.sleep(0.1)

View File

@ -41,8 +41,8 @@ setup(
author = "Stefan Kögl", author = "Stefan Kögl",
# FIXME: add author email # FIXME: add author email
author_email = "", author_email = "hotte@ctdo.de",
description = "osc filtering application level gateway", description = "tools for sending osc messages from olimex and ehealth biofeedback platforms to OSC",
# FIXME: add long_description # FIXME: add long_description
long_description = """ long_description = """