Example #1
0
 def searchTimeout(self, timeout):
     if (timeout > 0xFF) or (timeout < 0x00):
         raise ChannelError('%s: search timeout must be between 0 and 255, was %s', (self, timeout))
     msg = message.ChannelSearchTimeoutMessage(self.number, timeout)
     response = self.node.evm.writeMessage(msg).waitForAck(msg)
     if response != RESPONSE_NO_ERROR:
         raise ChannelError('%s: could not set search timeout (%.2x).' % (str(self), response) )
     self._searchTimeout = timeout
Example #2
0
 def setID(self, devType, devNum, transType):
     msg = message.ChannelIDMessage(self.number, devNum, devType, transType)
     response = self.node.evm.writeMessage(msg).waitForAck(msg)
     if response != RESPONSE_NO_ERROR:
         raise ChannelError('%s: could not set ID (%.2x).' %
                            (str(self), response))
     self.id = ChannelID(devNum, devType, transType)
Example #3
0
 def assign(self, network, channelType):
     msg = message.ChannelAssignMessage(self.number, channelType, network.number)
     response = self.node.evm.writeMessage(msg).waitForAck(msg)
     if response != RESPONSE_NO_ERROR:
         raise ChannelError('%s: could not assign (%.2x).' % (str(self), response))
     self.type = channelType
     self.network = network
Example #4
0
 def unassign(self):
     msg = message.ChannelUnassignMessage(number=self.number)
     response = self.node.evm.writeMessage(msg).waitForAck(msg)
     if response != RESPONSE_NO_ERROR:
         raise ChannelError('%s: could not unassign (0x%.2x).' %
                            (str(self), response))
     self.network = None
Example #5
0
 def frequency(self, frequency):
     msg = message.ChannelFrequencyMessage(self.number, frequency)
     response = self.node.evm.writeMessage(msg).waitForAck(msg)
     if response != RESPONSE_NO_ERROR:
         raise ChannelError('%s, could not set frequency (%.2x).' %
                            (str(self), response))
     self._frequency = frequency
Example #6
0
 def period(self, counts):
     msg = message.ChannelPeriodMessage(self.number, counts)
     response = self.node.evm.writeMessage(msg).waitForAck(msg)
     if response != RESPONSE_NO_ERROR:
         raise ChannelError('%s: could not set period (%.2x).' %
                            (str(self), response))
     self._period = counts
Example #7
0
    def open(self):
        msg = message.ChannelOpenMessage(number=self.number)
        evm = self.node.evm
        response = evm.writeMessage(msg).waitForAck(msg)
        if response != RESPONSE_NO_ERROR:
            raise ChannelError('%s: could not open (%.2x).' % (str(self), response))

        evm.registerCallback(self)
Example #8
0
    def close(self):
        msg = message.ChannelCloseMessage(number=self.number)
        evm = self.node.evm
        response = evm.writeMessage(msg).waitForAck(msg)
        if response != RESPONSE_NO_ERROR:
            raise ChannelError('%s: could not close (%.2x).' % (str(self), response))

        while True:
            msg = evm.waitForMessage(message.ChannelEventResponseMessage)
            if msg.channelNumber == self.number and \
               msg.messageCode == EVENT_CHANNEL_CLOSED:
                break

        evm.removeCallback(self)