@@ -66,85 +66,92 @@ def only_toyota_left(candidate_cars):
66
66
67
67
# **** for use live only ****
68
68
def fingerprint (logcan , sendcan , has_relay ):
69
- if has_relay :
70
- # Vin query only reliably works thorugh OBDII
71
- bus = 1
72
-
73
- cached_params = Params ().get ("CarParamsCache" )
74
- if cached_params is not None :
75
- cached_params = car .CarParams .from_bytes (cached_params )
76
- if cached_params .carName == "mock" :
77
- cached_params = None
78
-
79
- if cached_params is not None and len (cached_params .carFw ) > 0 and cached_params .carVin is not VIN_UNKNOWN :
80
- cloudlog .warning ("Using cached CarParams" )
81
- vin = cached_params .carVin
82
- car_fw = list (cached_params .carFw )
83
- else :
84
- cloudlog .warning ("Getting VIN & FW versions" )
85
- _ , vin = get_vin (logcan , sendcan , bus )
86
- car_fw = get_fw_versions (logcan , sendcan , bus )
87
-
88
- fw_candidates = match_fw_to_car (car_fw )
89
- else :
90
- vin = VIN_UNKNOWN
91
- fw_candidates , car_fw = set (), []
92
-
93
- cloudlog .warning ("VIN %s" , vin )
94
- Params ().put ("CarVin" , vin )
95
-
69
+ # if has_relay:
70
+ # # Vin query only reliably works thorugh OBDII
71
+ # bus = 1
72
+
73
+ # cached_params = Params().get("CarParamsCache")
74
+ # if cached_params is not None:
75
+ # cached_params = car.CarParams.from_bytes(cached_params)
76
+ # if cached_params.carName == "mock":
77
+ # cached_params = None
78
+
79
+ # if cached_params is not None and len(cached_params.carFw) > 0 and cached_params.carVin is not VIN_UNKNOWN:
80
+ # cloudlog.warning("Using cached CarParams")
81
+ # vin = cached_params.carVin
82
+ # car_fw = list(cached_params.carFw)
83
+ # else:
84
+ # cloudlog.warning("Getting VIN & FW versions")
85
+ # _, vin = get_vin(logcan, sendcan, bus)
86
+ # car_fw = get_fw_versions(logcan, sendcan, bus)
87
+
88
+ # fw_candidates = match_fw_to_car(car_fw)
89
+ # else:
90
+ # vin = VIN_UNKNOWN
91
+ # fw_candidates, car_fw = set(), []
92
+
93
+ # cloudlog.warning("VIN %s", vin)
94
+ # Params().put("CarVin", vin)
95
+
96
+ # finger = gen_empty_fingerprint()
97
+ # candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1
98
+ # frame = 0
99
+ # frame_fingerprint = 10 # 0.1s
100
+ # car_fingerprint = None
101
+ # done = False
102
+
103
+ # while not done:
104
+ # a = messaging.get_one_can(logcan)
105
+
106
+ # for can in a.can:
107
+ # # need to independently try to fingerprint both bus 0 and 1 to work
108
+ # # for the combo black_panda and honda_bosch. Ignore extended messages
109
+ # # and VIN query response.
110
+ # # Include bus 2 for toyotas to disambiguate cars using camera messages
111
+ # # (ideally should be done for all cars but we can't for Honda Bosch)
112
+ # if can.src in range(0, 4):
113
+ # finger[can.src][can.address] = len(can.dat)
114
+ # for b in candidate_cars:
115
+ # if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \
116
+ # can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]:
117
+ # candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b])
118
+
119
+ # # if we only have one car choice and the time since we got our first
120
+ # # message has elapsed, exit
121
+ # for b in candidate_cars:
122
+ # # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately
123
+ # if only_toyota_left(candidate_cars[b]):
124
+ # frame_fingerprint = 100 # 1s
125
+ # if len(candidate_cars[b]) == 1:
126
+ # if frame > frame_fingerprint:
127
+ # # fingerprint done
128
+ # car_fingerprint = candidate_cars[b][0]
129
+
130
+ # # bail if no cars left or we've been waiting for more than 2s
131
+ # failed = all(len(cc) == 0 for cc in candidate_cars.values()) or frame > 200
132
+ # succeeded = car_fingerprint is not None
133
+ # done = failed or succeeded
134
+
135
+ # frame += 1
136
+
137
+ # source = car.CarParams.FingerprintSource.can
138
+
139
+ # # If FW query returns exactly 1 candidate, use it
140
+ # if len(fw_candidates) == 1:
141
+ # car_fingerprint = list(fw_candidates)[0]
142
+ # source = car.CarParams.FingerprintSource.fw
143
+
144
+ # fixed_fingerprint = os.environ.get('FINGERPRINT', "")
145
+ # if len(fixed_fingerprint):
146
+ # car_fingerprint = fixed_fingerprint
147
+ # source = car.CarParams.FingerprintSource.fixed
148
+
149
+ # force the SUBURBAN
150
+ car_fingerprint = "CHEVROLET SUBURBAN 2019"
96
151
finger = gen_empty_fingerprint ()
97
- candidate_cars = {i : all_known_cars () for i in [0 , 1 ]} # attempt fingerprint on both bus 0 and 1
98
- frame = 0
99
- frame_fingerprint = 10 # 0.1s
100
- car_fingerprint = None
101
- done = False
102
-
103
- while not done :
104
- a = messaging .get_one_can (logcan )
105
-
106
- for can in a .can :
107
- # need to independently try to fingerprint both bus 0 and 1 to work
108
- # for the combo black_panda and honda_bosch. Ignore extended messages
109
- # and VIN query response.
110
- # Include bus 2 for toyotas to disambiguate cars using camera messages
111
- # (ideally should be done for all cars but we can't for Honda Bosch)
112
- if can .src in range (0 , 4 ):
113
- finger [can .src ][can .address ] = len (can .dat )
114
- for b in candidate_cars :
115
- if (can .src == b or (only_toyota_left (candidate_cars [b ]) and can .src == 2 )) and \
116
- can .address < 0x800 and can .address not in [0x7df , 0x7e0 , 0x7e8 ]:
117
- candidate_cars [b ] = eliminate_incompatible_cars (can , candidate_cars [b ])
118
-
119
- # if we only have one car choice and the time since we got our first
120
- # message has elapsed, exit
121
- for b in candidate_cars :
122
- # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately
123
- if only_toyota_left (candidate_cars [b ]):
124
- frame_fingerprint = 100 # 1s
125
- if len (candidate_cars [b ]) == 1 :
126
- if frame > frame_fingerprint :
127
- # fingerprint done
128
- car_fingerprint = candidate_cars [b ][0 ]
129
-
130
- # bail if no cars left or we've been waiting for more than 2s
131
- failed = all (len (cc ) == 0 for cc in candidate_cars .values ()) or frame > 200
132
- succeeded = car_fingerprint is not None
133
- done = failed or succeeded
134
-
135
- frame += 1
136
-
137
- source = car .CarParams .FingerprintSource .can
138
-
139
- # If FW query returns exactly 1 candidate, use it
140
- if len (fw_candidates ) == 1 :
141
- car_fingerprint = list (fw_candidates )[0 ]
142
- source = car .CarParams .FingerprintSource .fw
143
-
144
- fixed_fingerprint = os .environ .get ('FINGERPRINT' , "" )
145
- if len (fixed_fingerprint ):
146
- car_fingerprint = fixed_fingerprint
147
- source = car .CarParams .FingerprintSource .fixed
152
+ vin = VIN_UNKNOWN
153
+ car_fw = []
154
+ source = car .CarParams .FingerprintSource .fixed
148
155
149
156
cloudlog .warning ("fingerprinted %s" , car_fingerprint )
150
157
return car_fingerprint , finger , vin , car_fw , source
0 commit comments