def do_input(self, line): """Compiles the input and creates a code image from "line", sends the code image to the target over the connection, prints the return stream. """ codeobj = compile(line, COMPILE_FN, COMPILE_MODE) # DEBUG: Uncomment the next line to print the statement's bytecodes #dis.disco(codeobj) # Convert to a code image pic = pmImgCreator.PmImgCreator() try: codeimg = pic.co_to_str(codeobj) # Print any conversion errors except Exception, e: self.stdout.write("%s:%s\n" % (e.__class__.__name__, e))
def __init__(self, conn, pmfn): cmd.Cmd.__init__(self, ) self.prompt = IPM_PROMPT self.conn = conn self.pic = pmImgCreator.PmImgCreator(pmfn)
def main(): conn, pmfeatures_filename = parse_cmdline() i = Interactive(conn, pmfeatures_filename) i.run() def ser_test(): """Test ipm over serial connection directly. """ try: import serial except Exception, e: print NEED_PYSERIAL raise e pic = pmImgCreator.PmImgCreator("../platform/desktop/pmfeatures.py") serconn = serial.Serial("/dev/cu.SLAB_USBtoUART", 19200) serconn.setTimeout(2) testcode = ( 'print "Hello"\n', 'import sys\n', 'print sys.heap()\n', ) for line in testcode: print "compiling ``%s``" % line codeobj = compile(line, COMPILE_FN, COMPILE_MODE) codeimg = pic.co_to_str(codeobj) print "codeimg is %d bytes" % len(codeimg) print "sending codeimg..."
def main(): conn, pmfeatures_filename = parse_cmdline() i = Interactive(conn, pmfeatures_filename) i.run() def ser_test(): """Test ipm over serial connection directly. """ try: import serial except Exception, e: print NEED_PYSERIAL raise e pic = pmImgCreator.PmImgCreator( os.path.join(PLATFORM_DIR, "desktop/pmfeatures.py")) serconn = serial.Serial("/dev/cu.SLAB_USBtoUART", 19200) serconn.setTimeout(2) testcode = ( 'print "Hello"\n', 'import sys\n', 'print sys.heap()\n', ) for line in testcode: print "compiling ``%s``" % line codeobj = compile(line, COMPILE_FN, COMPILE_MODE) codeimg = pic.co_to_str(codeobj) print "codeimg is %d bytes" % len(codeimg) print "sending codeimg..."
conn.s.setDTR(False) conn.s.setRTS(False) time.sleep(0.1) #i.run() def ser_test(): """Test ipm over serial connection directly. """ try: import serial except Exception, e: print NEED_PYSERIAL raise e pic = pmImgCreator.PmImgCreator() serconn = serial.Serial("/dev/cu.SLAB_USBtoUART", 19200) serconn.setTimeout(2) testcode = ( 'print "Hello"\n', 'import sys\n', 'print sys.heap()\n', ) for line in testcode: print "compiling ``%s``" % line codeobj = compile(line, COMPILE_FN, COMPILE_MODE) codeimg = pic.co_to_str(codeobj) print "codeimg is %d bytes" % len(codeimg) print "sending codeimg..."