Skip to content

Commit 7dffb56

Browse files
committed
connected verbose
1 parent 9c285f4 commit 7dffb56

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

mpytool/conn_serial.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ def __init__(self, log=None, **serial_config):
2222
# Windows: pyserial has no fd, select() works only with sockets
2323
if not hasattr(self._serial, 'fd'):
2424
self._has_data = self._has_data_polling
25-
# Debug info about port type
25+
# Debug info about port
2626
port = serial_config.get('port', '')
2727
if self._port_info and self._port_info.vid:
28-
vid = self._port_info.vid
29-
pid = self._port_info.pid
30-
self._log.info(
31-
"Connected to %s [%04X:%04X %s]",
32-
port, vid, pid, self.port_type)
28+
desc = _utils._port_description(self._port_info)
29+
self._log.info("Connected to %s [%s]", port, desc)
3330
else:
3431
self._log.info("Connected to %s [unknown serial port]", port)
3532

mpytool/mpytool.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ def conn(self):
220220
if port:
221221
self._conn = _mpytool.ConnSerial(
222222
port=port, baudrate=self._baudrate, log=self._log)
223-
self._log.verbose(
224-
f"Connected to {port} [{self._conn.port_type}]", level=2)
223+
port_info = _utils.get_port_info(port)
224+
desc = _utils._port_description(port_info) if port_info else "serial"
225+
port_col = self._log.colorize(port, 'yellow')
226+
self._log.verbose(f"Connected to {port_col} {desc}", level=2)
225227
elif self._address:
226228
self._conn = _mpytool.ConnSocket(
227229
address=self._address, log=self._log)
@@ -268,10 +270,11 @@ def colorize(self, text, color):
268270

269271
def _verbose_path(self, cmd, path):
270272
"""Print verbose message for path-based commands (LS, TREE, etc.)"""
273+
# Always get CWD first to ensure connection happens before verbose output
274+
cwd = self.mpy.getcwd()
271275
if path.startswith('/'):
272276
msg = f"{self.colorize(cmd + ':', 'green')} {self.colorize(path, 'cyan')}"
273277
else:
274-
cwd = self.mpy.getcwd()
275278
cwd_colored = self.colorize(cwd, 'yellow')
276279
if path in ('', '.'):
277280
msg = f"{self.colorize(cmd + ':', 'green')} {cwd_colored}"

0 commit comments

Comments
 (0)