last changes before test run
This commit is contained in:
parent
e091a32017
commit
e4162538ea
|
@ -80,21 +80,24 @@ class Platform(object):
|
|||
def create_args(name):
|
||||
arg_parser = ArgParser(name)
|
||||
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()
|
||||
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()
|
||||
return args
|
||||
|
||||
|
||||
def init():
|
||||
args = create_args(os.path.basename(sys.argv[0]))
|
||||
def init(prog_name, port=None):
|
||||
args = create_args(prog_name)
|
||||
if port:
|
||||
args.chaosc_host = "lucas"
|
||||
args.chaosc_port = 6002
|
||||
platform = Platform(args)
|
||||
platform.connect()
|
||||
atexit.register(platform.close)
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import time, select, sys
|
||||
import select
|
||||
|
||||
from sensors2osc.common import *
|
||||
from chaosc.lib import logger
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -35,7 +34,7 @@ def main():
|
|||
|
||||
while 1:
|
||||
try:
|
||||
toread, towrite, toerrors = select.select([platform.serial_sock], [],[], 0.01)
|
||||
toread, towrite, toerrors = select.select([platform.serial_sock], [], [], 0.01)
|
||||
if toread:
|
||||
t = platform.serial_sock.read(1)
|
||||
else:
|
||||
|
@ -46,16 +45,18 @@ def main():
|
|||
logger.info("serial socket error!!! - try to reconnect")
|
||||
platform.reconnect()
|
||||
|
||||
t = None
|
||||
try:
|
||||
t = ord(t)
|
||||
except TypeError, e:
|
||||
except TypeError:
|
||||
continue
|
||||
|
||||
#if msg_count >= 20:
|
||||
if msg_count < 20:
|
||||
# logger.info("value = %d", t)
|
||||
# msg_count = 0
|
||||
#else:
|
||||
# msg_count += 1
|
||||
msg_count += 1
|
||||
continue
|
||||
else:
|
||||
msg_count = 0
|
||||
|
||||
try:
|
||||
osc_message = OSCMessage("/%s/ekg" % actor)
|
||||
|
|
Loading…
Reference in New Issue