-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestStandardFrame.py
executable file
·67 lines (56 loc) · 1.62 KB
/
testStandardFrame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
'''
Check that standard CAN frames don't cause problems
@author: Bob Jacobsen
'''
import connection as connection
import canolcbutils
def makeframe(header) :
retval = ":S"
retval += hex(header).upper()[2:]
retval += "N"
retval += ";"
return retval
def usage() :
print ""
print "Sends standard-form CAN frames, checking for no reply"
print ""
print "Default connection detail taken from connection.py"
print ""
print "-v verbose"
print "-V Very verbose"
import getopt, sys
def main():
# argument processing
verbose = False
try:
opts, remainder = getopt.getopt(sys.argv[1:], "vV", [])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
usage()
sys.exit(2)
for opt, arg in opts:
if opt == "-v":
verbose = True
elif opt == "-V":
connection.network.verbose = True
verbose = True
else:
assert False, "unhandled option"
retval = test(connection, verbose)
connection.network.close()
exit(retval)
def test(connection, verbose) :
for header in range(0,2048) :
connection.network.send(makeframe(header))
# see if any replies
reply = connection.network.receive()
if reply == None :
return 0
while reply != None :
print "Unexpected reply recieved to standard frame", hex(header), " was ", reply
reply = connection.network.receive()
return 4
if __name__ == '__main__':
main()