当前位置: 首页>>代码示例>>Python>>正文


Python XBee.remote_at方法代码示例

本文整理汇总了Python中xbee.XBee.remote_at方法的典型用法代码示例。如果您正苦于以下问题:Python XBee.remote_at方法的具体用法?Python XBee.remote_at怎么用?Python XBee.remote_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xbee.XBee的用法示例。


在下文中一共展示了XBee.remote_at方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
def main(argv):

	#this is for all command line argument parsing
	SerialNumber = ''
	Command = ''
	Parameter = ''

	try:
		opts, args = getopt.getopt(argv,"s:c:p:",["SerialNumber=","Command=","Parameter="])

	except getopt.GetoptError:
		print 'argtest.py -s SerialNumber -c Command -p Parameter'
		sys.exit(2)

	for opt, arg in opts:
		if opt == '-h':
			print 'test.py -s <SerialNumber> -c <Command> -p <Parameter>'
			sys.exit()
		elif opt in ("-s", "SerialNumber"):
			SerialNumber = arg
		elif opt in ("-c", "Command"):
			Command = arg
		elif opt in ("-p", "Parameter"):
			Parameter = arg

	print 'Serial Number is:', SerialNumber
	print 'Command is:', Command
	print 'Parameter is:', Parameter

	#XBee Transmit Part
	PORT = '/dev/ttyAMA0'
	BAUD = 9600

	print 'start'

	ser = Serial(PORT, BAUD)
	print '1'
	xbee = XBee(ser)
	print '2'
	# Sends remote command from coordinator to the serial number, this only returns the value. In order to change
	#the value must add a parameter='XX'
	xbee.remote_at(frame_id='A',dest_addr_long=SerialNumber.decode('hex'), command=Command, parameter=Parameter.decode('hex'))
	print '3'
	# Wait for and get the response
	frame = xbee.wait_read_frame()
	
	print '4'
	print frame
	ser.close()
开发者ID:henrib128,项目名称:uvic-home-auto,代码行数:51,代码来源:tx.py

示例2: XBee

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
xbee = XBee(ser)


def print_data(data) :
    print "print_data"
    print data

xbee = XBee(ser, callback=print_data)

# Set remote DIO pin 2 to low (mode 4)

i = 0
while True:
    try:
        print i
        xbee.tx(dest_addr='\x2C\x2C', data=str(i%10))
#        xbee.tx(dest_addr='\x1B\x1B', data=str(i%10))
        time.sleep(0.05)
        i = i + 1

    except KeyboardInterrupt:
        break

xbee.halt()
ser.close()
"""  
xbee.remote_at(
        dest_addr='\x56\x78',
        command='WR')
        """
开发者ID:morfant,项目名称:201510_xbee,代码行数:32,代码来源:rpiToTeensyTxTest.py

示例3: XBeeWrapper

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
class XBeeWrapper(object):
    """
    Helper class for the python-xbee module.
    It processes API packets into simple address/port/value groups.
    See http://code.google.com/r/xoseperez-python-xbee/
    """

    default_port_name = 'serial'

    serial = None
    xbee = None
    logger = None

    buffer = dict()

    def log(self, level, message):
        if self.logger:
            self.logger.log(level, message)

    def disconnect(self):
        """
        Closes serial port
        """
        self.xbee.halt()
        self.serial.close()
        return True

    def connect(self):
        """
        Creates an Xbee instance
        """
        try:
            self.log(logging.INFO, "Connecting to Xbee")
            self.xbee = XBee(self.serial, callback=self.process)
        except:
            return False
        return True

    def process(self, packet):
        """
        Processes an incoming packet, supported packet frame ids:
            0x90: Zigbee Receive Packet
            0x92: ZigBee IO Data Sample Rx Indicator
        """

        self.log(logging.DEBUG, packet)

        address = packet['source_addr_long']
        frame_id = int(packet['frame_id'])

        # Data sent through the serial connection of the remote radio
        if (frame_id == 90):

            # Some streams arrive split in different packets
            # we buffer the data until we get an EOL
            self.buffer[address] = self.buffer.get(address,'') + packet['data']
            count = self.buffer[address].count('\n')
            if (count):
                lines = self.buffer[address].splitlines()
                try:
                    self.buffer[address] = lines[count:][0]
                except:
                    self.buffer[address] = ''
                for line in lines[:count]:
                    line = line.rstrip()
                    try:
                        port, value = line.split(':', 1)
                    except:
                        value = line
                        port = self.default_port_name
                    self.on_message(address, port, value)

        # Data received from an IO data sample
        if (frame_id == 92):
            for port, value in packet['samples'].iteritems():
                if port[:3] == 'dio':
                    value = 1 if value else 0
                self.on_message(address, port, value)

    def on_message(self, address, port, value):
        """
        Hook for outgoing messages.
        """
        None

    def send_message(self, address, port, value, permanent = True):
        """
        Sends a message to a remote radio
        Currently, this only supports setting a digital output pin LOW (4) or HIGH (5)
        """
        try:

            if port[:3] == 'dio':
                address = binascii.unhexlify(address)
                number = int(port[3:])
                command = 'P%d' % (number - 10) if number>9 else 'D%d' % number
                value = binascii.unhexlify('0' + str(int(value) + 4))
                self.xbee.remote_at(dest_addr_long = address, command = command, parameter = value)
                self.xbee.remote_at(dest_addr_long = address, command = 'WR' if permanent else 'AC')
                return True
#.........这里部分代码省略.........
开发者ID:bodaay,项目名称:xbee2mqtt,代码行数:103,代码来源:xbee_wrapper.py

示例4: XBee

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
import serial
from xbee import XBee

import sys

#print sys.argv[1]

serial_port = serial.Serial('/dev/ttyUSB0', 9600)
xbee = XBee(serial_port)

if sys.argv[1] == '0':
	print 'Se prende la luz'	
	xbee.remote_at(dest_addr='\x00\x04', command='D0',  parameter='\x04')
else:
	print 'Se apaga la luz'
	xbee.remote_at(dest_addr='\x00\x04', command='D0',  parameter='\x05')
  
xbee.remote_at(dest_addr='\x00\x04', command='WR')
开发者ID:oritec,项目名称:bilbao796,代码行数:20,代码来源:SetLed-Valvula.py

示例5:

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
#MAC, number written on the back of the XBee module
# CO3 = my coordinator
# EP1 = my endpoint with the LED on pin 11

device={
        "CO3":'\x00\x00\x00\x00\x00\x00\x00\x00',
        "EP1":'\x00\x13\xa2\x00\x40\x64\x71\x68'
}

#change remote device function
# xbee.remote_at(dest_addr_long=device["EP1"],command='D2',parameter='\x02')
# xbee.remote_at(dest_addr_long=device["EP1"],command='D1',parameter='\x03')
# xbee.remote_at(dest_addr_long=device["EP1"],command='SM',parameter='\x00')
# xbee.remote_at(dest_addr_long=device["EP1"],command='SP',parameter='\x00')
xbee.remote_at(dest_addr_long=device["EP1"],command='ST',parameter='\x1388')
xbee.remote_at(dest_addr_long=device["EP1"],command='IR',parameter='\x04\x00')
xbee.remote_at(dest_addr_long=device["EP1"],command='IC',parameter='\x02')
xbee.remote_at(dest_addr_long=device["EP1"],command='WR')

led=False
while 1:

        #set led status
        led=not led

        if led:
                # xbee.remote_at(dest_addr_long=device["EP1"],command='D4',parameter='\x04')
		xbee.remote_at(dest_addr='\x00\x0f',command='D4',parameter='\x04')
                print "LED Off"
        else:
开发者ID:HarlandWHansen,项目名称:gateway_raspi,代码行数:32,代码来源:testSend.py

示例6: ZigBee

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
# Use an XBee 802.15.4 device
# To use with an XBee ZigBee device, replace with:
#xbee = ZigBee(ser)
xbee = XBee(ser)


device={
        "CO3":'\x00\x13\xa2\x00\x40\x52\x8d\x8a',
        "EP1":'\x00\x13\xa2\x00\x40\xb5\xb1\x0b'
}


led=False

#change remote device function
xbee.remote_at(dest_addr_long=device["EP1"],command='D2',parameter='\x02')
xbee.remote_at(dest_addr_long=device["EP1"],command='D1',parameter='\x03')
xbee.remote_at(dest_addr_long=device["EP1"],command='IR',parameter='\x04\x00')
xbee.remote_at(dest_addr_long=device["EP1"],command='IC',parameter='\x02')

while 1:
        #set led status
        led=not led
        if led:
                print "switching Off Light"
                xbee.remote_at(dest_addr_long=device["EP1"],command='D0',parameter='\x04')
        else:
                print "switching on Light"
                xbee.remote_at(dest_addr_long=device["EP1"],command='D0',parameter='\x05')
        # wait 1 second
        time.sleep(5)
开发者ID:rajeshrajd73,项目名称:xbee-python,代码行数:33,代码来源:xbee-relay.py

示例7: XBeeWrapper

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]

#.........这里部分代码省略.........
        """
        Processes an incoming packet, supported packet frame ids:
            0x90: Zigbee Receive Packet
            0x92: ZigBee IO Data Sample Rx Indicator
        """

        #self.log(logging.DEBUG, packet)

        address = packet['source_addr_long']
        frame_id = int(packet['frame_id'])

        # Data sent through the serial connection of the remote radio
        if (frame_id == 90):

            # Some streams arrive split in different packets
            # we buffer the data until we get an EOL
            self.buffer[address] = self.buffer.get(address,'') + packet['data']
            count = self.buffer[address].count('\n')
            if (count):
                lines = self.buffer[address].splitlines()
                try:
                    self.buffer[address] = lines[count:][0]
                except:
                    self.buffer[address] = ''
                for line in lines[:count]:
                    line = line.rstrip()
                    try:
                        port, value = line.split(':', 1)
                    except:
                        value = line
                        port = self.default_port_name
                    self.on_message(address, port, value)

        # Data received from an IO data sample
        if (frame_id == 92):
            for port, value in packet['samples'].iteritems():
                if port[:3] == 'dio':
                    value = 1 if value else 0
                self.on_message(address, port, value)

    def on_message(self, address, port, value):
        """
        Hook for outgoing messages.
        """
        None

#    def send_message(self, address, port, value, permanent = True):
#        """
#        Sends a message to a remote radio
#        Currently, this only supports setting a digital output pin LOW (4) or HIGH (5)
#        """
#        try:
#
#            if port[:3] == 'dio':
#                address = binascii.unhexlify(address)
#                number = int(port[3:])
#                command = 'P%d' % (number - 10) if number>9 else 'D%d' % number
#                value = binascii.unhexlify('0' + str(int(value) + 4))
#                self.xbee.remote_at(dest_addr_long = address, command = command, parameter = value)
#                self.xbee.remote_at(dest_addr_long = address, command = 'WR' if permanent else 'AC')
#                return True
#
#        except:
#            pass
#
#        return False

    def send_message (self, type, address, msg, dio_num = 0):
        """
        Sends a message to a remote radio
        """
        self.log(logging.DEBUG, 'send_message type: %s'%type)
        try:
            address = binascii.unhexlify(address)

            if type == 'dio':
                number = dio_num
                command = 'P%d' % (number - 10) if number>9 else 'D%d' % number
                value = binascii.unhexlify('0' + str(int(msg) + 4))
                self.xbee.remote_at(dest_addr_long = address, command = command, parameter = value)
                self.xbee.remote_at(dest_addr_long = address, command = 'WR')
                self.log(logging.DEBUG, "send remote_at cmd: %s %s"%(command, value))
                return True
            elif type == 'data':
                if self.radio_type == 'DigiMesh':
                    self.xbee.tx(dest_addr = address, data = msg)
                elif self.radio_type == 'IEEE':
                    self.xbee.tx_long_addr(dest_addr = address, data = msg)

                self.log(logging.DEBUG, "sent data: %s"% msg)

                return True
            elif type == 'rpc':
                pass

        except Exception,e:
            print e
            pass

        return False
开发者ID:CasyWang,项目名称:CloudPan,代码行数:104,代码来源:xbee_wrapper.py

示例8:

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
          #options='\x02',
          #command='IR',
          #parameter='\x32')

#print xbee.wait_read_frame()['status']

#xbee.send('remote_at', 
          #frame_id='C',
          #dest_addr_long='\x00\x00\x00\x00\x00\x00\x00\x00',
          #dest_addr='\x56\x78',
          #options='\x02',
          #command='WR')
          
# Deactivate alarm pin
xbee.remote_at(
  dest_addr='\x56\x78',
  command='D2',
  parameter='\x04')
  
xbee.remote_at(
  dest_addr='\x56\x78',
  command='WR')

#print xbee.wait_read_frame()['status']

while True:
    try:
        packet = xbee.wait_read_frame()
        print packet
        
        # If it's a sample, check it
        if packet['id'] == 'rx_io_data':
开发者ID:BenBBear,项目名称:python-xbee,代码行数:34,代码来源:led_adc_example.py

示例9: XBee

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
serial_port = serial.Serial(SERIALPORT,BAUDRATE)
xbee = XBee(serial_port)

thisDest = '\x00\x0f'

xbee.send('remote_at', 
          frame_id='C',
          dest_addr=thisDest,
          options='\x02',
          command='IR',
          parameter='\x32')

print xbee.wait_read_frame()['status']

# Deactivate LED pin, D4
xbee.remote_at(dest_addr=thisDest,command='D4',parameter='\x04')
xbee.remote_at(dest_addr=thisDest,command='WR')


led=False
while 1:

        #set led status
        led=not led

        if led:
		xbee.remote_at(dest_addr=thisDest,command='D4',parameter='\x04')
                print "LED Off"
        else:
		xbee.remote_at(dest_addr=thisDest,command='D4',parameter='\x05')
                print "LED On"
开发者ID:HarlandWHansen,项目名称:gateway_raspi,代码行数:33,代码来源:testLED.py

示例10: reconnect

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
    client.unsubscribe("/lights/#")
    client.disconnect()

def reconnect():
    disconnectall()
    connectall()

connectall()

try:
    while client.loop()==0:
        # Look for commands in the queue and execute them
        if(not commands.empty()):
            command=commands.get()
            if(args.verbosity>0):
                print("DISPATCHER: sending to Xbee: "+command)
            address=pack('>h',int(command.split(":")[0]))
            port='D'+command.split(":")[1]
            sent=command.split(":")[2]
            if sent == '1':
                 msg= pack('>b',4)
            elif sent == '0':
                msg= pack('>b',5)
            
            xbee.remote_at(dest_addr=address, command=port,  parameter=msg)
            

except KeyboardInterrupt:
    print "Interrupt received"
    disconnectall()
开发者ID:oritec,项目名称:bilbao796,代码行数:32,代码来源:mqttConsumer.py

示例11: writeLog

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
     if data[0] == 'battery_life':
         print 'Battery Life: ' + data[1].encode("hex")
         writeLog('Battery Life: ' + data[1].encode("hex") + '\n')
     if data[0] == 'command_executed':
         print 'Command executed: ' + data[1]
         writeLog('Command executed: ' + data[1] + '\n')
 
 command_file = open("/var/www/web/command.txt", "r+")
 command = command_file.read()
 if command != '':
     print 'Command received: ' + command 
     # Motion Sensing Disable
     if command == '1': 
         print 'Motion Sensing Disable'
         writeLog('Motion Sensing Disable\n')
         xbee.remote_at(dest_addr_long=device["EP1"],command='D0',parameter='\x05')
         time.sleep(1)		
         xbee.remote_at(dest_addr_long=device["EP1"],command='D0',parameter='\x04')
     # Enable Motion Detecting
     elif command == '2':
         print 'Enable Motion Detecting'
         writeLog('Enable Motion Detecting\n')
         xbee.remote_at(dest_addr_long=device["EP1"],command='D1',parameter='\x05')
         time.sleep(1)		
         xbee.remote_at(dest_addr_long=device["EP1"],command='D1',parameter='\x04')
     # Take a picture		
     elif command == '3':
         print 'Take A Picture'
         writeLog('Take A Picture\n')
         xbee.remote_at(dest_addr_long=device["EP1"],command='D2',parameter='\x05')
         time.sleep(1)		
开发者ID:alphamale327,项目名称:Camera_Hub_RasPi,代码行数:33,代码来源:main.py

示例12: XBee

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
import serial
from xbee import XBee

import sys

#print sys.argv[1]

serial_port = serial.Serial('/dev/ttyUSB0', 9600)
xbee = XBee(serial_port)


xbee.remote_at(frame_id='A', dest_addr='\x00\x02', command='D0', parameter=None) 
#xbee.remote_at(dest_addr='\x00\x02', command='WR')
packet = xbee.wait_read_frame()
#print packet


if packet['id'] == 'remote_at_response':
	if packet['parameter'] == '\x04':
		print 'LED esta apagado'
	elif packet['parameter']=='\x05':
		print 'LED esta prendido'
开发者ID:oritec,项目名称:bilbao796,代码行数:24,代码来源:ReadLed.py

示例13: hex

# 需要导入模块: from xbee import XBee [as 别名]
# 或者: from xbee.XBee import remote_at [as 别名]
                    break

                print "received data from:", address, "\t", data

                radioMsg = data.split(":")
                # print hex(int(radioMsg[0])), radioMsg[1]

                radioAddr = chr(0) + chr(int(radioMsg[0]))
                # print "radioAddr", radioAddr

                radioCmd = '\x04'
                if radioMsg[1] == "HI":
                    radioCmd = '\x05'

                for x in xrange(4):
                    xbee.remote_at(dest_addr=radioAddr,frame_id=b"A",command='D4',parameter=radioCmd)
                    time.sleep(.13)


            print "diconnected from: ", address

    except KeyboardInterrupt:
        print "keyboard break!"
        keepGoing = False
        break

    except Exception, e:
        print "general error", e.message
        keepGoing = False
        s.close()
        print "exception: socket closed..."
开发者ID:TinajaLabs,项目名称:tinajagate,代码行数:33,代码来源:sensorgate.py


注:本文中的xbee.XBee.remote_at方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。