From 8be1278183976e7094dd1103da969188da315845 Mon Sep 17 00:00:00 2001 From: cliechti Date: Thu, 12 Apr 2012 16:47:47 +0000 Subject: - miniterm now asks for the port if none is given (instead of opening '0') - update py2exe scripts (ensure own module is taken not the one in site-packages) git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@452 f19166aa-fa4f-0410-85c2-fa1106f25c8a --- serial/tools/miniterm.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'serial') diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py index fdf4d8e..626c5aa 100644 --- a/serial/tools/miniterm.py +++ b/serial/tools/miniterm.py @@ -141,6 +141,14 @@ else: raise NotImplementedError("Sorry no implementation for your platform (%s) available." % sys.platform) +def dump_port_list(): + if comports: + sys.stderr.write('\n--- Available ports:\n') + for port, desc, hwid in sorted(comports()): + #~ sys.stderr.write('--- %-20s %s [%s]\n' % (port, desc, hwid)) + sys.stderr.write('--- %-20s %s\n' % (port, desc)) + + CONVERT_CRLF = 2 CONVERT_CR = 1 CONVERT_LF = 0 @@ -222,13 +230,6 @@ class Miniterm(object): REPR_MODES[self.repr_mode], LF_MODES[self.convert_outgoing])) - def dump_port_list(self): - if comports: - sys.stderr.write('\n--- Available ports:\n') - for port, desc, hwid in sorted(comports()): - #~ sys.stderr.write('--- %-20s %s [%s]\n' % (port, desc, hwid)) - sys.stderr.write('--- %-20s %s\n' % (port, desc)) - def reader(self): """loop and copy serial->console""" try: @@ -345,7 +346,7 @@ class Miniterm(object): LF_MODES[self.convert_outgoing], )) elif c in 'pP': # P -> change port - self.dump_port_list() + dump_port_list() sys.stderr.write('--- Enter port name: ') sys.stderr.flush() console.cleanup() @@ -599,7 +600,9 @@ def main(): if args: parser.error("too many arguments") else: - if port is None: port = 0 + if port is None: + dump_port_list() + port = raw_input('Enter port name:') convert_outgoing = CONVERT_CRLF if options.cr: -- cgit v1.2.1