mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pyterm: label pyterm arg for native generically
This commit is contained in:
parent
273486be78
commit
075f2ffd6a
@ -17,14 +17,14 @@ FLASHFILE ?= $(ELFFILE)
|
||||
ifeq (native,$(RIOT_TERMINAL))
|
||||
TERMPROG ?= $(FLASHFILE)
|
||||
else
|
||||
TERMFLAGS += -n $(FLASHFILE)
|
||||
TERMFLAGS += -ps $(FLASHFILE)
|
||||
ifeq (1,$(USE_ZEP))
|
||||
ZEP_IP ?= [::1]
|
||||
ZEP_PORT_BASE ?= 17754
|
||||
TERMFLAGS += --native-args '-z $(ZEP_IP):$(ZEP_PORT_BASE)'
|
||||
TERMFLAGS += --process-args '-z $(ZEP_IP):$(ZEP_PORT_BASE)'
|
||||
endif
|
||||
ifneq (,$(ZEP_MAC))
|
||||
TERMFLAGS += --native-args '\-\-eui64=$(ZEP_MAC)'
|
||||
TERMFLAGS += --process-args '\-\-eui64=$(ZEP_MAC)'
|
||||
endif
|
||||
endif
|
||||
|
||||
|
56
dist/tools/pyterm/pyterm
vendored
56
dist/tools/pyterm/pyterm
vendored
@ -110,8 +110,8 @@ class SerCmd(cmd.Cmd):
|
||||
"""
|
||||
|
||||
def __init__(self, port=None, baudrate=None, toggle=None,
|
||||
tcp_serial=None, native=None, native_args=None,
|
||||
native_tap=None, confdir=None, conffile=None, host=None,
|
||||
tcp_serial=None, process=None, process_args=None,
|
||||
process_tap=None, confdir=None, conffile=None, host=None,
|
||||
run_name=None, log_dir_name=None, newline=None,
|
||||
formatter=None, set_rts=None, set_dtr=None, serprompt=None,
|
||||
repeat_command_on_empty_line=defaultrepeat_cmd_empty_line,
|
||||
@ -121,10 +121,10 @@ class SerCmd(cmd.Cmd):
|
||||
Args:
|
||||
port (str): serial port
|
||||
baudrate (int): serial baudrate
|
||||
tcp_serial (iht): TCP port to connect to (alternatively)
|
||||
native (str): Native instance to run and connect to
|
||||
native_args (str): Optional arguments for Native
|
||||
native_tap (str): TAP interface to pass to native
|
||||
tcp_serial (iht): TCP port to connect to (alterprocessly)
|
||||
process (str): Program to run as subprocess and connect to its I/O
|
||||
process_args (str): Optional arguments for the subprocess
|
||||
process_tap (str): TAP interface to pass to process
|
||||
confdir (str): configuration directory
|
||||
conffile (str): configuration file name
|
||||
host (str): local host name
|
||||
@ -140,15 +140,15 @@ class SerCmd(cmd.Cmd):
|
||||
self.set_rts = set_rts
|
||||
self.set_dtr = set_dtr
|
||||
self.tcp_serial = tcp_serial
|
||||
self.native = native
|
||||
self.native_args = []
|
||||
if native_args:
|
||||
for arg in native_args:
|
||||
self.process = process
|
||||
self.process_args = []
|
||||
if process_args:
|
||||
for arg in process_args:
|
||||
for elem in arg:
|
||||
for substr in elem.split(' '):
|
||||
substr = substr.replace('\\-\\-', '--')
|
||||
self.native_args.append(substr)
|
||||
self.native_tap = native_tap
|
||||
self.process_args.append(substr)
|
||||
self.process_tap = process_tap
|
||||
self.configdir = confdir
|
||||
self.configfile = conffile
|
||||
self.host = host
|
||||
@ -219,8 +219,8 @@ class SerCmd(cmd.Cmd):
|
||||
"""Executed bat program start.
|
||||
"""
|
||||
|
||||
if self.native and (self.port != defaultport or self.tcp_serial):
|
||||
self.logger.error("Specified a native instance AND a serial "
|
||||
if self.process and (self.port != defaultport or self.tcp_serial):
|
||||
self.logger.error("Specified a process instance AND a serial "
|
||||
"port or TCP connection. You probably want "
|
||||
"to specify only the one or the other.")
|
||||
sys.exit(1)
|
||||
@ -273,10 +273,10 @@ class SerCmd(cmd.Cmd):
|
||||
self.logger.error("Something went wrong connecting to "
|
||||
"localhost:%s" % self.tcp_serial)
|
||||
sys.exit(1)
|
||||
elif self.native:
|
||||
native_call = [self.native] + self.native_tap + self.native_args
|
||||
self.logger.debug("Executing native as %s", str(native_call))
|
||||
self.ser = Popen(native_call, stdout=PIPE, stdin=PIPE, stderr=PIPE)
|
||||
elif self.process:
|
||||
process_call = [self.process] + self.process_tap + self.process_args
|
||||
self.logger.debug("Executing process as %s", str(process_call))
|
||||
self.ser = Popen(process_call, stdout=PIPE, stdin=PIPE, stderr=PIPE)
|
||||
# otherwise go for the serial port
|
||||
elif self.port:
|
||||
connected = False
|
||||
@ -692,7 +692,7 @@ class SerCmd(cmd.Cmd):
|
||||
|
||||
def _read_char(self):
|
||||
output_stream = self.ser
|
||||
if self.native:
|
||||
if self.process:
|
||||
output_stream = self.ser.stdout
|
||||
# check if serial port can be accessed.
|
||||
sr = codecs.getreader("UTF-8")(output_stream,
|
||||
@ -701,10 +701,10 @@ class SerCmd(cmd.Cmd):
|
||||
|
||||
def _write_char(self, output):
|
||||
input_stream = self.ser
|
||||
if self.native:
|
||||
if self.process:
|
||||
input_stream = self.ser.stdin
|
||||
input_stream.write(output)
|
||||
if self.native:
|
||||
if self.process:
|
||||
input_stream.flush()
|
||||
|
||||
def _handle_serial_exception(self):
|
||||
@ -849,11 +849,11 @@ if __name__ == "__main__":
|
||||
help="Connect to a TCP port instead of a serial port. "
|
||||
"Format is <hostname>:<port>. If the colon is missing"
|
||||
" host defaults to \"localhost\"")
|
||||
parser.add_argument("-n", "--native",
|
||||
help="Start a RIOT native instance and connect "
|
||||
"pyterm to its stdio.")
|
||||
parser.add_argument("-na", "--native-args",
|
||||
help="Adding optional arguments to RIOT native",
|
||||
parser.add_argument("-ps", "--process",
|
||||
help="Start a subprocess and connect pyterm to its "
|
||||
"stdio.")
|
||||
parser.add_argument("-pa", "--process-args",
|
||||
help="Adding optional arguments to subprocess",
|
||||
action="append", nargs='*')
|
||||
parser.add_argument("-b", "--baudrate",
|
||||
help="Specifies baudrate for the serial port, default "
|
||||
@ -931,7 +931,7 @@ if __name__ == "__main__":
|
||||
action="store_false",
|
||||
help="Do not try to reconnect when failing on "
|
||||
"connection setup (Default)")
|
||||
parser.add_argument("native_tap", nargs='*')
|
||||
parser.add_argument("process_tap", nargs='*')
|
||||
|
||||
parser.set_defaults(
|
||||
repeat_command_on_empty_line=defaultrepeat_cmd_empty_line,
|
||||
@ -942,7 +942,7 @@ if __name__ == "__main__":
|
||||
if args.noprefix:
|
||||
args.format = ""
|
||||
myshell = SerCmd(args.port, args.baudrate, args.toggle, args.tcp_serial,
|
||||
args.native, args.native_args, args.native_tap,
|
||||
args.process, args.process_args, args.process_tap,
|
||||
args.directory, args.config, args.host, args.run_name,
|
||||
args.log_dir_name, args.newline, args.format,
|
||||
args.set_rts, args.set_dtr, args.prompt,
|
||||
|
Loading…
Reference in New Issue
Block a user