Statistics
| Revision:

root / trunk / swipe / pingTest.py @ 301

History | View | Annotate | Download (1.2 KB)

1
#!/usr/bin/python
2

    
3
"""
4
  This file is part of Tooltron.
5
 
6
  Tooltron is free software: you can redistribute it and/or modify
7
  it under the terms of the Lesser GNU General Public License as published by
8
  the Free Software Foundation, either version 3 of the License, or
9
  (at your option) any later version.
10
 
11
  Tooltron is distributed in the hope that it will be useful,
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
  Lesser GNU General Public License for more details.
15
  You should have received a copy of the Lesser GNU General Public License
16
  along with Tooltron.  If not, see <http://www.gnu.org/licenses/>.
17

18
  Copyright 2009 Bradford Neuman <bneuman@andrew.cmu.edu>
19

20
"""
21

    
22
# This files allows you to try to send pings to all possible tools
23

    
24
import sys
25
sys.path.append('../common')
26
import common
27

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

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

    
33
def response(i):
34
    return common.checkAck(t)
35

    
36
acks = []
37

    
38
try:
39
    for i in range(256):
40
        ping(i)
41
        while response(i):
42
            acks.append(i)
43
    print "\n\ndone pinging"
44
finally:
45
    print "responses from:"
46
    print acks