GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-xbee/scripts/shell.py at master · desnotes/python-xbee Expand file tree/ Copy pathshell.pyMore file actions executable file ·71 lines (59 loc) · 1.61 KB / Copy pathshell.pyFile metadata and controlsexecutable file ·71 lines (59 loc) · 1.61 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 #!/usr/bin/env python """ shell.py Amit Snyderman, 2009 Updated by Paul Malmsten, 2010 Provides a simple shell for testing XBee devices. Currently, the shell only allows one to parse and print received data; sending is not supported. """ # $Id: xbee-serial-terminal.py 7 2009-12-30 16:25:08Z amitsnyderman $ import sys, time, cmd, serial, binascii from xbee import XBee1 class XBeeShell(cmd.Cmd): def __init__(self): cmd.Cmd.__init__(self) self.prompt = "xbee% " self.serial = serial.Serial() def default(self, p): if not self.serial.isOpen(): print "You must set a serial port first." else: if p == '+++': self.serial.write(p) time.sleep(2) else: self.serial.write('%s\r' % p) time.sleep(0.5) output = '' while self.serial.inWaiting(): output += self.serial.read() print output.replace('\r', '\n').rstrip() def do_serial(self, p): """Set the serial port, e.g.: /dev/tty.usbserial-A4001ib8""" try: self.serial.port = p self.serial.open() print 'Opening serial port: %s' % p except Exception, e: print 'Unable to open serial port: %s' % p def do_baudrate(self, p): """Set the serial port's baud rate, e.g.: 19200""" self.serial.baudrate = p def do_watch(self, p): if not self.serial.isOpen(): print "You must set a serial port first." else: while 1: xbee = XBee1(self.serial) packet = xbee.wait_read_frame() print packet def do_exit(self, p): """Exits from the XBee serial console""" self.serial.close() return 1 if __name__ == '__main__': shell = XBeeShell() shell.cmdloop() |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |