diff --git a/can/interfaces/ics_neovi/neovi_bus.py b/can/interfaces/ics_neovi/neovi_bus.py index 5366f8155..bd4fc5445 100644 --- a/can/interfaces/ics_neovi/neovi_bus.py +++ b/can/interfaces/ics_neovi/neovi_bus.py @@ -318,8 +318,9 @@ def _process_msg_queue(self, timeout=0.1): if is_tx: if bool(ics_msg.StatusBitField & ics.SPY_STATUS_GLOBAL_ERR): continue - if ics_msg.DescriptionID: - receipt_key = (ics_msg.ArbIDOrHeader, ics_msg.DescriptionID) + + receipt_key = (ics_msg.ArbIDOrHeader, ics_msg.DescriptionID) + if ics_msg.DescriptionID and receipt_key in self.message_receipts: self.message_receipts[receipt_key].set() if not self._receive_own_messages: continue @@ -477,11 +478,10 @@ def send(self, msg, timeout=0): else: raise ValueError("msg.channel must be set when using multiple channels.") - msg_desc_id = next(description_id) - message.DescriptionID = msg_desc_id - receipt_key = (msg.arbitration_id, msg_desc_id) - if timeout != 0: + msg_desc_id = next(description_id) + message.DescriptionID = msg_desc_id + receipt_key = (msg.arbitration_id, msg_desc_id) self.message_receipts[receipt_key].clear() try: @@ -492,5 +492,9 @@ def send(self, msg, timeout=0): # If timeout is set, wait for ACK # This requires a notifier for the bus or # some other thread calling recv periodically - if timeout != 0 and not self.message_receipts[receipt_key].wait(timeout): - raise CanTimeoutError("Transmit timeout") + if timeout != 0: + got_receipt = self.message_receipts[receipt_key].wait(timeout) + # We no longer need this receipt, so no point keeping it in memory + del self.message_receipts[receipt_key] + if not got_receipt: + raise CanTimeoutError("Transmit timeout")