From 678357b838c292a85eab70d0c3857f7732ebf6e1 Mon Sep 17 00:00:00 2001 From: Musab Erdem Date: Wed, 17 Jul 2024 16:38:07 +0200 Subject: [PATCH] =?UTF-8?q?USB=20Kommunikation=20zur=20LSP1=20eingef=C3=BC?= =?UTF-8?q?hrt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/main.py b/main.py index 38b2130..d6a13bc 100644 --- a/main.py +++ b/main.py @@ -19,6 +19,15 @@ class ArduinoGUI: self.root.title("PRG 342 GUI") self.root.attributes('-fullscreen', True) # Setzt das Fenster in den Vollbildmodus + self.ser = serial.Serial( + port='/dev/serial0', + baudrate=192000, + parity=serial.PARITY_NONE, + stopbits=serial.STOPBITS_ONE, + bytesize=serial.EIGHTBITS, + timeout=1 + ) + self.arduino = None self.ports = list(serial.tools.list_ports.comports()) self.running = True @@ -41,6 +50,8 @@ class ArduinoGUI: self.load_configurations() # Start the communication thread + self.lsp_communication_tread = threading.Thread(target=self.lsp_communication_loop) + self.lsp_communication_tread.start() self.communication_thread = threading.Thread(target=self.communication_loop) self.communication_thread.start() @@ -406,6 +417,14 @@ class ArduinoGUI: time.sleep(0.1) + def lsp_communication_loop(self): + while self.running: + if self.ser: + if self.ser.in_waiting: + command = self.ser.readline + self.ser.write(command) + + def send_pid_parameters(self): if self.selected_pid in self.pid_params: pid_values = self.pid_params[self.selected_pid]