Skip to content

Commit

Permalink
Add echo capability
Browse files Browse the repository at this point in the history
This adds the --echo parameter, which starts up an infinite loop,
printing the output of the MCU to stdout. This is useful when not
wanting to run a separate terminal to observe the MCU output.
  • Loading branch information
jonte committed Dec 12, 2015
1 parent 27f6efc commit b053bea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions luatool/luatool.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def decidetransport(cliargs):
parser.add_argument('-l', '--list', action='store_true', help='List files on device')
parser.add_argument('-w', '--wipe', action='store_true', help='Delete all lua/lc files on device.')
parser.add_argument('-i', '--id', action='store_true', help='Query the modules chip id.')
parser.add_argument('-e', '--echo', action='store_true', help='Echo output of MCU until script is terminated.')
parser.add_argument('--delete', default=None, help='Delete a lua/lc file from device.')
parser.add_argument('--ip', default=None, help='Connect to a telnet server on the device (--ip IP[:port])')
args = parser.parse_args()
Expand Down Expand Up @@ -304,6 +305,12 @@ def decidetransport(cliargs):
if args.dofile: # never exec if restart=1
transport.writeln("dofile(\"" + args.dest + "\")\r", 0)

if args.echo:
if args.verbose:
sys.stderr.write("\r\nEchoing MCU output, press Ctrl-C to exit")
while True:
sys.stdout.write(transport.read(1))

# close serial port
transport.close()

Expand Down

0 comments on commit b053bea

Please sign in to comment.