[Tinyos-commits] CVS: tinyos-1.x/tools/python/apps Listen.py, NONE,
1.1
Kamin Whitehouse
kaminw at users.sourceforge.net
Wed Sep 28 00:01:23 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/tools/python/apps
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15271/apps
Added Files:
Listen.py
Log Message:
Listen.py is a new tool that pretty prints all incoming packets, even in they come in over a routing layer such as Drain. MessageSnooper is a library that should know about all routing layers. It uses introspection to see which routing layers are compiled into the application and registers for all packet types for all routing layers
--- NEW FILE: Listen.py ---
#!/usr/bin/python
#$Id: Listen.py,v 1.1 2005/09/28 07:01:20 kaminw Exp $
# "Copyright (c) 2000-2003 The Regents of the University of California.
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose, without fee, and without written agreement
# is hereby granted, provided that the above copyright notice, the following
# two paragraphs and the author appear in all copies of this software.
#
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
# OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
# OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
# ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
#
# @author Kamin Whitehouse
#
import sys, threading
import pytos.util.NescApp as NescApp
import pytos.util.ParseArgs as ParseArgs
import pytos.util.MessageSnooper as MessageSnooper
import pytos.Comm as Comm
class Listen( object ) :
"""This application prints incoming packets to the screen. Unlike
other versions of listen, this one automatically parses the byte
stream. The format of the output can be modified by typing letters
while the data is flowing by (similar to 'top'). For a help, type
the letter 'h'. Some of the current commands are:
h: toggle help
q: quit
c: toggle colors
usage:
Listen.py telosb sf at localhost:9001
"""
def __init__( self , snooper ) :
msgQueue = Comm.MessageQueue(1)
self.snooper = snooper
self.snooper.register( msgQueue )
self.running = True
# #start a thread to process the messages (make daemon so it dies when tk is killed)
# msgThread = threading.Thread(target=self.processMessages,
# args=(msgQueue,))
# #msgThread.setDaemon(True)
# msgThread.start()
# def processMessages(self, msgQueue) :
while True :
(addr,msg) = msgQueue.get()
if self.running == True:
print msg
def stop(self) :
self.running = False
def start(self) :
self.running = True
if __name__ == "__main__":
args = ParseArgs.ParseArgs(sys.argv)
app = NescApp.NescApp(args.buildDir, args.motecom, tosbase=True, localCommOnly=True)
snooper = MessageSnooper.MessageSnooper(app)
listen = Listen(snooper)
More information about the Tinyos-commits
mailing list