From 85247db7d2adbe1d3fe8558a9e3ce8ff5bcebd6f Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 27 Dec 2011 17:26:59 +0100 Subject: [PATCH] Add bong-integrator for openbeacon reader support. Sorry, it's hacky. --- tools/game/bong/integrator-reader.py | 77 ++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/tools/game/bong/integrator-reader.py b/tools/game/bong/integrator-reader.py index 8d42fb7..890b488 100644 --- a/tools/game/bong/integrator-reader.py +++ b/tools/game/bong/integrator-reader.py @@ -9,35 +9,80 @@ import os.path import logging import threading import socket +import time from tornado.options import define, options define("port", default=8888, help="run on the given port", type=int) pong=None -pos=0.5 +left=0.0 +right=0.0 +cntr=0 +cntl=0 +info={} def sendpos(): + global right, left + global cntr, cntl + global info + sstr="{ \"right\": %s, \"cntr\": %s , \"cntl\": %s, \"left\": %s }"%(right,cntr,cntl,left) if pong: - pong.write_message("{ \"right\": "+str(pos)+" }") - threading.Timer(.5,sendpos).start() + pong.write_message(sstr) +# print sstr + threading.Timer(.1,sendpos).start() + for (id,(b,t,r)) in info.items(): + if(t+51: - pos=1 - def workPacket(data, addr): - print "new packet:", list(data), addr + global right, left + global cntr, cntl + global reid + global r0id + global button + global info +# print "new packet:", list(data), addr + reid=ord(data[4])*256 + ord(data[5]) + r0id=ord(data[19])*256*256*256 + ord(data[20])*256*256+ord(data[21])*256+ord(data[22]) + button=ord(data[27]) + rl=1 + if reid == 1123: + rl=2 + info[r0id]=(button,time.time(),rl) + print "added rl=%s r0=%s bu=%s"%(rl,r0id,button) def readerThread(): sock = socket.socket( socket.AF_INET, # Internet