Browse Source

Add send_cr option to translate LF to CR on output

master
Jim Paris 7 years ago
parent
commit
44f431db13
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      terminal.py

+ 7
- 0
terminal.py View File

@@ -130,6 +130,7 @@ class Jimterm:
suppress_read_firstnull = True, suppress_read_firstnull = True,
transmit_all = False, transmit_all = False,
add_cr = False, add_cr = False,
send_cr = False,
raw = True, raw = True,
color = True, color = True,
bufsize = 65536): bufsize = 65536):
@@ -145,6 +146,7 @@ class Jimterm:
self.threads = [] self.threads = []
self.transmit_all = transmit_all self.transmit_all = transmit_all
self.add_cr = add_cr self.add_cr = add_cr
self.send_cr = send_cr
self.raw = raw self.raw = raw
self.bufsize = bufsize self.bufsize = bufsize
self.quote_re = None self.quote_re = None
@@ -277,6 +279,8 @@ class Jimterm:
if self.suppress_write_bytes is not None: if self.suppress_write_bytes is not None:
c = c.translate(None, self.suppress_write_bytes) c = c.translate(None, self.suppress_write_bytes)


if self.send_cr and c == '\n':
c = '\r'
# Send character # Send character
if self.transmit_all: if self.transmit_all:
for serial in self.serials: for serial in self.serials:
@@ -343,6 +347,8 @@ if __name__ == "__main__":
help="Default baudrate for all devices", default=115200) help="Default baudrate for all devices", default=115200)
parser.add_argument("--crlf", "-c", action="store_true", parser.add_argument("--crlf", "-c", action="store_true",
help="Add CR before incoming LF") help="Add CR before incoming LF")
parser.add_argument("--lfcr", "-C", action="store_true",
help="Send CR instead of LF on output",
parser.add_argument("--all", "-a", action="store_true", parser.add_argument("--all", "-a", action="store_true",
help="Send keystrokes to all devices, not just " help="Send keystrokes to all devices, not just "
"the first one") "the first one")
@@ -394,6 +400,7 @@ if __name__ == "__main__":
term = Jimterm(devs, term = Jimterm(devs,
transmit_all = args.all, transmit_all = args.all,
add_cr = args.crlf, add_cr = args.crlf,
send_cr = args.lfcr,
raw = raw, raw = raw,
color = (os.name == "posix" and not args.mono), color = (os.name == "posix" and not args.mono),
bufsize = args.bufsize) bufsize = args.bufsize)


Loading…
Cancel
Save