Skip to content

Commit e48cd8f

Browse files
committed
switch off in development feature on ui
1 parent fd53612 commit e48cd8f

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

serial_plugin/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from .serial_command_runner import SerialCommandRunner
33
from .serial_get_file_structure import FileStructure
44
from .serial_get_version import Version
5+
from .serial_monitor import Debug
56

67

78
__all__ = ["SerialBase",
89
"SerialCommandRunner",
910
"FileStructure",
10-
"Version"]
11+
"Version",
12+
"Debug"]

serial_plugin/serial_command_runner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Callable
44
from .serial_get_version import Version
55
from .serial_get_file_structure import FileStructure
6+
from .serial_monitor import Debug
67

78

89
logger = getLogger(__name__)
@@ -39,6 +40,11 @@ def task() -> None:
3940
thread = Thread(target=task, daemon=True)
4041
thread.start()
4142

43+
@staticmethod
44+
def _run_monitor(port: str) -> str:
45+
with Debug(port=port) as monitor:
46+
return monitor.get_debug()
47+
4248
@staticmethod
4349
def _get_version(port: str) -> str:
4450
"""
@@ -65,6 +71,9 @@ def _get_structure(port: str) -> str:
6571
with FileStructure(port=port) as structure_fetcher:
6672
return structure_fetcher.get_tree()
6773

74+
def get_debug(self, port: str, callback: Callable[[str], None]) -> None:
75+
self._run_in_thread(lambda: self._run_monitor(port), callback)
76+
6877
def get_version(self, port: str, callback: Callable[[str], None]) -> None:
6978
"""
7079
Executes a function to retrieve version information for a given port and

serial_plugin/serial_monitor.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from logging import getLogger, debug
2+
from .serial_base import SerialBase
3+
4+
5+
logger = getLogger(__name__)
6+
7+
8+
class Debug(SerialBase):
9+
"""
10+
Represents a utility for interacting with a device to fetch the
11+
current console over a serial connection.
12+
"""
13+
pass
14+
15+
def get_debug(self) -> str:
16+
while True:
17+
line = self._ser.readline().decode('utf-8', errors='ignore').strip()
18+
19+
if line:
20+
debug(line)

ui/firmware_studio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self):
7272
# PlugIns
7373
self.plugins = FramePlugIns(self)
7474
self.plugins.label.configure(font=FONT_CATEGORY)
75-
self.plugins.mp_debug_btn.configure(command=self._debug_device)
75+
# self.plugins.mp_debug_btn.configure(command=self._debug_device)
7676
self.plugins.mp_version_btn.configure(command=self._get_version)
7777
self.plugins.mp_version_btn.pack_forget()
7878
self.plugins.mp_structure_btn.configure(command=self._get_structure)
@@ -230,7 +230,7 @@ def _disable_buttons(self) -> None:
230230
self.information.memory_info_btn.configure(state='disabled')
231231
self.information.mac_info_btn.configure(state='disabled')
232232
self.information.flash_status_btn.configure(state='disabled')
233-
self.plugins.mp_debug_btn.configure(state='disabled')
233+
# self.plugins.mp_debug_btn.configure(state='disabled')
234234
self.plugins.mp_version_btn.configure(state='disabled')
235235
self.plugins.mp_structure_btn.configure(state='disabled')
236236
self.erase_device.erase_btn.configure(state='disabled')
@@ -246,7 +246,7 @@ def _enable_buttons(self) -> None:
246246
self.information.memory_info_btn.configure(state='normal')
247247
self.information.mac_info_btn.configure(state='normal')
248248
self.information.flash_status_btn.configure(state='normal')
249-
self.plugins.mp_debug_btn.configure(state='normal')
249+
# self.plugins.mp_debug_btn.configure(state='normal')
250250
self.plugins.mp_version_btn.configure(state='normal')
251251
self.plugins.mp_structure_btn.configure(state='normal')
252252
self.erase_device.erase_btn.configure(state='normal')

ui/frame_plugins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def __init__(self, master, *args, **kwargs):
2525
self.label = CTkLabel(self, text='PlugIns')
2626
self.label.pack(padx=10, pady=10)
2727

28-
self.mp_debug_btn = CTkButton(self, text='Debug', fg_color='green')
29-
self.mp_debug_btn.pack(padx=10, pady=5)
28+
# self.mp_debug_btn = CTkButton(self, text='Debug', fg_color='green')
29+
# self.mp_debug_btn.pack(padx=10, pady=5)
3030

3131
self.mp_version_btn = CTkButton(self, text='Version', fg_color='green')
3232
self.mp_version_btn.pack(padx=10, pady=5)

0 commit comments

Comments
 (0)