Skip to content

Commit

Permalink
Merge pull request #16726 from hugueslarrive/pyterm
Browse files Browse the repository at this point in the history
dist/tools/pyterm: ipv6 address support for tcp_serial option
  • Loading branch information
benpicco authored Aug 14, 2021
2 parents 416a609 + 4f3cb12 commit ce99933
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions dist/tools/pyterm/pyterm
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,20 @@ class SerCmd(cmd.Cmd):
self.port = defaultport
# if a TCP port is specified try to connect
if self.tcp_serial:
if self.tcp_serial.find(':') >= 0:
host = self.tcp_serial.split(':')[0]
port = self.tcp_serial.split(':')[1]
# if this is an ipv6 address
if self.tcp_serial.find(']:') >= 0:
host = self.tcp_serial.split(']:')[0]
host = host.split('[')[1]
port = self.tcp_serial.split(']:')[1]
else:
self.logger.warning("Host name for TCP connection is "
"missing, defaulting to \"localhost\"")
host = "localhost"
port = self.tcp_serial
if self.tcp_serial.find(':') >= 0:
host = self.tcp_serial.split(':')[0]
port = self.tcp_serial.split(':')[1]
else:
self.logger.warning("Host name for TCP connection is "
"missing, defaulting to \"localhost\"")
host = "localhost"
port = self.tcp_serial
self.logger.info("Connect to %s:%s"
% (host, port))
try:
Expand Down

0 comments on commit ce99933

Please sign in to comment.