def main(): """ The function that actually runs the REPL. """ port = find_microbit() print('port', port) if not port: sys.stderr.write('Could not find micro:bit. Is it plugged in?\n') sys.exit(0) serial.tools.miniterm.EXITCHARCTER = character(b'\x1d') miniterm = connect_miniterm(port) # Emit some helpful information about the program and MicroPython. shortcut_message = 'Quit: {} | Stop program: Ctrl+C | Reset: Ctrl+D\n' help_message = 'Type \'help()\' (without the quotes) then press ENTER.\n' exit_char = key_description(serial.tools.miniterm.EXITCHARCTER) sys.stderr.write(shortcut_message.format(exit_char)) sys.stderr.write(help_message) # Start everything. console.setup() miniterm.start() miniterm.serial.write(b'\x03') # Connecting stops the running program. try: miniterm.join(True) except KeyboardInterrupt: pass sys.stderr.write('\nEXIT - see you soon... :-)\n')
def terminal(self): miniterm = MyMiniterm(self._port) log.info('Started terminal. Hit ctrl-] to leave terminal') console.setup() miniterm.start() try: miniterm.join(True) except KeyboardInterrupt: pass miniterm.join()
def main(): """ The function that actually runs the REPL. """ port = find_microbit() if not port: sys.stderr.write('Could not find micro:bit. Is it plugged in?\n') sys.exit(0) serial.tools.miniterm.EXITCHARCTER = character(b'\x1d') try: miniterm = Miniterm( port, BAUDRATE, PARITY, rtscts=False, xonxoff=False, echo=False, convert_outgoing=2, repr_mode=0, ) except serial.SerialException as e: if e.errno == 16: # Device is busy. Explain what to do. sys.stderr.write("Found micro:bit, but the device is busy. " + "Wait up to 20 seconds, or " + "press the reset button on the " + "back of the device next to the yellow light; " + "then try again.\n") else: # Try to be as helpful as possible. sys.stderr.write("Found micro:bit, but could not connect via" + " port %r: %s\n" % (port, e)) sys.stderr.write("I'm not sure what to suggest. :-(\n") sys.exit(1) # Emit some helpful information about the program and MicroPython. shortcut_message = 'Quit: {} | Stop program: Ctrl+C | Reset: Ctrl+D\n' help_message = 'Type \'help()\' (without the quotes) then press ENTER.\n' exit_char = key_description(serial.tools.miniterm.EXITCHARCTER) sys.stderr.write(shortcut_message.format(exit_char)) sys.stderr.write(help_message) # Start everything. console.setup() miniterm.start() miniterm.serial.write(b'\x03') # Connecting stops the running program. try: miniterm.join(True) except KeyboardInterrupt: pass sys.stderr.write('\nEXIT - see you soon... :-)\n')
def terminal(self): if not MINITERM_AVAILABLE: print "Miniterm is not available on this system" return miniterm = MyMiniterm(self._port) log.info('Started terminal. Hit ctrl-] to leave terminal') console.setup() miniterm.start() try: miniterm.join(True) except KeyboardInterrupt: pass miniterm.join()
def terminal(port=default_port()): if not MINITERM_AVAILABLE: print "Miniterm is not available on this system" return False sp = serial.Serial(port, 9600) # Keeps things working, if following conections are made: ## RTS = CH_PD (i.e reset) ## DTR = GPIO0 sp.setRTS(False) sp.setDTR(False) miniterm = McuMiniterm(sp) log.info('Started terminal. Hit ctrl-] to leave terminal') console.setup() miniterm.start() try: miniterm.join(True) except KeyboardInterrupt: pass miniterm.join() sp.close()