Skip to content

Commit

Permalink
Update create2.py
Browse files Browse the repository at this point in the history
 Enabled history in the REPL python console.
  • Loading branch information
danimaciasperea authored Aug 9, 2018
1 parent 0b9c516 commit fd5a6de
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions irobot/console_interfaces/create2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def check_for_quirks(robot):

print('Checking firmware for quirks')
print('Restarting Robot...')

boot_message = robot.firmware_version.split(u'\r\n')

for line in boot_message:
if match(FIRMWARE_PREFIX, line):
print('Found firmware:', line)
Expand Down Expand Up @@ -64,16 +64,33 @@ def format(self, record):

def main():
import code

import atexit
import os
import readline
import rlcompleter

historyPath = os.path.expanduser("~/.pyhistory")

def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)

if os.path.exists(historyPath):
readline.read_history_file(historyPath)

atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath

print('Launching REPL')
port = input('Serial Port> ')
brc_pin = int(input('BRC Pin> '))
print()

# give the user a way out before we launch into interactive mode
if port.lower() == 'quit()':
return
try:
robot = Create2(port)
robot = Create2(port,brc_pin)
except RobotConnectionError as e:
print(e, '\nInner Exception:', e.__cause__)
return
Expand Down

0 comments on commit fd5a6de

Please sign in to comment.