last changes before test run

This commit is contained in:
Stefan Kögl 2014-12-04 16:38:55 +01:00
parent e091a32017
commit e4162538ea
2 changed files with 22 additions and 18 deletions

View File

@ -80,21 +80,24 @@ class Platform(object):
def create_args(name): def create_args(name):
arg_parser = ArgParser(name) arg_parser = ArgParser(name)
arg_parser.add_global_group() arg_parser.add_global_group()
main_group = arg_parser.add_argument_group("main")
arg_parser.add_argument(main_group, "-D", '--device',
help='device node under /dev')
arg_parser.add_argument(main_group, "-a", '--actor',
help='actor name')
arg_parser.add_argument(main_group, '-b', '--baudrate', type=int, default=115200, choices=sorted(serial.baudrate_constants.keys()),
help='selects the baudrate, default=115200, for valid values execute "import serial;print sorted(serial.baudrate_constants.keys())"')
arg_parser.add_chaosc_group() arg_parser.add_chaosc_group()
client_group = arg_parser.add_client_group()
arg_parser.add_argument(client_group, "-D", '--device',
help='device node under /dev')
arg_parser.add_argument(client_group, "-a", '--actor',
help='actor name')
arg_parser.add_argument(client_group, '-b', '--baudrate', type=int, default=115200, choices=sorted(serial.baudrate_constants.keys()),
help='selects the baudrate, default=115200, for valid values execute "import serial;print sorted(serial.baudrate_constants.keys())"')
args = arg_parser.finalize() args = arg_parser.finalize()
return args return args
def init(): def init(prog_name, port=None):
args = create_args(os.path.basename(sys.argv[0])) args = create_args(prog_name)
if port:
args.chaosc_host = "lucas"
args.chaosc_port = 6002
platform = Platform(args) platform = Platform(args)
platform.connect() platform.connect()
atexit.register(platform.close) atexit.register(platform.close)

View File

@ -20,10 +20,9 @@
from __future__ import absolute_import from __future__ import absolute_import
import time, select, sys import select
from sensors2osc.common import * from sensors2osc.common import *
from chaosc.lib import logger
def main(): def main():
@ -46,16 +45,18 @@ def main():
logger.info("serial socket error!!! - try to reconnect") logger.info("serial socket error!!! - try to reconnect")
platform.reconnect() platform.reconnect()
t = None
try: try:
t = ord(t) t = ord(t)
except TypeError, e: except TypeError:
continue continue
#if msg_count >= 20: if msg_count < 20:
# logger.info("value = %d", t) # logger.info("value = %d", t)
# msg_count = 0 msg_count += 1
#else: continue
# msg_count += 1 else:
msg_count = 0
try: try:
osc_message = OSCMessage("/%s/ekg" % actor) osc_message = OSCMessage("/%s/ekg" % actor)