Index: dialin/protocols/CAN.py =================================================================== diff -u -r0188c0a21079a4c92efca69e298beeccb93ed22c -re914c6b16fd5114f4b5990d28eaa853509f62c64 --- dialin/protocols/CAN.py (.../CAN.py) (revision 0188c0a21079a4c92efca69e298beeccb93ed22c) +++ dialin/protocols/CAN.py (.../CAN.py) (revision e914c6b16fd5114f4b5990d28eaa853509f62c64) @@ -465,6 +465,7 @@ """ self.message_queue_mutex = threading.Lock() self.response_dictionary_mutex = threading.Lock() + self.transmitting_mutex = threading.Lock() self.logger = logger self.message_queue = deque() self.callback_listener_complete_messages = None @@ -646,6 +647,8 @@ # If it is not, this is a publication message and we need to call it's register function else: + self.response_dictionary_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( @@ -660,6 +663,7 @@ self.sync_response_dictionary[dialin_ch_id][dialin_msg_id][function_id], complete_dialin_message, message.timestamp) + self.response_dictionary_mutex.release() else: self.logger.critical("Invalid message: {}\n".format(self.messages)) @@ -754,6 +758,8 @@ number_of_packets = DenaliMessage.get_total_packets(padded_can_message_array) # We are sending one message at a time on CAN + self.transmitting_mutex.acquire() + for n in range(number_of_packets): packet = padded_can_message_array[n * DenaliMessage.PACKET_LENGTH: (n + 1) * DenaliMessage.PACKET_LENGTH] @@ -765,6 +771,8 @@ self.bus.send(packet, 0) # 0.1) + self.transmitting_mutex.release() + # After all messages have been sent, we clear a flag self.send_event.clear()