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
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)
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
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
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
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
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)
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)