optimierung

This commit is contained in:
2024-07-18 10:20:21 +02:00
parent b081c33748
commit 083767f626

25
main.py
View File

@@ -440,6 +440,11 @@ class ArduinoGUI:
self.csv_writer.writerow([formatted_time, formatted_angle, formatted_setpoint, formatted_torque, formatted_output]) self.csv_writer.writerow([formatted_time, formatted_angle, formatted_setpoint, formatted_torque, formatted_output])
except Exception as e:
print(e)
if self.ser: if self.ser:
if self.ser.in_waiting: if self.ser.in_waiting:
try: try:
@@ -458,7 +463,6 @@ class ArduinoGUI:
try: try:
pass pass
self.connect_lsp() self.connect_lsp()
except Exception as e: except Exception as e:
print(e) print(e)
@@ -466,7 +470,26 @@ class ArduinoGUI:
def lsp_communication_loop(self): def lsp_communication_loop(self):
while self.running: while self.running:
if self.ser:
if self.ser.in_waiting:
try:
command = self.ser.readline().decode(errors='ignore').strip()
print(command)
if command == 'a':
message = f"{self.current_angle};{self.current_torque};{self.analogInput};{self.currentSetpoint};{self.currentOutput}\n"
self.ser.write(message.encode())
time.sleep(0.1)
while self.ser.out_waiting:
pass pass
except Exception as e:
print(e)
#self.ser.write(b'Hallo\n')
else :
try:
pass
self.connect_lsp()
except Exception as e:
print(e)
def send_pid_parameters(self): def send_pid_parameters(self):