добавлена терминалка 1.9b
улучшена терминалка для считывания логов (в качестве ереза и подтверждения коннекта к esp)
This commit is contained in:
parent
5cc802c3be
commit
64db7ec184
BIN
Terminal.exe
Normal file
BIN
Terminal.exe
Normal file
Binary file not shown.
51
getLogs.py
51
getLogs.py
@ -122,7 +122,7 @@ class ESPLoggerTerminal(QWidget):
|
||||
try:
|
||||
self.status_label.setText("Connecting to ESP32...")
|
||||
QApplication.processEvents()
|
||||
ser = serial.Serial(port, baud, timeout=2) # короче таймаут
|
||||
ser = serial.Serial(port, baud, timeout=0.1) # короче таймаут
|
||||
ser.reset_input_buffer()
|
||||
ser.reset_output_buffer()
|
||||
ser.write(b'd\n')
|
||||
@ -191,6 +191,8 @@ class ESPLoggerTerminal(QWidget):
|
||||
self.status_label.setText(f"Log saved to {fname}")
|
||||
QMessageBox.information(self, "Success", f"CSV saved: {fname}")
|
||||
|
||||
|
||||
|
||||
def clear_logs(self):
|
||||
"""Очистка логов на ESP32"""
|
||||
port = self.port_combo.currentData()
|
||||
@ -205,18 +207,55 @@ class ESPLoggerTerminal(QWidget):
|
||||
return
|
||||
|
||||
try:
|
||||
ser = serial.Serial(port, baud, timeout=3)
|
||||
ser = serial.Serial(port, baud, timeout=0.1)
|
||||
ser.write(b'c\n')
|
||||
response = ser.readline().decode(errors='ignore').strip()
|
||||
|
||||
|
||||
# Ждём первую реакцию от ESP32 (например "=== LOG DUMP START ===")
|
||||
pre_line = ser.readline().decode(errors='ignore').strip()
|
||||
first_line = ser.readline().decode(errors='ignore').strip()
|
||||
if not first_line or "LOG ERASING" not in first_line:
|
||||
ser.close()
|
||||
if "CLEARED" in response:
|
||||
QMessageBox.warning(self, "Error", "Selected port is not responding like ESP32")
|
||||
return
|
||||
|
||||
self.status_label.setText("Erasing... May take a few second")
|
||||
QApplication.processEvents()
|
||||
|
||||
|
||||
import time
|
||||
lines = []
|
||||
start_time = time.time()
|
||||
timeout_sec = 15
|
||||
|
||||
while True:
|
||||
if time.time() - start_time > timeout_sec:
|
||||
QMessageBox.warning(self, "Timeout", "No confirmation from ESP32 (timeout).")
|
||||
break
|
||||
|
||||
line = ser.readline().decode(errors='ignore').strip()
|
||||
if line:
|
||||
start_time = time.time()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
if "CLEARED" in line:
|
||||
self.status_label.setText("Logs cleared on ESP32")
|
||||
QMessageBox.information(self, "Success", "Logs cleared on ESP32")
|
||||
else:
|
||||
QMessageBox.warning(self, "Warning", "No confirmation from ESP32")
|
||||
QApplication.processEvents()
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
except Exception as e:
|
||||
QMessageBox.critical(self, "Error", f"Serial error: {e}")
|
||||
|
||||
finally:
|
||||
if 'ser' in locals() and ser and ser.is_open:
|
||||
ser.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
w = ESPLoggerTerminal()
|
||||
|
Loading…
Reference in New Issue
Block a user