From f091a1d57864d10161088bba472ebdcecdac1db4 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Thu, 28 Mar 2024 12:59:22 +0100 Subject: [PATCH] Only allow access to flash and EEPROM tabs after reading signature Also mark by green or red color if the signature matches the selected device, and log a if they do not match. Tune the error and warning colors a bit. --- src/python/adgui.py | 14 ++++++++++++-- src/python/memories.ui | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/python/adgui.py b/src/python/adgui.py index 0b7d5dfe..9d704a7d 100755 --- a/src/python/adgui.py +++ b/src/python/adgui.py @@ -241,8 +241,8 @@ class adgui(QObject): # level to color mapping colors = [ '#804040', # MSG_EXT_ERROR - '#603030', # MSG_ERROR - '#605000', # MSG_WARNING + '#A03030', # MSG_ERROR + '#A08000', # MSG_WARNING '#000000', # MSG_INFO '#006000', # MSG_NOTICE '#005030', # MSG_NOTICE2 @@ -463,12 +463,22 @@ class adgui(QObject): self.pgm.teardown() def read_signature(self): + sig_ok = "background-color: rgb(255, 255, 255);\ncolor: rgb(0, 100, 0);" + sig_bad = "background-color: rgb(255, 255, 255);\ncolor: rgb(150, 0, 0);" if self.connected: m = ad.avr_locate_mem(self.dev, 'signature') if m: ad.avr_read_mem(self.pgm, self.dev, m) self.progress_callback(100, 0, "", 0) # clear progress bar read_sig = m.get(3) + if read_sig == self.dev.signature: + self.memories.deviceSig.setStyleSheet(sig_ok) + else: + self.memories.deviceSig.setStyleSheet(sig_bad) + self.log("Signature read from device does not match config file", + ad.MSG_WARNING) + self.memories.flash.setEnabled(True) + self.memories.eeprom.setEnabled(True) sigstr = read_sig.hex(' ').upper() self.memories.deviceSig.setText(sigstr) p = ad.locate_part_by_signature(ad.cvar.part_list, read_sig) diff --git a/src/python/memories.ui b/src/python/memories.ui index 5e747c59..55ed963e 100644 --- a/src/python/memories.ui +++ b/src/python/memories.ui @@ -33,6 +33,9 @@ + + true + 30 @@ -182,7 +185,7 @@ - true + false Flash @@ -434,6 +437,9 @@ + + false + EEPROM