Revision 284
| trunk/swipe/pingTest.py (revision 284) | ||
|---|---|---|
| 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]) |
|
| 29 |
|
|
| 30 |
def ping(t): |
|
| 31 |
common.sendMessage(t, common.TT_PING, "") |
|
| 32 |
return common.checkAck(t) |
|
| 33 |
|
|
| 34 |
acks = [] |
|
| 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 |
|
| trunk/swipe/manualtron.py (revision 284) | ||
|---|---|---|
| 44 | 44 |
|
| 45 | 45 |
def ping(t): |
| 46 | 46 |
common.sendMessage(t, common.TT_PING, "") |
| 47 |
print common.checkAck(t) |
|
| 47 |
return common.checkAck(t) |
|
| 48 | 48 |
|
| trunk/swipe/tooltron.py (revision 284) | ||
|---|---|---|
| 39 | 39 |
|
| 40 | 40 |
import sys |
| 41 | 41 |
import MySQLdb |
| 42 |
import getpass |
|
| 42 |
import base64 |
|
| 43 | 43 |
import datetime |
| 44 | 44 |
from datetime import date |
| 45 | 45 |
from time import * |
| 46 | 46 |
sys.path.append('../common')
|
| 47 | 47 |
import common |
| 48 | 48 |
|
| 49 |
keypadTimeout = 12 #in seconds |
|
| 50 |
|
|
| 51 | 49 |
#this table maps which keypad button to press for each tool. This |
| 52 | 50 |
#list should probably be printed next to the swipe box |
| 53 | 51 |
tools = {
|
| 54 |
'Bandsaw':[], |
|
| 55 |
'DrillPress':['3','8'], |
|
| 56 |
'Mill':['4'], |
|
| 52 |
'Bandsaw':['3','4'], |
|
| 53 |
'DrillPress':['1','2'], |
|
| 54 |
'Mill':['5'], |
|
| 57 | 55 |
'Lathe':[], |
| 58 | 56 |
#HACK: since the saw isn't used I use it for testing random boards |
| 59 | 57 |
'ChopMiterSaw':['1','2','5','6','7','9'] |
| ... | ... | |
| 64 | 62 |
#boards were swapped out. The tool ID number should be printed on the |
| 65 | 63 |
#tool board, but needs to be hand coded into the toolbox code |
| 66 | 64 |
ids = {
|
| 67 |
'1':11, |
|
| 68 |
'2':12, |
|
| 69 |
'3':13, |
|
| 70 |
'4':14, |
|
| 71 |
'5':15, |
|
| 72 |
'6':16, |
|
| 73 |
'7':17, |
|
| 74 |
'8':18, |
|
| 75 |
'9':19, |
|
| 76 |
'0':13 |
|
| 65 |
'1':13, |
|
| 66 |
'2':18, |
|
| 67 |
'3':11, |
|
| 68 |
'4':17, |
|
| 69 |
'5':14, |
|
| 70 |
'6':10, |
|
| 71 |
'7':10, |
|
| 72 |
'8':10, |
|
| 73 |
'9':10, |
|
| 74 |
'0':10 |
|
| 77 | 75 |
} |
| 78 | 76 |
|
| 79 | 77 |
try: |
| ... | ... | |
| 124 | 122 |
print "usage: tooltron.py /path/to/bus/device" |
| 125 | 123 |
else: |
| 126 | 124 |
|
| 127 |
pw = getpass.getpass("mysql password: ")
|
|
| 125 |
# read password |
|
| 126 |
try: |
|
| 127 |
passfile = open('pass', 'r')
|
|
| 128 | 128 |
|
| 129 |
except IOError as e: |
|
| 130 |
print "\========================================" |
|
| 131 |
print "File 'pass' could not be opened!" |
|
| 132 |
print e |
|
| 133 |
print "This file is required for MySQL authentication" |
|
| 134 |
print "\========================================" |
|
| 135 |
exit(-1) |
|
| 136 |
|
|
| 137 |
pw = base64.b64decode(passfile.read()) |
|
| 138 |
|
|
| 129 | 139 |
cursor = None |
| 130 | 140 |
qry1 = "SELECT tools_6 FROM civicrm_value_roboclub_info_2 WHERE card_number_1 = " |
| 131 | 141 |
|
Also available in: Unified diff