Fix demo mode crash due to demo mode toggle 99/29499/1
authorsuchinton2001 <suchinton.2001@gmail.com>
Mon, 4 Dec 2023 14:03:48 +0000 (19:33 +0530)
committersuchinton2001 <suchinton.2001@gmail.com>
Mon, 4 Dec 2023 14:06:09 +0000 (19:36 +0530)
- Avoid starting the same thread twice when running demo-mode
- Add red highlight to toggle button when unchecked
- Log errors when running running steering signals in CAN mode

Bug-AGL: SPEC-5005

Change-Id: I73e163c87149e7d8eee53a7ab953339a7b94e1af
Signed-off-by: suchinton2001 <suchinton.2001@gmail.com>
Widgets/ICPage.py
Widgets/settings.py

index 8681d61..859f3e7 100644 (file)
@@ -384,7 +384,8 @@ class VehicleSimulator(QObject):
         if not self.running:
             self.reset()
             self.running = True
-            self.thread.start()
+            if not self.thread.is_alive():
+                self.thread.start()
 
     def stop(self):
         self.running = False
index 72b1bea..b0512cc 100644 (file)
@@ -47,6 +47,7 @@ def create_animated_toggle():
     return AnimatedToggle(
         checked_color="#4BD7D6",
         pulse_checked_color="#00ffff",
+        pulse_unchecked_color= "#4BD7D6",
     )
 
 
@@ -153,12 +154,12 @@ class settings(Base, Form):
             # check if can0 is available
             try:
                 can_bus = can.interface.Bus(
-                    channel='can0', bustype='socketcan_native')
+                    channel='can0', bustype='socketcan')
                 can_bus.shutdown()
                 Steering_Signal_Type = "CAN"
-            except:
+            except OSError as e:
                 self.CAN_Kuksa_toggle.setChecked(False)
-                logging.error("CAN Bus not available")
+                logging.error(f"CAN0 is not available{e}")
         else:
             Steering_Signal_Type = "Kuksa"