From db17fbc1d9327d01cdfe2fd4064cf4a4a2b9bc99 Mon Sep 17 00:00:00 2001 From: musabe24 Date: Mon, 22 Jul 2024 12:12:56 +0200 Subject: [PATCH] Optimierung LSP Schnittstelle --- main.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 2630289..3cc0be8 100644 --- a/main.py +++ b/main.py @@ -445,23 +445,19 @@ class ArduinoGUI: if self.ser.in_waiting: try: command = "" - command = self.ser.read().decode(errors='ignore').strip() while self.ser.in_waiting: - pass - print(command) + command += self.ser.read(1).decode(errors='ignore').strip() if command[0] == 'a': message = f"{self.current_angle};{self.current_torque};{self.analogInput};{self.currentSetpoint};{self.currentOutput}\n" self.ser.write(message.encode()) if command[0] == 'w': self.tare_angle() if command[0] == 'u': - outCommand = F"{command}\n" - self.arduino.write(outCommand.encode()) + outCommand = F"command: {command}\n" + selr.arduino.write(outCommand.encode()) time.sleep(0.1) - - while self.ser.out_waiting: - pass - self.ser.read_all() + + self.ser.read() except Exception as e: print(e) #self.ser.write(b'Hallo\n')