Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9214e12ee2c9
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: af62ffb52658
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 7, 2020

  1. applet.interface.{i2c_initiator,uart}: remove obsolete repl command.

    These weren't customized, so run-repl is a complete replacement.
    whitequark committed Mar 7, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    costrouc Christopher Ostrouchov
    Copy the full SHA
    8ad33a9 View commit details
  2. cli: flush demultiplexer after each command in run-repl.

    This avoids an absurdly infuriating situation where, if you send
    commands to DUT but do not read anything back, they won't actually
    get delivered until the buffer is full enough, which is often after
    several minutes of frustrated debugging. I think I got bitten by
    this every single time I tried to use run-repl.
    whitequark committed Mar 7, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    costrouc Christopher Ostrouchov
    Copy the full SHA
    af62ffb View commit details
6 changes: 0 additions & 6 deletions software/glasgow/applet/interface/i2c_initiator/__init__.py
Original file line number Diff line number Diff line change
@@ -327,9 +327,6 @@ def add_interact_arguments(cls, parser):
"--device-id", "-i", action="store_true", default=False,
help="read device ID from devices responding to scan")

p_repl = p_operation.add_parser(
"repl", help="drop into Python shell; use `iface` to communicate")

async def interact(self, device, args, i2c_iface):
if args.operation == "scan":
# read/write is the default option
@@ -350,9 +347,6 @@ async def interact(self, device, args, i2c_iface):
self.logger.info("device %s ID: manufacturer %s, part %s, revision %s",
bin(addr), bin(manufacturer), bin(part_ident), bin(revision))

if args.operation == "repl":
await AsyncInteractiveConsole(locals={"iface":i2c_iface}).interact()

# -------------------------------------------------------------------------------------------------

class I2CInitiatorAppletTestCase(GlasgowAppletTestCase, applet=I2CInitiatorApplet):
5 changes: 0 additions & 5 deletions software/glasgow/applet/interface/uart/__init__.py
Original file line number Diff line number Diff line change
@@ -208,9 +208,6 @@ def add_interact_arguments(cls, parser):
"socket", help="connect UART to a socket")
ServerEndpoint.add_argument(p_socket, "endpoint")

p_repl = p_operation.add_parser(
"repl", help="drop into Python shell; use `iface` to communicate")

async def _monitor_errors(self, device):
cur_bit_cyc = await device.read_register(self.__addr_bit_cyc, width=4)
cur_errors = 0
@@ -338,8 +335,6 @@ async def interact(self, device, args, uart):
await self._interact_pty(uart)
if args.operation == "socket":
await self._interact_socket(uart, args.endpoint)
if args.operation == "repl":
await AsyncInteractiveConsole(locals={"iface":uart}).interact()

# -------------------------------------------------------------------------------------------------

3 changes: 2 additions & 1 deletion software/glasgow/cli.py
Original file line number Diff line number Diff line change
@@ -571,7 +571,8 @@ async def run_applet():
logger.warn("applet provides customized REPL(s); consider using `run "
"{} ...-repl` subcommands".format(applet.name))
logger.info("dropping to REPL; use 'help(iface)' to see available APIs")
await AsyncInteractiveConsole(locals={"iface":iface}).interact()
await AsyncInteractiveConsole(locals={"iface":iface},
run_callback=device.demultiplexer.flush).interact()
except GlasgowAppletError as e:
applet.logger.error(str(e))
except asyncio.CancelledError:
10 changes: 8 additions & 2 deletions software/glasgow/support/pyrepl.py
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ class _FutureResult(Exception):


class AsyncInteractiveConsole(code.InteractiveConsole):
def __init__(self, *args, **kwargs):
def __init__(self, *args, run_callback=None, **kwargs):
super().__init__(*args, **kwargs)

if readline is not None:
@@ -32,6 +32,7 @@ def __init__(self, *args, **kwargs):
readline.set_completer(completer.complete)

self.locals["__name__"] = __name__.split(".")[0]
self.run_callback = run_callback
self._future = None

def save_history(self):
@@ -44,7 +45,12 @@ def runcode(self, code):
exec(code, self.locals)
if hasattr(builtins, "_"):
if asyncio.iscoroutine(builtins._):
self._future = asyncio.ensure_future(builtins._)
async def run_and_wait():
result = await builtins._
if self.run_callback is not None:
await self.run_callback()
return result
self._future = asyncio.ensure_future(run_and_wait())
except SystemExit:
raise
except: