From baee04c181eb9043606797da2f223a1fafed1ae1 Mon Sep 17 00:00:00 2001
From: Suchinton Chakravarty <suchinton.2001@gmail.com>
Date: Wed, 30 Oct 2024 16:13:15 +0530
Subject: Bug fixes for Control Panel

    - Fixed Stutter while setting values using slider (when databroker is connected),
      Caused due to the values being sent at every step on main thread.
    - Improved error handeling if playback file is empty/ not found
    - Fixed Tire pressure values not being sent when connected to databroker
    - Selected tire pressure value and unit is updated on LCD display as selected

Bug-AGL: SPEC-5161
Change-Id: I66ed5f2e36bd0b0a84743e2c2a8af0de955cf4ba
Signed-off-by: Suchinton Chakravarty <suchinton.2001@gmail.com>
---
 Scripts/record_playback.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'Scripts')

diff --git a/Scripts/record_playback.py b/Scripts/record_playback.py
index 4d067f1..0eb8e70 100644
--- a/Scripts/record_playback.py
+++ b/Scripts/record_playback.py
@@ -10,6 +10,7 @@ import argparse
 from PyQt6.QtCore import QThread, pyqtSignal
 import cantools
 import sys
+import logging
 
 current_dir = os.path.dirname(os.path.abspath(__file__))
 sys.path.append(os.path.dirname(current_dir))
@@ -28,7 +29,7 @@ class CAN_playback(QThread):
     try:
         playbackFile = config.get_playback_file()
     except Exception as e:
-        print(e)
+        logging.error("Error loading playback file:", e)
         # playbackFile = os.path.join(current_dir, "can_messages.txt")
 
     def __init__(self, interface='vcan0'):
@@ -104,7 +105,11 @@ class CAN_playback(QThread):
     def replay_messages(self, messages):
         """Replay CAN messages."""
         # self._running = True
-        start_time = messages[0].timestamp
+        try:
+            start_time = messages[0].timestamp  
+        except IndexError:
+            logging.error("No messages to replay from file:", self.output_file)
+            self.reset()
 
         for msg in messages:
             if not self._running:  # Check if playback should stop
@@ -161,7 +166,6 @@ class CAN_playback(QThread):
 
         if decoded_data['PT_LeftTurnOn'] == 1:
             self.indicatorUpdate.emit('LeftBlinkerOn')
-            print("Left Blinker On")
         if decoded_data['PT_LeftTurnOn'] == 0:
             self.indicatorUpdate.emit('LeftBlinkerOff')
 
-- 
cgit