Example #1
0
You can script the device's SCSI interface too:

    sc c ac              # Backdoor signature
    sc 8 ff 00 ff        # Undocumented firmware version
    ALSO: reset, eject, sc_sense, sc_read, scsi_in, scsi_out

Happy hacking!    -- Type 'thing?' for help on 'thing' or
~MeS`14              '?' for IPython, '%h' for this again.
"""

from IPython.terminal.embed import InteractiveShellEmbed
from shell_magics import ShellMagics
from remote import Device
import shell_namespace

# Make a global device, but only give it to the user namespace.
# Make it default by assigning it to 'd', our current device.
shell_namespace.d = shell_namespace.d_remote = Device()

# Make a shell that feels like a debugger
ipy = InteractiveShellEmbed(user_ns = shell_namespace.__dict__)
shell_namespace.ipy = ipy
ipy.register_magics(ShellMagics)
ipy.register_magic_function(lambda _: ipy.write(__doc__), magic_name='h')
ipy.alias_manager.define_alias('git', 'git')
ipy.alias_manager.define_alias('make', 'make')

# Hello, tiny world
ipy.mainloop(display_banner = __doc__)
Example #2
0
from shell_magics import ShellMagics
from remote import Device
import shell_namespace
import sys

messages = ''
user_ns = dict(shell_namespace.__dict__)

# Make a global device, but only give it to the user namespace.
# Make it default by assigning it to 'd', our current device.
try:
    user_ns['d'] = user_ns['d_remote'] = Device()
except IOError as e:
    messages += "\n-------- There is NO DEVICE available! --------\n"
    messages += "\n%s\n\n" % e
    messages += "--> Try again to attach via USB:   %reset\n"
    messages += "--> Reattach over bitbang serial:  %bitbang -a /dev/tty.usb<tab>\n"
    user_ns['d'] = user_ns['d_remote'] = None

# Make a shell that feels like a debugger
ipy = InteractiveShellEmbed(user_ns=user_ns)
user_ns['ipy'] = ipy
ipy.register_magics(ShellMagics)
ipy.register_magic_function(lambda _: ipy.write(__doc__), magic_name='h')
ipy.alias_manager.define_alias('git', 'git')
ipy.alias_manager.define_alias('make', 'make')

# Hello, tiny world
sys.stdout.write(__doc__ + messages)
ipy.mainloop()