Revision 300

View differences:

trunk/swipe/pingTest.py
25 25
sys.path.append('../common')
26 26
import common
27 27

  
28
common.initBus(sys.argv[1])
28
common.initBus(sys.argv[1], timeout=0.2)
29 29

  
30 30
def ping(t):
31 31
    common.sendMessage(t, common.TT_PING, "")
......
33 33

  
34 34
acks = []
35 35

  
36
for i in range(256):
37
    if ping(i):
38
        acks.append(i)
39

  
40
print "\n\ndone pinging, responses from:"
41
print acks
36
try:
37
    for i in range(256):
38
        while ping(i):
39
            acks.append(i)
40
    print "\n\ndone pinging"
41
finally:
42
    print "responses from:"
43
    print acks
trunk/common/common.py
248 248
    return cmd == TT_ACK
249 249

  
250 250

  
251
def initBus(filename):
251
def initBus(filename, timeout=1):
252 252
    global bus
253 253

  
254
    bus = serial.Serial(filename, BAUD_RATE, timeout = 1)
254
    bus = serial.Serial(filename, BAUD_RATE, timeout=timeout)
255 255
    bus.flushInput()
256 256
    print bus
257 257

  

Also available in: Unified diff