Skip to content

Commit

Permalink
[tools] Fix telnetlib for Python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
andryblack authored and salkinium committed Dec 15, 2024
1 parent 638423f commit 43d088d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions tools/modm_tools/jlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import time
import signal
import platform
import telnetlib
import subprocess

from . import gdb
Expand Down Expand Up @@ -99,10 +98,15 @@ def itm(device, baudrate=None):


def rtt(backend, channel=0):
try:
import telnetlib3
except ImportError:
print("Please upgrade modm: pip3 install -U modm")
import telnetlib as telnetlib3
# Start JLinkGDBServer in the background
with backend.scope():
time.sleep(0.5)
with telnetlib.Telnet("localhost", 19021) as tn:
with telnetlib3.Telnet("localhost", 19021) as tn:
try:
tn.interact()
except KeyboardInterrupt:
Expand Down
8 changes: 6 additions & 2 deletions tools/modm_tools/openocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import signal
import tempfile
import platform
import telnetlib
import subprocess

from . import utils
Expand Down Expand Up @@ -126,11 +125,16 @@ def itm(backend, fcpu, baudrate=None):
pass

def rtt(backend, channel=0):
try:
import telnetlib3
except ImportError:
print("Please upgrade modm: pip3 install -U modm")
import telnetlib as telnetlib3
backend.commands.append("modm_rtt")
# Start OpenOCD in the background
with backend.scope():
time.sleep(0.5)
with telnetlib.Telnet("localhost", 9090+channel) as tn:
with telnetlib3.Telnet("localhost", 9090+channel) as tn:
try:
tn.interact()
except KeyboardInterrupt:
Expand Down

0 comments on commit 43d088d

Please sign in to comment.