Skip to content

Commit

Permalink
Merge pull request #59 from dmg210/main
Browse files Browse the repository at this point in the history
add support for k-line + can adapters
bump gkbus version to 0.2.8
- introduced function to set the adapter to KKL mode
- introduced function to reset the adapter by toggling DTR
  • Loading branch information
dmg210 authored Dec 18, 2024
2 parents a4c4ead + a9f47fe commit c788ae7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions bsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
logger = logging.getLogger("bsl")
logger.setLevel(logging.DEBUG)

# GUI log handler for directing logs to the GUI
class GuiLogHandler(logging.Handler):
"""Log handler for directing logs to the GUI"""
def __init__(self, gui_callback):
super().__init__()
self.gui_callback = gui_callback
Expand All @@ -21,17 +21,16 @@ def emit(self, record):
message = self.format(record)
self.gui_callback(message)

# Function to add the GUI log handler dynamically
def set_gui_log_handler(gui_callback):
""" Add the GUI log handler dynamically"""
gui_handler = GuiLogHandler(gui_callback)
gui_handler.setLevel(logging.DEBUG)
gui_handler.setFormatter(logging.Formatter("%(message)s"))
logger.addHandler(gui_handler)


def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
base_path = (os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)

def ResetAdapter(ser):
Expand Down Expand Up @@ -313,9 +312,8 @@ def CallAtAddress(ser, addr, register): # 8 register words on r8-r15
def RunFunc(exit, ser, file, job, size, eetype, portAddr4, directionPortAddress4, pinnum, progress_callback=None, log_callback2=None):
ResetAdapter(ser)
SetAdapterKKL(ser)

ser.reset_input_buffer()
char = b''

SYSCON_Addr = 0x00ff12
SYSCON_Data_ext = 0xe204 # from 15 -0: 3b stksz, 1b ROMS1, 1b SGTDIS, 1b ROMEN, 1b BYTDIS, 1b CLKEN, 1b WRCFG, 1b CSCFG, 1b reserved,
Expand Down Expand Up @@ -904,7 +902,7 @@ def run_bsl_loop(progress_callback=None, log_callback2=None):
while comcounter < len(ports):
logger.info(f"num: {comcounter} : {ports[comcounter]}")
comcounter += 1
num = input("Type COM to use (pos number): ")
num = input("Select COM Port (position number): ")
try:
comcounter = int(num)
if comcounter >= len(ports) or comcounter < 0:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alive_progress==3.1.5
crcmod==1.7
gkbus==0.2.7
gkbus==0.2.8
pyqt5==5.15.10
PyYAML==6.0.1

0 comments on commit c788ae7

Please sign in to comment.