improved serial init for sensors

This commit is contained in:
Stefan Kögl 2014-03-26 14:34:05 +01:00
parent d2b6abbbb5
commit 2df8221eaf
5 changed files with 19 additions and 17 deletions

View File

@ -37,9 +37,9 @@ new-window -n 'pulse2osc-bjoern' -t 'csession:14' 'pulse2osc -4 -d /tmp/puls
new-window -n 'pulse2osc-merle' -t 'csession:15' 'pulse2osc -4 -d /tmp/pulse2osc-merle-out -a merle'
new-window -n 'pulse2osc-uwe' -t 'csession:16' 'pulse2osc -4 -d /tmp/pulse2osc-uwe-out -a uwe'
new-window -n 'ehealth2osc-bjoern' -t 'csession:17' 'ehealth2osc -4 -d /tmp/ehealth2osc-bjoern-out -a bjoern'
new-window -n 'ehealth2osc-merle' -t 'csession:18' 'ehealth2osc -4 -d /tmp/ehealth2osc-merle-out -a merle'
new-window -n 'ehealth2osc-uwe' -t 'csession:19' 'ehealth2osc -4 -d /tmp/ehealth2osc-uwe-out -a uwe'
new-window -n 'ehealth2osc-bjoern' -t 'csession:17' 'sleep 1 && ehealth2osc -4 -d /tmp/ehealth2osc-bjoern-out -a bjoern'
new-window -n 'ehealth2osc-merle' -t 'csession:18' 'sleep 1 && ehealth2osc -4 -d /tmp/ehealth2osc-merle-out -a merle'
new-window -n 'ehealth2osc-uwe' -t 'csession:19' 'sleep 1 && ehealth2osc -4 -d /tmp/ehealth2osc-uwe-out -a uwe'
new-window -n 'test-ekg-bjoern' -t 'csession:20' 'python /home/stefan/dev/psychose/sensors2osc/sensors2osc/socat_ekg_test.py /tmp/ekg2osc-bjoern-in'
new-window -n 'test-ekg-merle' -t 'csession:21' 'python /home/stefan/dev/psychose/sensors2osc/sensors2osc/socat_ekg_test.py /tmp/ekg2osc-merle-in'
@ -52,9 +52,10 @@ new-window -n 'test-pulse-uwe' -t 'csession:25' 'python /home/stefan/dev/ps
new-window -n 'test-ehealth-bjoern' -t 'csession:26' 'python /home/stefan/dev/psychose/sensors2osc/sensors2osc/socat_ehealth_test.py /tmp/ehealth2osc-bjoern-in'
new-window -n 'test-ehealth-merle' -t 'csession:27' 'python /home/stefan/dev/psychose/sensors2osc/sensors2osc/socat_ehealth_test.py /tmp/ehealth2osc-merle-in'
new-window -n 'test-ehealth-uwe' -t 'csession:28' 'python /home/stefan/dev/psychose/sensors2osc/sensors2osc/socat_ehealth_test.py /tmp/ehealth2osc-uwe-in'
# new-window -n 'ekgplotter' -t 'csession:29' 'sleep 5 && ekgplotter -s'
# new-window -n 'vlc' -t 'csession:30' 'sleep 10 && vlc "http://localhost:9000/camera.mjpeg"'
new-window -n 'chaosc_emitter' -t 'csession:31' 'chaosc_emitter'
#new-window -n 'chaosc_emitter' -t 'csession:31' 'chaosc_emitter'
select-window -t 'csession:1'

View File

@ -45,17 +45,15 @@ class Platform(object):
def connect(self):
print "connect serial"
self.serial_sock = serial.Serial()
self.serial_sock.port = self.args.device
self.serial_sock.baudrate = 115200
self.serial_sock.timeout = 0
print "waiting for the device %r to come up" % self.args.device
while 1:
try:
self.serial_sock.open()
break
except serial.serialtuil.SerialException:
self.serial_sock = serial.Serial(self.args.device, 115200, timeout=1)
except serial.serialutil.SerialException, e:
print "serial error", e
pass
else:
break
def close(self):

View File

@ -42,7 +42,7 @@ def main():
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:

View File

@ -20,7 +20,7 @@
from __future__ import absolute_import
import time
import time, select
from datetime import datetime
from sensors2osc.common import *

View File

@ -21,15 +21,18 @@
# 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, sys, time, random, struct
import serial, time, random, sys
serial_sock = serial.Serial()
serial_sock.port = sys.argv[1]
serial_sock.baudrate = 115200
serial_sock.timeout = 0
serial_sock.timeout = 1
serial_sock.writeTimeout = 1
serial_sock.open()
while 1:
serial_sock.write("%d;%d;%d\r\n" % (random.randint(0,1023), random.randint(0,1023), random.randint(0,1023)))
time.sleep(0.05)
a = (random.randint(0,1023), random.randint(0,1023), random.randint(0,1023))
print "data", a
serial_sock.write("%d;%d;%d\r\n" % a)
time.sleep(0.1)