コード例 #1
0
    def __init__(self, app=""):

        self.app = app
        self.listeners = []

        msgQueue = Comm.MessageQueue(10)

        #register the msgQueue for all message types with localComm
        comm = Comm.getCommObject(self.app, self.app.motecom)
        registerAllMsgs(self.app.msgs, msgQueue, comm)

        #register the msgQueue for all message types with drain and unregister DrainMsg with localComm
        if "AM_DRAINMSG" in self.app.enums._enums:
            drains = Drain.getDrainObject(self.app)
            for drain in drains:
                registerAllMsgs(self.app.msgs, msgQueue, drain)
            comm.unregister(self.app.msgs.DrainMsg, msgQueue)

        #if rpc is imported
        if self.app.__dict__.has_key("rpc"):
            #make sure a drip object exists for snooping on cmds
            drips = Drip.getDripObject(self.app, self.app.motecom,
                                       self.app.enums.AM_RPCCOMMANDMSG)
            #register the msgQueue for all rpc response messages
            for command in self.app.rpc._messages.values():
                command.register(msgQueue)
            #and unregister RpcResponseMsg from drain
            drains = Drain.getDrainObject(self.app, self.app.motecom,
                                          0xfffe)  #ugh... hard coded number
            for drain in drains:
                drain.unregister(app.msgs.RpcResponseMsg, msgQueue)
            #if ram symbols is imported
            if self.app.__dict__.has_key("ramSymbols"):
                #register the msgQueue for all ram symbol response messages
                for symbol in self.app.ramSymbols._messages.values():
                    symbol.registerPeek(msgQueue)
                    symbol.registerPoke(msgQueue)
                #and unregister from peek/poke rpc commands
                self.app.RamSymbolsM.peek.unregister(msgQueue)
                self.app.RamSymbolsM.poke.unregister(msgQueue)

        #register the msgQueue for all message types with drip and unregister DripMsg with localComm
        if "AM_DRIPMSG" in self.app.enums._enums:
            drips = Drip.getDripObject(self.app)
            for drip in drips:
                print "actually dtrying to register dripmsgs\n"
                registerAllMsgs(self.app.msgs, msgQueue, drip)
            comm.unregister(self.app.msgs.DripMsg, msgQueue)

        self.running = True
        msgThread = threading.Thread(target=self.processMessages,
                                     args=(msgQueue, ))
        msgThread.setDaemon(True)
        msgThread.start()
コード例 #2
0
ファイル: MessageSnooper.py プロジェクト: iplusu/sarp
  def __init__( self , app="" ) :

    self.app = app
    self.listeners = []

    msgQueue = Comm.MessageQueue(10)
        
    #register the msgQueue for all message types with localComm
    comm = Comm.getCommObject(self.app, self.app.motecom)
    registerAllMsgs(self.app.msgs, msgQueue, comm)

    #register the msgQueue for all message types with drain and unregister DrainMsg with localComm
    if "AM_DRAINMSG" in self.app.enums._enums :
      drains = Drain.getDrainObject(self.app)
      for drain in drains:
        registerAllMsgs(self.app.msgs, msgQueue, drain)
      comm.unregister(self.app.msgs.DrainMsg, msgQueue)

    #if rpc is imported
    if self.app.__dict__.has_key("rpc") :
      #make sure a drip object exists for snooping on cmds
      drips = Drip.getDripObject(self.app, self.app.motecom, self.app.enums.AM_RPCCOMMANDMSG)
      #register the msgQueue for all rpc response messages
      for command in self.app.rpc._messages.values() :
        command.register(msgQueue)
      #and unregister RpcResponseMsg from drain
      drains = Drain.getDrainObject(self.app, self.app.motecom, 0xfffe) #ugh... hard coded number
      for drain in drains:
        drain.unregister(app.msgs.RpcResponseMsg, msgQueue)
      #if ram symbols is imported
      if self.app.__dict__.has_key("ramSymbols") :
        #register the msgQueue for all ram symbol response messages
        for symbol in self.app.ramSymbols._messages.values() :
          symbol.registerPeek(msgQueue)
          symbol.registerPoke(msgQueue)
        #and unregister from peek/poke rpc commands
        self.app.RamSymbolsM.peek.unregister(msgQueue)
        self.app.RamSymbolsM.poke.unregister(msgQueue)

    #register the msgQueue for all message types with drip and unregister DripMsg with localComm
    if "AM_DRIPMSG" in self.app.enums._enums :
      drips = Drip.getDripObject(self.app)
      for drip in drips:
        print "actually dtrying to register dripmsgs\n"
        registerAllMsgs(self.app.msgs, msgQueue, drip)
      comm.unregister(self.app.msgs.DripMsg, msgQueue)

    self.running = True
    msgThread = threading.Thread(target=self.processMessages,
                                 args=(msgQueue,))
    msgThread.setDaemon(True)
    msgThread.start()
コード例 #3
0
ファイル: RoutingMessages.py プロジェクト: iplusu/sarp
  def __init__(self, app) :

    self.app = app
    self._messages = {}

    ## In this constructor, we connect to the routing layer as best as
    ## we can.  This may mean creating new drip/drain instances,
    ## reusing old ones, reusing old Comm objects, or not connecting
    ## at all, depending...

    if app.motecom == None:
      return

    #connect to sendComm: use localComm if user requested or if drip not compiled in.
    self.address=app.enums.TOS_BCAST_ADDR
    if app.localCommOnly==True or "AM_DRIPMSG" not in app.enums._enums:
      self.sendComm = Comm.getCommObject(app, app.motecom)
    else :
      self.sendComm = Drip.getDripObject(app, app.motecom, app.enums.AM_RPCCOMMANDMSG)[0]

    #connect to receiveComm: always use Drain unless not compiled in
    if "AM_DRAINMSG" not in app.enums._enums:
      self.receiveComm = Comm.getCommObject(app, app.motecom)
      self.returnAddress = app.enums.TOS_BCAST_ADDR
    else :
      treeID = 0xfffe                                        #can we set this automatically?
      self.receiveComm = Drain.getDrainObject(app, app.motecom, treeID)[0]
      if app.localCommOnly == False :
        self.receiveComm.maintainTree()
      if app.tosbase==True:                                  #can we discover this like deluge?
        self.returnAddress = treeID
      else :
        self.returnAddress = app.enums.TOS_UART_ADDR