Index: dialin/protocols/CAN.py =================================================================== diff -u -r21cc5bfbf3079f194f7bad44e87146da5a986226 -rac5801c48b2b5058c330ca67f849ed5d2c55dc3f --- dialin/protocols/CAN.py (.../CAN.py) (revision 21cc5bfbf3079f194f7bad44e87146da5a986226) +++ dialin/protocols/CAN.py (.../CAN.py) (revision ac5801c48b2b5058c330ca67f849ed5d2c55dc3f) @@ -454,7 +454,6 @@ def __init__(self, can_interface: str, logger: Logger, - log_can=False, passive_mode=True, console_out=False): """ @@ -467,7 +466,6 @@ self.message_queue_mutex = threading.Lock() self.response_dictionary_mutex = threading.Lock() self.logger = logger - self.log_can = log_can self.message_queue = deque() self.callback_listener_complete_messages = None self.callback_listener_invalid_messages = None @@ -567,6 +565,7 @@ # Careful here, making this any shorter will start limiting CPU time for other threads sleep(0.01) else: + self.message_queue_mutex.acquire() message: can.Message = self.message_queue.popleft() if message.dlc == DenaliMessage.PACKET_LENGTH: @@ -580,9 +579,6 @@ else: message_length = can_data[DenaliMessage.PAYLOAD_LENGTH_INDEX] - if self.log_can: - self.do_log_can(message, style="candump", channel=self.bus.channel, send=False) - # if we are building a long message, then proceed to push it to the channel dictionary if channel_id in self.long_msg_channel_id_set: self.messages = self.long_message_builders[channel_id].push(message) @@ -648,7 +644,6 @@ # If it is not, this is a publication message and we need to call it's register function else: - self.message_queue_mutex.acquire() if DenaliCanMessenger.is_ui_received_channel(dialin_ch_id): # check if the channel is in ui channels if self.ui_received_function_ptr is not None: self.thread_pool_executor.submit( @@ -662,12 +657,13 @@ self.thread_pool_executor.submit( self.sync_response_dictionary[dialin_ch_id][dialin_msg_id][function_id], complete_dialin_message, message.timestamp) - self.message_queue_mutex.release() + else: self.logger.critical("Invalid message: {}\n".format(self.messages)) # Done with this message, let's get the next one self.messages = None + self.message_queue_mutex.release() @staticmethod def is_ui_received_channel(channel_id: int) -> bool: @@ -765,8 +761,6 @@ data=packet, is_extended_id=False) - if self.log_can: - self.do_log_can(packet, style="candump", channel=self.bus.channel, send=True) self.bus.send(packet, 0) # 0.1) # After all messages have been sent, we clear a flag