summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2013-10-13 21:36:49 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2013-10-13 21:36:49 +0000
commitee1416ce5fea5292e90f13a69a6958816f29eb02 (patch)
tree90808ae61830e10ce7292c8cefc9c2a2db42088a
parent2e2526ecf130de5fe754f8f65c0513663b389a44 (diff)
downloadpyserial-ee1416ce5fea5292e90f13a69a6958816f29eb02.tar.gz
fixes for python 3 compatibility
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@475 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-rw-r--r--serial/tools/miniterm.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/serial/tools/miniterm.py b/serial/tools/miniterm.py
index 6d27ba6..274c7fb 100644
--- a/serial/tools/miniterm.py
+++ b/serial/tools/miniterm.py
@@ -14,8 +14,8 @@ try:
except ImportError:
comports = None
-EXITCHARCTER = '\x1d' # GS/CTRL+]
-MENUCHARACTER = '\x14' # Menu: CTRL+T
+EXITCHARCTER = serial.to_bytes([0x1d]) # GS/CTRL+]
+MENUCHARACTER = serial.to_bytes([0x14]) # Menu: CTRL+T
DEFAULT_PORT = None
DEFAULT_BAUDRATE = 9600
@@ -81,6 +81,13 @@ else:
def character(b):
return b
+LF = serial.to_bytes([10])
+CR = serial.to_bytes([13])
+CRLF = serial.to_bytes([13, 10])
+
+X00 = serial.to_bytes([0])
+X0E = serial.to_bytes([0x0e])
+
# first choose a platform dependant way to read single characters from the console
global console
@@ -99,11 +106,11 @@ if os.name == 'nt':
def getkey(self):
while True:
z = msvcrt.getch()
- if z == '\0' or z == '\xe0': # functions keys, ignore
+ if z == X00 or z == X0E: # functions keys, ignore
msvcrt.getch()
else:
- if z == '\r':
- return '\n'
+ if z == CR:
+ return LF
return z
console = Console()
@@ -153,7 +160,7 @@ def dump_port_list():
CONVERT_CRLF = 2
CONVERT_CR = 1
CONVERT_LF = 0
-NEWLINE_CONVERISON_MAP = ('\n', '\r', '\r\n')
+NEWLINE_CONVERISON_MAP = (LF, CR, CRLF)
LF_MODES = ('LF', 'CR', 'CR/LF')
REPR_MODES = ('raw', 'some control', 'all control', 'hex')