|
|
@ -22,7 +22,6 @@ class CANParser(object): |
|
|
|
self.msgs_ck = [check[0] for check in checks] |
|
|
|
self.msgs_ck = [check[0] for check in checks] |
|
|
|
self.frqs = [check[1] for check in checks] |
|
|
|
self.frqs = [check[1] for check in checks] |
|
|
|
self.can_valid = False # start with False CAN assumption |
|
|
|
self.can_valid = False # start with False CAN assumption |
|
|
|
self.msgs_upd = [] # list of updated messages |
|
|
|
|
|
|
|
# list of received msg we want to monitor counter and checksum for |
|
|
|
# list of received msg we want to monitor counter and checksum for |
|
|
|
# read dbc file |
|
|
|
# read dbc file |
|
|
|
self.can_dbc = dbc(os.path.join(dbcs.DBC_PATH, dbc_f)) |
|
|
|
self.can_dbc = dbc(os.path.join(dbcs.DBC_PATH, dbc_f)) |
|
|
@ -55,14 +54,14 @@ class CANParser(object): |
|
|
|
self._message_indices[x].append(i) |
|
|
|
self._message_indices[x].append(i) |
|
|
|
|
|
|
|
|
|
|
|
def update_can(self, can_recv): |
|
|
|
def update_can(self, can_recv): |
|
|
|
self.msgs_upd = [] |
|
|
|
msgs_upd = [] |
|
|
|
cn_vl_max = 5 # no more than 5 wrong counter checks |
|
|
|
cn_vl_max = 5 # no more than 5 wrong counter checks |
|
|
|
|
|
|
|
|
|
|
|
# we are subscribing to PID_XXX, else data from USB |
|
|
|
# we are subscribing to PID_XXX, else data from USB |
|
|
|
for msg, ts, cdat, _ in can_recv: |
|
|
|
for msg, ts, cdat, _ in can_recv: |
|
|
|
idxs = self._message_indices[msg] |
|
|
|
idxs = self._message_indices[msg] |
|
|
|
if idxs: |
|
|
|
if idxs: |
|
|
|
self.msgs_upd.append(msg) |
|
|
|
msgs_upd.append(msg) |
|
|
|
# read the entire message |
|
|
|
# read the entire message |
|
|
|
out = self.can_dbc.decode((msg, 0, cdat))[1] |
|
|
|
out = self.can_dbc.decode((msg, 0, cdat))[1] |
|
|
|
# checksum check |
|
|
|
# checksum check |
|
|
@ -116,6 +115,8 @@ class CANParser(object): |
|
|
|
#print "CAN INVALID!" |
|
|
|
#print "CAN INVALID!" |
|
|
|
self.can_valid = False |
|
|
|
self.can_valid = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return msgs_upd |
|
|
|
|
|
|
|
|
|
|
|
def _check_dead_msgs(self): |
|
|
|
def _check_dead_msgs(self): |
|
|
|
### input: |
|
|
|
### input: |
|
|
|
## simple stuff for now: msg is not valid if a message isn't received for 10 consecutive steps |
|
|
|
## simple stuff for now: msg is not valid if a message isn't received for 10 consecutive steps |
|
|
|