-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathfind_wheel.py
More file actions
152 lines (133 loc) · 3.66 KB
/
find_wheel.py
File metadata and controls
152 lines (133 loc) · 3.66 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/python
class SFFMessage:
def __init__(self, line):
self.wid = 0x0000
self.line = line
#break out the pieces
pieces = line.split(',')
if(len(pieces) > 3):
self.idh = pieces[0].split(':')[1].strip()
self.idl = pieces[1].split(':')[1].strip()
self.wid = self.idh + self.idl
self.len = int(pieces[2].split(':')[1].strip(),16)
self.data = pieces[3].split(':')[1].strip()
self.data_pieces = self.data.split(' ')
if len(self.data_pieces) != self.len:
print "ERROR - COULDN'T SPLIT DATA"
def check_for_msg(msg, print_repeats, verbosity):
global lines
if msg.wid in lines.keys():
# print "existing..."
entry = lines[msg.wid]
if entry['len'] != msg.len:
print "Packet with unexpected length found!"
print msg.line
if not print_repeats:
add_msg_to_data(msg)
for x in range(msg.len):
#seen this byte before
if msg.data_pieces[x] not in entry[x].keys():
if verbosity > 0:
print "FOUND DIFFERING BYTE, SLOT %d" % x
print entry[x].keys()
print msg.data_pieces[x]
print msg.line
if verbosity == 0:
print msg.wid
if not print_repeats:
add_msg_to_data(msg)
else:
print "NEW MSG TYPE " + msg.wid
def add_msg_to_data(msg):
global lines
if msg.wid in lines.keys():
# print "existing, add to it"
entry = lines[msg.wid]
if entry['len'] != msg.len:
print "Packet with lengths that don't match found!"
for x in range(msg.len):
#seen this byte before
if msg.data_pieces[x] in entry[x].keys():
entry[x][msg.data_pieces[x]] = entry[x][msg.data_pieces[x]] + 1
# its a new byte
else:
entry[x][msg.data_pieces[x]] = 1
else:
# print "new one, add it"
entry = {'len':msg.len}
for x in range(msg.len):
entry[x] = {msg.data_pieces[x]:1}
lines[msg.wid] = entry
def get_data(filename):
fp = open(filename, "r")
for line in fp:
msg = SFFMessage(line)
if(msg.wid != 0):
add_msg_to_data(msg)
def look_for_different_data(filename, print_repeats, verbosity):
fp = open(filename, "r")
for line in fp:
msg = SFFMessage(line)
if(msg.wid != 0):
check_for_msg(msg, print_repeats, verbosity)
lines = {}
get_data("manual.dat")
idle = lines
lines = {}
get_data("autopark.dat")
#print "steering"
#print
#get_data('autopark.dat')
steering = lines
def print_max(wid, byte):
global lines
min = 255
max = 0
for x in lines[wid][byte]:
val = int(x,16)
if val > max:
max = val
if val < min:
min = val
print "max: %x, min: %x, diff %x" % (max,min,max - min)
def do_max(file, wid, byte):
global lines
print file
lines = {}
get_data(file+".dat")
print_max(wid, byte)
#do_max('off','0250',1)
#do_max('idle','0250',1)
#do_max('reverse','0250',1)
#do_max('drive','0250',1)
#do_max('accelerate','0250',1)
#do_max('steering','0250',1)
#do_max('coast','0250',1)
#do_max('set','0250',1)
#do_max('resume','0250',1)
#do_max('manual','0250',1)
#do_max('autopark','0250',1)
for wid in idle:
# print idle[wid]
for byte in range(idle[wid]['len']):
# print idle[wid][byte]
if len(idle[wid][byte]) < 3:
# print "wid %s at byte %d is static" % (wid, byte)
if len(steering[wid][byte]) >= 3:
print "non static in steering where was static in idle, %s:%d" % (wid, byte)
min = 255
max = 0
for x in steering[wid][byte]:
if int(x,16) > max:
max = int(x,16)
if int(x,16) < min:
min = int(x,16)
# print max - min
print idle[wid][byte]
print steering[wid][byte]
# print idle[wid]
# print steering[wid]
#print idle
#print steering
#look_for_different_data("test.dat", False, 0)
#print lines