Git Product home page Git Product logo

xbee-python's Introduction

Digi XBee Python library pypiversion PyPI - Python Version

This project contains the source code of the XBee Python library, an easy-to-use API developed in Python that allows you to interact with Digi International's XBee radio frequency (RF) modules.

This source has been contributed by Digi International.

Installation

You can install XBee Python library using pip:

$ pip install digi-xbee

Install from Source

You can install XBee Python library directly from sources. To do so, extract the source code to your computer and execute the following command:

$ pip install <path_to_xbee-python_dir>

Documentation

XBee Python library has user guide and API reference documentation hosted on Read the Docs. You can find the latest, most up to date, documentation at latest docs. To see only those features which have been released, check out the stable docs.

How to contribute

The contributing guidelines are in the CONTRIBUTING.rst document.

License

Copyright 2017-2021, Digi International Inc.

The MPL 2.0 license covers the majority of this project with the following exceptions:

  • The ISC license covers the contents of the examples directory.

xbee-python's People

Contributors

daescalona avatar diescalo avatar hgonzaledigi avatar ihermida avatar jdepedro-digi avatar jroelofs avatar jviguera avatar mikewadsten avatar rubenmoral avatar soterboat avatar tatianaleon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xbee-python's Issues

digi.xbee.exception.InvalidOperatingModeException: Unsupported operating mode: AT mode

I'm trying to use this library in a Raspberry Pi 3 with two modules XBEE S1. I have checked the correct operation of API mode [1] with a hyperterminal with different XBEE whit fixed PAN ID and CH. But, if I run the basic example:

from digi.xbee.devices import XBeeDevice
....
device = XBeeDevice('/dev/ttyS0', 9600)
device.open()
...
device.send_data_broadcast ("Hello XBees!")
...
device.close()

I get this error:

File "/home/pi/JairoC/ApiModeService.py", line 73, in <module>
      device.open()
File "usr/local/lib/python3.5/dist-packages/digi_xbee-1.1.0-py3.5.egg/digi/
xbee/devices.py", line 1262, in open
       raise InvalidOperatingModeException.from_operating_mode(self._operating_mode)
digi.xbee.exception.InvalidOperatingModeException: Unsupported operating mode: 
AT mode

I don't know what to do... Sometimes the application works and send information but with a long process or parallel trading, the error is presented.

Any help will be valued

ImportError: cannot import name Serial

While executing the program in Ubuntu 16.04 I am getting this error

Traceback (most recent call last):
File "dgpython.py", line 1, in
from digi.xbee.devices import XBeeDevice
File "build/bdist.linux-x86_64/egg/digi/xbee/devices.py", line 22, in
File "build/bdist.linux-x86_64/egg/digi/xbee/serial.py", line 15, in
ImportError: cannot import name Serial

Configuration of PWM is not working

Hi,
I tryto configure PWM then I am getting the following error.
found_node.set_io_configuration(self.IO_LINE_PWM0, IOMode.PWM
File "/usr/local/lib/python3.5/dist-packages/digi/xbee/devices.py", line 624, in set_io_configuration
self.set_parameter(io_line.at_command, bytearray([io_mode.value]))
File "/usr/local/lib/python3.5/dist-packages/digi/xbee/devices.py", line 4835, in set_parameter
raise ATCommandException("Error setting parameter, command status: " + response.status.description)
digi.xbee.exception.ATCommandException: Error setting parameter, command status: Invalid parameter

API Frame 0x09 (Queued AT command) is not implemented

I am seeing device.enable_apply_changes(False) not being respected on local Zigbee Devices, and upon looking at the code, it sure looks like the API frame required for that (0x09 - Queued AT command) is not even implemented.

How to get RSSI of a message

Hi,

I would like to know how to get the RSSI between 2 nodes? I can see at the XCTU serial monitor the message with the RSSI, but I can't find how to get the RSSI with this python library.

Thanks!

Installing 1.1.1 error through pip

$ pip install digi-xbee==1.1.1
Collecting digi-xbee==1.1.1
  Could not find a version that satisfies the requirement digi-xbee==1.1.1 (from versions: 1.0.0.1, 1.1.0.1, 1.1.1.1)
No matching distribution found for digi-xbee==1.1.1

However doing this works.

$ pip install digi-xbee==1.1.1.1
Collecting digi-xbee==1.1.1.1
  Using cached https://files.pythonhosted.org/packages/08/0c/2ed3b4af93dd957103d897c7899159b77d55b0809490669b25c5e469784b/digi-xbee-1.1.1.1.tar.gz
  Requested digi-xbee==1.1.1.1 from https://files.pythonhosted.org/packages/08/0c/2ed3b4af93dd957103d897c7899159b77d55b0809490669b25c5e469784b/digi-xbee-1.1.1.1.tar.gz#sha256=5bef6b1888886e99d1ec02ba35e1db17eb5f6f5b008e08cc85571f94df104acf, but installing version 1.1.1
Collecting pyserial>=3 (from digi-xbee==1.1.1.1)
  Using cached https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl
Building wheels for collected packages: digi-xbee
  Running setup.py bdist_wheel for digi-xbee ... done
  Stored in directory: /home/asolis/.cache/pip/wheels/ee/8c/1f/a3490f75dd633035a32badb045abdb7d244009b919614859a1
Successfully built digi-xbee
Installing collected packages: pyserial, digi-xbee
Successfully installed digi-xbee-1.1.1 pyserial-3.4

When doing a pip freeze the version is 1.1.1

My set up (but also applies at least to 3.7 and pip 18.0)

$ python --version
Python 3.6.5
$ pip --version
pip 18.0 from /home/asolis/.virtualenvs/experiments/lib/python3.6/site-packages/pip (python 3.6)

NoneType attribute error

Hello ,
I bought these new Xbee 868 and tried to use them in API mode with this python library, but whatever I try I keep getting this error and i have no clue what i did wrong. I just used the example network/DiscoverDevicesSample and followed the exact instructions. Could somebody please help me?

+---------------------------------------------+
| XBee Python Library Discover Devices Sample |
+---------------------------------------------+

The thread 'MainThread' (0x1c64) has exited with code 0 (0x0).
Traceback (most recent call last):
File "C:\Users\Jim\source\repos\start\start\start.py", line 70, in
main()
File "C:\Users\Jim\source\repos\start\start\start.py", line 34, in main
device.open()
File "C:\Users\Jim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\digi\xbee\devices.py", line 1290, in open
self.read_device_info()
File "C:\Users\Jim\AppData\Local\Programs\Python\Python36-32\lib\site-packages\digi\xbee\devices.py", line 315, in read_device_info
self._protocol = XBeeProtocol.determine_protocol(self._hardware_version.code, self._firmware_version)
AttributeError: 'NoneType' object has no attribute 'code'
The program '[6768] python.exe' has exited with code -1073741510 (0xc000013a).

Definition for ENABLE_UNICAST_TRACE_ROUTE is incorrect

ENABLE_UNICAST_TRACE_ROUTE is presently defined as 0x04 in file xbee/models/options.py.
It should be defined as 0x08.

Note that that the current definition of ENABLE_UNICAST_TRACE_ROUTE has the same value as ENABLE_UNICAST_NACK. Unfortunately, the document "XBee/XBee-PRO SX RF Module user guide" doesn't actually define the value for ENABLE_UNICAST_TRACE_ROUTE. Nor does it adequately define the bits for transmit options for transmit requests. Ideally it would contain the following table:
BIT Value Description
0 0x01 DISABLE_ACK - Disables acknowledgments on all unicasts
1 0x02 DONT_ATTEMPT_RD - Disables Route Discovery on all DigiMesh unicasts.
2 0x04 ENABLE_UNICAST_NACK - Enables unicast NACK messages.
3 0x08 ENABLE_UNICAST_TRACE_ROUTE - Enables unicast trace route messages.
6,7 0x40 POINT_MULTIPOINT_MODE - Transmission is performed using point-to-point/multipoint mode
6,7 0x80 REPEATER_MODE - Transmission is performed using repeater mode.
6,7 0xC0 DIGIMESH_MODE - Transmission is performed using DigiMesh mode

[FEATURE REQUEST] Add method to RemoteXBeeDevice to transmit data

When I have a RemoteXBeeDevice object I want to transmit data to, it's a little cumbersome to reference the local device's send_data method, and then pass the RemoteXBeeDevice to that.

remote.get_local_xbee_device().send_data(remote, data)

I propose a new wrapper method in RemoteXBeeDevice that eliminates some of the redundancy

class RemoteXBeeDevice:
    ....
    def send_data(self, data, transmit_options=TransmitOptions.NONE.value):
        _local_xbee_device.send_data(self, data, transmit_options)

Before:

remote.get_local_xbee_device().send_data(remote, data)

After:

remote.send_data(data)

TimeOut Exception

I have a simple setup of 2 xbee s2c modules and one rpi. Coordinator Xbee on adapter is conneccted to rpi via USB and the router is connected to my laptop throught xctu (I have verified communication by connecteding both through xctu software). My problem is when i try to send any message from coordinator connected to rpi, I get a TimeOutException. I have tried to send data asynchronously, asynchronously and broadcast. All have failed. There is no problem in receiving messages

Coordinator config Profile File
https://drive.google.com/file/d/1cKQTSytdIcGt9pdrIU-YRaW-DdvHDLTx/view?usp=sharing

Router config Profile File
https://drive.google.com/file/d/1HYRM0SXRHhK2-fNxXi3kiyCeFtXfyrfL/view?usp=sharing

My Code
`
from digi.xbee.models.address import XBee64BitAddress, XBee16BitAddress, XBeeIMEIAddress
from digi.xbee.devices import RemoteXBeeDevice, DigiMeshDevice, XBeeDevice

PORT = "/dev/ttyUSB0"
BAUD_RATE = 57600

def my_data_received_callback(xbee_message):
address = xbee_message.remote_device.get_64bit_addr()
data = xbee_message.data.decode("utf8")
print(data)
remote_device = RemoteXBeeDevice(device, address)

#device.send_data_broadcast("Hello XBee World!")
device.send_data(remote_device,"received")

device = XBeeDevice(PORT, BAUD_RATE)
device.open()
device.add_data_received_callback(my_data_received_callback)
`

Device read data returns None

Hi all,

I'm trying to use read_data() to read data from a coordinator connected to USB but I get not data. The code that I'm using is the following:

from digi.xbee.devices import XBeeDevice
PORT = "/dev/ttyUSB0"
BAUD_RATE = 9600
device = XBeeDevice(PORT, BAUD_RATE)
device.open()
device.flush_queues()
xbee_message = device.read_data()

The xbee_message is allways None. I have checked with XCTU that from the console that I recive data but the python code it is not working. The Corrdinatore is in AP=1 and the apioutput mode is NATIVE.

Best,

Lorenzo

Not able to install through PIP

Hi,
I am NOT able to install via PIP. pip install digi-xbee gives following error.
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecomma nd.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/ install.py", line 324, in run
requirement_set.prepare_files(finder)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_s et.py", line 380, in prepare_files

async explicit data rx callback blocks

Hi...

I'm using the async explicit data received callback with Zigbee as follows:

device.add_expl_data_received_callback(my_expl_data_received_callback)

...and here is the content of the callback...

def my_expl_data_received_callback(explicit_xbee_message):
print("explicit data received")
pprint(vars(explicit_xbee_message))

print(" - Source endpoint:        %s"
      % utils.hex_to_string(utils.int_to_length(explicit_xbee_message.source_endpoint)))
print(" - Destination endpoint:   %s"
      % utils.hex_to_string(utils.int_to_length(explicit_xbee_message.dest_endpoint)))
print(" - Cluster ID:             %s"
      % utils.hex_to_string(utils.int_to_length(explicit_xbee_message.cluster_id)))
print(" - Profile ID:             %s"
      % utils.hex_to_string(utils.int_to_length(explicit_xbee_message.profile_id)))
print(" - Source address:         %s" % (explicit_xbee_message.remote_device.get_64bit_addr()))
print(" - Data: %s", explicit_xbee_message.data.decode())

For some reason it blocks on the final statement when I try to read the data property. The following is the failure message:

Traceback

(most recent call last):
File "digi-test.py", line 137, in
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/serial/serialposix.py", line 472, in read
ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/digi/xbee/reader.py", line 297, in run
raw_packet = self.__try_read_packet()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/digi/xbee/reader.py", line 642, in __try_read_packet
xbee_packet[0] = self.__serial_port.read_byte()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/digi/xbee/serial.py", line 89, in read_byte
byte = bytearray(self.read(1))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/serial/serialposix.py", line 497, in read
raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/digi/xbee/reader.py", line 325, in run
self.__xbee_device.serial_port.close()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/serial/serialposix.py", line 440, in close
os.close(self.fd)
OSError: [Errno 9] Bad file descriptor`

I'm using v 1.0.0 of the library.

Liam

XBee-PRO ZB (S2C) TH - InvalidOperatingModeException: Could not determine operating mode

Hi all,

I have conncted a Digi XBee-PRO ZB (S2C) TH to my desktop. If try to connect to the device with the following code I get the following error:

from digi.xbee.devices import ZigBeeDevice 
PORT = "/dev/ttyUSB0"  
BAUD_RATE = 9600 
device = ZigBeeDevice(PORT, BAUD_RATE)                                                                                                                                       
device.open()        
                                                                                                                                                        
---------------------------------------------------------------------------
InvalidOperatingModeException             Traceback (most recent call last)
<ipython-input-4-b929a415d2b8> in <module>
----> 1 device.open()

~/py3/lib/python3.6/site-packages/digi/xbee/devices.py in open(self)
   2970            | :meth:`.XBeeDevice.open`
   2971         """
-> 2972         super().open()
   2973         if self.get_protocol() != XBeeProtocol.ZIGBEE:
   2974             raise XBeeException("Invalid protocol.")

~/py3/lib/python3.6/site-packages/digi/xbee/devices.py in open(self)
   1257         if self._operating_mode == OperatingMode.UNKNOWN:
   1258             self.close()
-> 1259             raise InvalidOperatingModeException("Could not determine operating mode")
   1260         if self._operating_mode == OperatingMode.AT_MODE:
   1261             self.close()

InvalidOperatingModeException: Could not determine operating mode

If I open than XCTU and try to connect the device it works from both XCTU and Python.

Any suggestion to solve the issue?

Best,

Lorenzo

RE: BeagleBone Black, XBee S1, and THT Grove Adapter Board/Seth

Hello,

I am using a BeagleBone Black Wireless via their Linux Distro w/ the THT dev. board from Digi. My wireless XBee is attached to the THT/Grove dev. board.

The dev. board and XBee is attached to the BeagleBone Black Wireless via the USB port on the BBBW located at ttyUSB0. That is the number 0 and not the letter O.

I found your software from 2017 at https://github.com/digidotcom/python-xbee/blob/master/examples/io/LocalDIOSample/LocalDIOSample.py.

So, I thought I could, since the OS is Debian (a Linux Distro), use ttyUSB0 instead of a com7 port for this particular attachment.

Now...

I am getting an error:

Traceback (most recent call last):
  File "xBee.py", line 10, in <module>
    IO_LINE_IN = IOLine.DIO0_DO0
  File "/usr/lib/python3.5/enum.py", line 274, in __getattr__
    raise AttributeError(name) from None
AttributeError: DIO0_DO0

line 10 reads:

 IO_LINE_IN = IOLine.DIO0_DO0   

So...

I thought I had the connection incorrect or not at all ready for reading my receiver module that is located on a breadboard that would light up a LED.

This idea has already been accomplished and the LED lit up w/ my wiring and XCTU config.

If you know why I am receiving the DIO0_DO0 error, please reply. I sure could use some ideas. If this does not have to do w/ your library or software, please let me know, too.

Seth

P.S. If you need any other info. from me, please contact me.

Register Joining Device - 0x24 - support

It doesn't look like there is support for the 0x24 packet type to enable registration of devices via their install code.
Is this supported by the library at the moment, or is it on the roadmap at all?
This is documented at:
https://www.digi.com/resources/documentation/digidocs/pdfs/90001539.pdf
(search for 'Example: Register a joining node using an install code')

From the code it looks like we'd need a new entry into https://github.com/digidotcom/xbee-python/blob/master/digi/xbee/packets/aft.py#L38, and probably a new packet class in https://github.com/digidotcom/xbee-python/blob/master/digi/xbee/packets/common.py

exception on device.close()

Discovery process finished successfully.
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/xxxxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/serial/serialposix.py", line 483, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/xxxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/digi/xbee/reader.py", line 299, in run
    raw_packet = self.__try_read_packet(self.__xbee_device.operating_mode)
  File "/Users/xxxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/digi/xbee/reader.py", line 671, in __try_read_packet
    xbee_packet[0] = self.__serial_port.read_byte()
  File "/Users/xxxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/digi/xbee/serial.py", line 89, in read_byte
    byte = bytearray(self.read(1))
  File "/Users/xxxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/serial/serialposix.py", line 509, in read
    raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.4_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/Users/xxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/digi/xbee/reader.py", line 327, in run
    self.__xbee_device.serial_port.close()
  File "/Users/xxxxx/.local/share/virtualenvs/python-demo-ImaXBV93/lib/python3.6/site-packages/serial/serialposix.py", line 451, in close
    os.close(self.fd)
OSError: [Errno 9] Bad file descriptor

device.open() => self.send_packet_sync_and_get_response(packet_to_send) # raises TimeoutException

Hello,
I'm not sure if it is the good place to post my problem..
I try to use this library with a xbee S2C 2.4ghz digimesh, plugged on a sparkfun usb explorer.
Xbee configured on API2 with XCTU.

I try to make the delivered example of receive data. So I write the python script and run it.
But when it enter in device.open() I have this error :

File "C:\Program Files (x86)\Python36-32\lib\site-packages\digi_xbee-1.0.0-py3.6.egg\digi\xbee\devices.py", line 1290, in open
self.read_device_info()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\digi_xbee-1.0.0-py3.6.egg\digi\xbee\devices.py", line 309, in read_device_info
self._hardware_version = HardwareVersion.get(self.get_parameter("HV")[0])
File "C:\Program Files (x86)\Python36-32\lib\site-packages\digi_xbee-1.0.0-py3.6.egg\digi\xbee\devices.py", line 1028, in dec_function
return func(self, *args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\digi_xbee-1.0.0-py3.6.egg\digi\xbee\devices.py", line 1336, in get_parameter
response = self.send_packet_sync_and_get_response(packet_to_send) # raises TimeoutException
File "C:\Program Files (x86)\Python36-32\lib\site-packages\digi_xbee-1.0.0-py3.6.egg\digi\xbee\devices.py", line 2450, in send_packet_sync_and_get_response
raise TimeoutException("Response not received in the configured timeout.")
digi.xbee.exception.TimeoutException

I have same error on Windows7 or on Raspbian. I try different settings of Baud_rate but same error.

Could anyone help me to understand if I make a configuration error ?

Thank you

InvalidPacketException when reading in API escaped mode if checksum byte is escaped

After applying a fix for #11, I am now running into another error that crops up from time to time.

original: 7E 02 0B B0 34 2B 79 4D 00 00 27 7D 31 00 00 3A 45 5F 49 4E 2C 5A 09 2D 72 0C 71 60 37 6A 6A 28 3E 5B 49 3A 5F 38 32 51 66 49 7B 46 48 49 42 3E 64 5C 60 2B 5F 50 78 09 58 5D 6B 41 78 51 25 2D 4B 70 24 20 60 61 62 7B 54 6A 23 53 2C 75 51 6C 70 54 32 51 6B 37 46 7B 48 51 22 54 3D 6C 52 57 54 2B 4F 2B 2D 6C 4E 37 47 6C 51 33 4E 56 39 40 7A 3C 69 7C 39 41 79 4D 61 49 31 2A 75 50 64 3E 57 51 3B 7D 5D 48 59 55 62 0C 3A 36 33 75 79 57 50 3C 46 28 45 5E 25 5A 2A 2F 43 24 5B 3F 6E 33 6C 2B 7D 5D 6C 22 74 34 59 3B 47 72 44 66 46 3D 53 25 60 21 3A 32 60 0A 47 2A 72 77 53 0A 60 66 46 52 20 61 55 0A 4F 7B 79 47 4F 43 2C 3F 53 5D 6D 78 32 32 3C 38 75 47 65 54 3A 40 76 6B 30 30 35 61 44 20 5D 42 5B 0C 0B 57 68 6A 44 6C 37 50 62 54 2F 46 5E 43 6A 6E 5F 6C 31 20 34 3E 6D 59 3F 2A 63 7B 66 2C 22 63 42 68 56 6E 61 21 36 33 57 6D 66 2A 60 32 45 32 5C 2D 2B 5E 31 4B 73 44 09 39 3F 2D 0B 68 49 47 30 49 4F 2C 6B 67 0C 63 0A 49 42 4E 38 3F 6F 65 7D 5E 42 38 6C 29 53 34 5C 3C 78 6D 56 3A 45 3A 58 5D 3A 0A 0C 3F 5A 31 56 67 51 28 7D 5D 4B 2B 7D 5E 44 5B 44 7D 5E 35 42 36 09 60 78 20 54 32 27 72 7D 5E 3F 25 2D 51 6B 37 37 7C 3C 2D 0A 7A 4B 2C 6B 30 34 7C 4D 47 6D 26 53 77 78 25 2A 4F 4C 76 74 6B 23 67 30 69 38 2E 42 40 2A 35 3B 6D 62 53 34 6B 0C 2D 45 4D 3A 23 29 78 59 23 09 3B 76 49 22 38 3E 5F 7D 5D 55 62 36 45 3A 4B 59 64 2D 61 4E 72 76 30 43 5D 76 46 34 46 4F 7B 59 30 54 7C 50 3E 48 31 72 2A 3F 55 6B 28 53 4B 6F 67 39 7D 5E 24 3B 34 7C 2F 25 77 6B 64 64 50 50 63 50 5C 75 46 75 2B 7C 2B 34 40 6E 35 2F 4A 6C 45 28 21 4D 48 62 75 21 62 72 2B 26 5D 09 46 5F 34 30 39 58 43 6F 3F 0C 67 31 73 5F 70 75 49 49 49 7D
escaped: 7E 02 0B B0 34 2B 79 4D 00 00 27 11 00 00 3A 45 5F 49 4E 2C 5A 09 2D 72 0C 71 60 37 6A 6A 28 3E 5B 49 3A 5F 38 32 51 66 49 7B 46 48 49 42 3E 64 5C 60 2B 5F 50 78 09 58 5D 6B 41 78 51 25 2D 4B 70 24 20 60 61 62 7B 54 6A 23 53 2C 75 51 6C 70 54 32 51 6B 37 46 7B 48 51 22 54 3D 6C 52 57 54 2B 4F 2B 2D 6C 4E 37 47 6C 51 33 4E 56 39 40 7A 3C 69 7C 39 41 79 4D 61 49 31 2A 75 50 64 3E 57 51 3B 7D 48 59 55 62 0C 3A 36 33 75 79 57 50 3C 46 28 45 5E 25 5A 2A 2F 43 24 5B 3F 6E 33 6C 2B 7D 6C 22 74 34 59 3B 47 72 44 66 46 3D 53 25 60 21 3A 32 60 0A 47 2A 72 77 53 0A 60 66 46 52 20 61 55 0A 4F 7B 79 47 4F 43 2C 3F 53 5D 6D 78 32 32 3C 38 75 47 65 54 3A 40 76 6B 30 30 35 61 44 20 5D 42 5B 0C 0B 57 68 6A 44 6C 37 50 62 54 2F 46 5E 43 6A 6E 5F 6C 31 20 34 3E 6D 59 3F 2A 63 7B 66 2C 22 63 42 68 56 6E 61 21 36 33 57 6D 66 2A 60 32 45 32 5C 2D 2B 5E 31 4B 73 44 09 39 3F 2D 0B 68 49 47 30 49 4F 2C 6B 67 0C 63 0A 49 42 4E 38 3F 6F 65 7E 42 38 6C 29 53 34 5C 3C 78 6D 56 3A 45 3A 58 5D 3A 0A 0C 3F 5A 31 56 67 51 28 7D 4B 2B 7E 44 5B 44 7E 35 42 36 09 60 78 20 54 32 27 72 7E 3F 25 2D 51 6B 37 37 7C 3C 2D 0A 7A 4B 2C 6B 30 34 7C 4D 47 6D 26 53 77 78 25 2A 4F 4C 76 74 6B 23 67 30 69 38 2E 42 40 2A 35 3B 6D 62 53 34 6B 0C 2D 45 4D 3A 23 29 78 59 23 09 3B 76 49 22 38 3E 5F 7D 55 62 36 45 3A 4B 59 64 2D 61 4E 72 76 30 43 5D 76 46 34 46 4F 7B 59 30 54 7C 50 3E 48 31 72 2A 3F 55 6B 28 53 4B 6F 67 39 7E 24 3B 34 7C 2F 25 77 6B 64 64 50 50 63 50 5C 75 46 75 2B 7C 2B 34 40 6E 35 2F 4A 6C 45 28 21 4D 48 62 75 21 62 72 2B 26 5D 09 46 5F 34 30 39 58 43 6F 3F 0C 67 31 73 5F 70 75 49 49 49
2018-01-05 18:02:06,754 digi.xbee.reader: ERROR: The real length of this frame is distinct than the specified by length field (bytes 2 and 3)
Traceback (most recent call last):
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/reader.py", line 308, in run
    read_packet = factory.build_frame(raw_packet, self.__xbee_device.operating_mode)
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/packets/factory.py", line 181, in build_frame
    return RXIPv4Packet.create_packet(packet_bytearray, operating_mode)
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/packets/network.py", line 96, in create_packet
    XBeeAPIPacket._check_api_packet(raw, min_length=RXIPv4Packet.__MIN_PACKET_LENGTH)
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/packets/base.py", line 397, in _check_api_packet
    raise InvalidPacketException("The real length of this frame is distinct than the specified by length "
digi.xbee.exception.InvalidPacketException: The real length of this frame is distinct than the specified by length field (bytes 2 and 3)

The first two lines are from print calls that I have added.

By copying the 'original' frame data into XCTU's frame interpreter, I can see that I'm missing a 0x5D (escaped 0x7D) checksum byte at the end.

Perhaps the library is incorrectly calculating/accounting for escaped mode when reading in the API frame? According to the note here,

In API 2 mode, the length field does not include any escape character in the frame and the checksum is calculated with non-escaped data.

I haven't captured my serial traffic using a Saleae device or something like that (perhaps I should), but I don't think I'm losing any traffic.

serial.serialutil.SerialException: read failed: [Errno 9] Bad file descriptor

Hi, I'm trying to use a very simple code

PORT = "COM3"
BAUD_RATE = 9600

DATA_TO_SEND = "Hello XBee!"
REMOTE_NODE_ID = "N1"

def main():
    device = XBeeDevice(PORT, BAUD_RATE)
    device.close()

    try:
        device.open()
        print("Connection Open")
        # Obtain the remote XBee device from the XBee network.
        device.close()
        print("Connection Closed")
   except Exception as err:
       print(err)

and i get this error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/matiasjunemann/Documents/Repositories/inti-tech/penv/lib/python3.6/site-packages/serial/serialposix.py", line 483, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Basically I traced the error that the serial port it's getting closed twice on digi.xbee.device.py line 1285 and in digi.xbee.reader.py in line 327, when the reader its stop raises an exception and tries to close the serial port again.

You can see it from the logs off the library, if you comment line 1285 closing works fine.

2018-01-24 16:43:02,794 - digi.xbee.devices - INFO - /dev/tty.usbserial-DN02YVHY port opened
2018-01-24 16:43:02,794 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 01 41 50 65
2018-01-24 16:43:02,818 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 06 88 01 41 50 00 01 E4
2018-01-24 16:43:02,818 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 02 48 56 57
2018-01-24 16:43:02,851 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 07 88 02 48 56 00 2E 48 61
2018-01-24 16:43:02,852 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 03 56 52 4C
2018-01-24 16:43:02,882 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 07 88 03 56 52 00 40 59 33
2018-01-24 16:43:02,883 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 04 53 48 58
2018-01-24 16:43:02,914 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 09 88 04 53 48 00 00 13 A2 00 23
2018-01-24 16:43:02,915 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 05 53 4C 53
2018-01-24 16:43:02,946 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 09 88 05 53 4C 00 41 5B 8C 17 94
2018-01-24 16:43:02,948 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 06 4E 49 5A
2018-01-24 16:43:02,978 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 07 88 06 4E 49 00 43 31 66
2018-01-24 16:43:02,979 - digi.xbee.devices - DEBUG - /dev/tty.usbserial-DN02YVHYSENT        OperatingMode.API_MODE7E 00 04 08 07 4D 59 4A
2018-01-24 16:43:03,009 - digi.xbee.reader - DEBUG - /dev/tty.usbserial-DN02YVHYRECEIVED    OperatingMode.API_MODE7E 00 07 88 07 4D 59 00 00 00 CA
1)
2018-01-24 16:43:03,116 - digi.xbee.devices - INFO - /dev/tty.usbserial-DN02YVHY port closed
Done
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/matiasjunemann/Documents/Repositories/inti-tech/penv/lib/python3.6/site-packages/serial/serialposix.py", line 483, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
OSError: [Errno 9] Bad file descriptor

I don't know if is intended or i missing something.

digi.xbee.exception.InvalidOperatingModeException: Unsupported operating mode: AT mode

I have 3 XBees s1 all configured in API mode with one coordinator and 2 end device and I'm tring to send data explcitly to one of the bees.I'm using XCTU to visualise the data recieved in which both my end devices have the serial connection closed.

My code is as follows :

from digi.xbee.devices import *

Instantiate a XBee object
server = XBeeDevice("COM4",115200)

Open a port for communication
server.open()

Instantiate a remote object
thanos = RemoteXBeeDevice(server,XBee64BitAddress.from_hex_string("0013A2004103D949"))
hulk = RemoteXBeeDevice(server,XBee64BitAddress.from_hex_string("0013A2004103D932"))

Message to be sent to the bot
server._send_expl_data(thanos,0xA0, 0xA1, 0x1554, 0xC105, "Iron Man")
time.sleep(2)

Close the communication port
server.close()

But i get the error :

Traceback (most recent call last):
File "explicit_data_bee.py", line 8, in
server.open()
File "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\digi\xbee\devices.py", line 1262, in open
raise InvalidOperatingModeException.from_operating_mode(self._operating_mode)
digi.xbee.exception.InvalidOperatingModeException: Unsupported operating mode: AT mode

But both all my Xbees are in API mode only.

Any help is appreciated.

AttributeError exception with enum.py module python3.7

Traceback (most recent call last): File "/Users/kmuza/Aquicore/repos/asmund/pc_dfu/update.py", line 181, in main print(remote_pinout.get_micro_selected()) File "/Users/kmuza/Aquicore/repos/asmund/pc_dfu/gpio_control.py", line 29, in get_micro_selected return self.remote_xbee_sx.get_io_configuration(STM_XBEE_MUX) File "/Users/kmuza/venvs/asmund3.7/lib/python3.7/site-packages/digi/xbee/devices.py", line 645, in get_io_configuration mode = IOMode.get(self.get_parameter(io_line.at_command)[0]) File "/Users/kmuza/.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/enum.py", line 348, in __getattr__ raise AttributeError(name) from None AttributeError: get

Getting an exception when trying to get_io_configuration from a remote xbee.
Using get_dio_value seems to be working fine though

won't work with python2.7

Hello,
This library is not working with python2.7
is this library meant for only python3,is there any other library for 2.7

digi.xbee.exception.InvalidOperatingModeException: Unsupported operating mode: AT mode

I'm trying to use this on a Macbook using Python3. I have verified that the AP parameter is set to API Enabled [1] in XCTU. When I try to run the following code:

from digi.xbee.devices import XBeeDevice

device = XBeeDevice('/dev/tty.usbserial-AL02DVXW', 115200)

device.open()

while True:
    xbee_message = device.read_data()
    
    print(xbee_message)

I get digi.xbee.exception.InvalidOperatingModeException: Unsupported operating mode: AT mode even though it is in API enabled [1]. Any help is appreciated.

PacketListener does not handle length or frame-type fields being escaped

When using API mode 2 (escaped API mode), if either byte of the length field is escaped, then an incoming frame will either be misinterpreted (if the 4th byte happens to be a valid API frame type) or rejected.

Much like in #13, the issue lies in PacketListener.__try_read_packet:

            packet_length = self.__serial_port.read_bytes(2)
            # Add packet length.
            xbee_packet += packet_length
            length = utils.length_to_int(packet_length)

The above code does not account for the fact that either byte (realistically, the second byte) of the length field might be escaped, in which case we will miscalculate the packet length.

In addition to this, the factory.build_frame function, and most if not all create_packet functions for different frame types, assumes that packet_bytearray begins with 0x7E <length_msb> <length_lsb> <frame_type>, which is not necessarily true when in API escaped mode.

send source route frame

I create source route frame data structure as a string (the sequence of data explained in XBee manual) in python and I need to send it to xbee module through UART. I do not know how to do it, which class or function in XBee python library can perform it.

Timeout in IOSample callback

Hello !
I am trying to set a remote digital output each time an IOSample is received through a callback but I get a Timeout exception on set_io_configuration. Is the callback restricted ? I have a Digital IO Change Detection on DIO2 and I try to set DIO1 high or low.
I am using two Xbee3 RF micro in API1 mode, with the local one connected to a Raspberry Pi. The firmware version is 1003 with Zigbee protocol and here is my code.

from digi.xbee.devices import XBeeDevice, RemoteXBeeDevice
from digi.xbee.io import IOLine, IOMode
from digi.xbee.models.address import XBee64BitAddress

class SampleCallBackTest:

    def __init__(self):
        self.state = 0
        self.baseXbee = XBeeDevice("/dev/serial0", 115200)
        self.baseXbee.open()
        self.baseXbee.add_io_sample_received_callback(self.ioSampleCallback)
        self.remoteXbeeDev = RemoteXBeeDevice(self.baseXbee, XBee64BitAddress.from_hex_string(REMOTE_XBEE_ADDRESS))
        #self.baseXbee.set_sync_ops_timeout(5)

    def ioSampleCallback(self, ioSample, remoteXbee, sendTime):
        if self.state:
            remoteXbee.set_io_configuration(IOLine.DIO1_AD1, IOMode.DIGITAL_OUT_LOW)
            self.state = 0
        else:
            remoteXbee.set_io_configuration(IOLine.DIO1_AD1, IOMode.DIGITAL_OUT_HIGH)
            self.state = 1

sample = SampleCallBackTest()

Response not received :Timeout exception

Hi,
I am getting a Timeout exception("Response not received in the configured timeout") error.
I am trying out the basic example of SendDataSample.py. I am using 2 Xbee pro Series 1 and the firmware version is 10ec. The python version is 3.6 and the xbee library version is 1.1.1.
These are the errors :
......python-xbee/examples/communication/SendDataSample/SendDataSample.py", line 45, in main
device.send_data(remote_device, DATA_TO_SEND).
......lib\site-packages\digi\xbee\devices.py", line 1544, in send_data
return self._send_data_64(remote_xbee_device.get_64bit_addr(), data, transmit_options).
......\lib\site-packages\digi\xbee\devices.py", line 1028, in dec_function
return func(self, *args, **kwargs).
.....lib\site-packages\digi\xbee\devices.py", line 1038, in dec_function
response = func(*args, **kwargs).
....site-packages\digi\xbee\devices.py", line 1446, in _send_data_64
return self.send_packet_sync_and_get_response(packet).
.....lib\site-packages\digi\xbee\devices.py", line 2423, in send_packet_sync_and_get_response
raise TimeoutException("Response not received in the configured timeout.")
digi.xbee.exception.TimeoutException.

Disable printing serial bytes to console

The library prints every serial message like so:

/dev/ttyUSB0RECEIVED    OperatingMode.API_MODE7E 00 05 88 09 4E 49 00 D7                        
DEBUG:digi.xbee.reader:/dev/ttyUSB0RECEIVED    OperatingMode.API_MODE7E 00 05 88 09 4E 49 00 D7

This interferes with the program interface and it appears to cause high CPU usage when a lot of packets are being transmitted. Is there a way to disable this output?

Locla device serial port keeps closing

On Ubuntu Linux with a Series-2 device in Coordinator mode connected via a USB adapter.
xbee = ZigBeeDevice('/dev/Zigbee', 9600 ) xbee.open()
I do a few operations, which work fine, including
xbee.send_data( remote, data )
But the next time I do send_data I get this exception:
XBee device's serial port closed

What can cause the serial port to close behind my back?

Sometimes this turns up on a remote operation, such as
remote.set_parameter( code, value )
in which case the exception becomes Local XBee device's serial port is closed.

Installing into a python3 virtualenv

Hi all,
Love this library, thank you.

I setup a python virtual environment running v3.5.3. When I run pip to install the library, it still errors with python version must be v3. My system level python install is 2.7. I am running debian 9 and when I check the python version in the virtualenv, it does come up as 3.5.3.

Thank you very much

Missing support for "Route Information"(0x8D) and "Aggregate Addressing Update"(0x8E) messages

The "Route Information"(0x8D) and "Aggregate Addressing Update"(0x8E) messages do not have support in the library. To add them, the following files would need modification:
aft.py (in class ApiFrameType); in factory.py(in function build_frame); in common.py (missing classes); in reader.py(in class PacketListener, and method __execute_user_callbacks); devices.py (in class XbeeDevice)

And there needs to have the methods added (such as):
"add_route_info_received_callback", "del_route_info_received_callback", "add_agr_addr_update_callback", and "del_agr_addr_update_callback".

Change _DEFAULT_TIMEOUT_SYNC_OPERATIONS Digimesh

Hi All,

I am trying to properly change the default timeout for sending data with Digimesh as done in the example here: SendDataSample.py.

It sends the data fine, however when the device is new in the network or the address is not found it will always returns a digi.xbee.exception.TimeoutException. But in the logs I see the Digimesh network replies its own error code, just a little later.

Moreover, if I alter the _DEFAULT_TIMEOUT_SYNC_OPERATIONS in devices.py up two seconds (6). I get a nice error report digi.xbee.exception.XBeeException: Transmit status: Route not found.

This is what I like to see. Unfortunately, there is no where to set the time out. Searching the code and the documentation didn't give any answers to this.

Where can we set this timeout?

Much appreciated,
Fokko

source and dest endpoint identical

in the explicit message object passed to the explicit data received callback, the "source_endpoint" and "dest_endpoint" are the same. It appears that the source endpoint is being copied from the dest_endpoint

i.e. in the following both printed values are identical

def my_expl_data_received_callback(explicit_xbee_message):
         LOGGER.info("Source endpoint:        %s"
                 % utils.hex_to_string(utils.int_to_length(explicit_xbee_message.source_endpoint)))
         LOGGER.info("Destination endpoint:   %s"
                 % utils.hex_to_string(utils.int_to_length(explicit_xbee_message.dest_endpoint)))

Wrong checksum exception

_check_api_packet in base.py throws an exception when receiving a bad checksum.

2 questions:
How do I catch this exception and ignore it? (the run method in reader.py doesn't seem to be something I can put a try / except around in my code)
Why is this even an exception? (I.e. Since the message is corrupt why not just throw it away and move on instead of throwing an exception?)

If necessary I'll modify my local version of reader.py but I would hate to do that...

[FEATURE REQUEST] if block in PacketListener.__add_packet_queue should be elif

See the first two if blocks in this code segment

if xbee_packet.get_frame_type() in [ApiFrameType.RECEIVE_PACKET, ApiFrameType.RX_64, ApiFrameType.RX_16]:
    if self.__data_xbee_queue.full():
        self.__data_xbee_queue.get()
    self.__data_xbee_queue.put_nowait(xbee_packet)
# Explicit packets.
if xbee_packet.get_frame_type() == ApiFrameType.EXPLICIT_RX_INDICATOR:
    if self.__explicit_xbee_queue.full():
        self.__explicit_xbee_queue.get()
    self.__explicit_xbee_queue.put_nowait(xbee_packet)
    # Check if the explicit packet is 'special'.
    if self.__is_special_explicit_packet(xbee_packet):
        # Create the non-explicit version of this packet and add it to the queue.
        self.__add_packet_queue(self.__expl_to_no_expl(xbee_packet))
# IP packets.
elif xbee_packet.get_frame_type() == ApiFrameType.RX_IPV4:
...

The conditions for the first and second if statements are mutually exclusive, so the second can be changed to elif for optimal performance.

ModemStatus enum is missing values for Remote Manager connect/disconnect

On XBee Wi-Fi and XBee Cellular devices, modem status frames with values 0xE and 0xF (Remote Manager connected and disconnected, respectively) will be output when the Remote Manager connection is established or is dropped.

This library does not understand those values, and so in the logs we see messages such as:

2017-11-22 10:44:32,510: digi.xbee.reader: DEBUG: /dev/xbibRECEIVED    OperatingMode.API_MODE7E 00 02 8A 0E 67                                 
2017-11-22 10:44:32,511: digi.xbee.reader: INFO: /dev/xbibRECEIVED    MODEM STATUSNone              ModemStatus.UNKNOWN

Device is not listed with encryption enabled

I am using the xbee zigbee PRO dev kit and things are working great when EE is set to Disabled [0].

Changing EE to Enabled [1], however, causes the remote nodes not to be listed in the local_device.get_network() process. Using XCTU, the nodes and master are able to list out all the devices though.

Is there a bug in the SDK?

"Protocol cannot be None" when decoding RX IPv4 frame in escaped API mode

Seen when testing sending UDP packets from an XBee Cellular 3G unit to our loopback service, using escaped API mode.

2018-01-05 16:59:15,872 digi.xbee.reader: DEBUG: /dev/xbib2RECEIVED    OperatingMode.ESCAPED_API_MODE7E 04 0B B0 34 2B 79 4D 00 00 27 7D 31 00 00 3B 0A 7D 5D 71 49 4D 6C 4C 5A 7C 78 66 71 5B 75 45 39 7C 75 21 7D 5D 74 30 7A 4E 4D 28 39 28 24 70 2A 47 3B 69 78 33 36 68 42 65 28 70 52 42 4D 74 4F 6C 75 21 22 53 2E 5E 2E 0A 48 70 5F 3A 2D 4B 4D 09 0C 56 61 30 3D 51 52 5B 76 66 7A 31 2E 4B 66 69 2B 2D 44 6F 76 48 45 3A 7D 5E 09 58 25 69 20 5E 5F 29 4D 46 46 0B 45 47 3D 4A 4C 3F 77 76 0D 4F 0A 33 5E 40 36 67 72 60 7A 52 49 38 5E 0D 34 59 63 2E 43 31 6A 37 3E 22 3D 33 48 4E 35 41 2B 71 25 30 65 45 5E 7D 5D 6A 0D 6A 2B 46 0C 43 73 6A 64 72 6B 4F 31 26 65 52 2D 68 73 33 62 38 38 25 26 2B 48 29 65 3F 0B 73 6B 2F 26 72 4F 3D 3D 4B 24 6A 3E 58 55 39 63 4F 0B 64 4C 45 23 37 58 6D 56 30 2F 41 6D 3D 53 38 42 6E 71 42 5B 65 54 7D 5E 3B 49 3F 37 4C 45 4D 47 7D 5D 66 46 73 44 6A 64 79 7D 5E 4F 66 09 75 7D 5E 56 2E 57 65 32 5A 55 26 4A 60 23 47 79 76 38 72 7A 45 0A 54 2D 3C 71 09 3C 0C 6C 7B 40 4E 43 77 75 50 0B 48 69 22 7A 66 44 2D 61 0C 6A 7D 5D 66 6E 66 79 61 40 48 0B 6D 3E 20 21 72 44 31 39 40 4F 20 3D 52 5C 28 6E 24 52 7C 4B 43 33 52 6D 46 62 45 35 53 77 0B 2C 40 2F 09 60 24 2A 72 09 78 7D 5D 53 35 28 48 34 64 79 36 62 4D 65 52 3E 34 7C 48 44 36 23 7B 09 46 55 36 6E 63 4E 30 66 34 3D 45 51 29 23 61 2E 3A 2D 3A 23 6C 2C 3F 4D 62 7D 5D 28 3C 7B 70 5D 4E 29 59 4A 40 72 49 5C 33 36 36 5E 4A 25 66 78 6C 4D 29 63 53 54 0A 57 38 45 58 22 2F 2F 51 78 32 4B 57 35 55 4D 75 60 5C 51 33 73 70 3A 52 7C 3B 2A 40 5E 79 73 3C 40 3D 0C 3F 35 3F 4C 26 44 36 45 46 75 39 52 42 5A 21 65 59 34 3B 25 43 4C 38 48 56 37 52 6D 4E 70 3F 71 39 5D 63 61 4A 5C 47 6F 32 7A 56 6E 7D 5E 48 59 39 6A 29 2E 6E 4D 75 69 5D 6E 3C 4B 33 71 75 6F 72 6E 29 27 73 60 5B 5A 77 6D 4A 5C 52 59 6C 61 2A 56 60 3C 79 2D 35 5C 35 25 27 71 64 0C 4B 3F 69 46 6F 33 75 52 51 2F 2F 0B 73 59 42 4D 40 0D 46 61 33 56 5C 35 0A 54 42 42 49 6E 51 5D 7D 5D 69 3E 3C 44 39 3D 58 28 5E 46 68 67 71 7D 5E 40 34 4F 7D 5E 63 7D 5E 4D 2C 50 22 4C 48 48 49 74 0B 72 54 49 71 7D 5D 2C 46 54 48 4A 69 6F 38 6E 6F 74 5F 57 33 25 28 4C 62 2E 29 5E 54 39 51 2B 34 5A 57 55 3C 49 72 6D 67 61 68 2C 4E 40 3B 74 57 6B 09 21 74 2D 4E 62 79 28 56 58 59 2A 54 29 62 4C 4B 55 60 75 73 3C 25 0C 3D 58 35 57 39 36 7C 69 3F 6A 6B 63 37 31 6C 4B 70 77 70 0B 23 0D 2D 51 5A 68 45 0D 58 21 6C 61 52 64 49 29 49 37 22 3F 3D 72 3E 4E 45 52 58 59 6D 6C 4C 0A 0B 60 35 44 33 3D 4D 3E 4F 33 71 29 3A 3E 32 58 2B 3A 3C 43 77 72 09 28 3A 2E 21 3E 50 7A 76 41 78 6F 62 09 68 53 56 4A 63 4B 70 68 7B 43 70 3A 6C 40 4B 45 46 7D 5D 5F 4B 2B 35 6F 28 77 3C 70 33 0A 4A 53 77 5F 4B 38 23 3D 50 69 7A 68 7D 5D 7D 5D 4F 2A 58 35 2C 46 65 2B 34 49 43 3D 7C 24 61 21 51 62 62 6C 64 2B 2C 64 61 2D 46 24 23 21 70 25 63 61 63 61 2D 64 40 4A 4D 36 27 45 62 3F 5E 43 32 0D 4B 69 5D 0C 43 37 5C 57 54 6A 6D 5A 50 7D 5E 70 57 74 67 23 22 45 79 70 6C 27 66 6D 56 35 38 60 6A 62 30 79 6B 38 38 41 6C 6E 6E 5F 3D 4E 6D 28 35 48 46 62 5E 68 4C 77 7D 5D 41 20 6F 0B 53 36 6A 77 47 42 43 53 09 25 72 53 61 69 3F 77 3E 6A 5B 2B 40 7D 5D 32 34 5B 66 7D 5E 40 37 54 0C 5D 4F 3B 28 5E 6F 4E 09 20 0A 5C 63 51 23 36 24 33 2E 59 72 70 3E 2F 6B 4F 70 5B 68 6F 40 7D 5D 68 29 4D 3C 5E 51 37 68 6C 6E 2B 74 5B 49 09 55 48 42 2C 75 2B 6E 79 32 43 53 68 77 41 66 38 31 43 37 5D 7B 73 5D 5A 6A 20 36 EE
2018-01-05 16:59:15,891 digi.xbee.reader: ERROR: Protocol cannot be None
Traceback (most recent call last):
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/reader.py", line 325, in run
    self.__execute_user_callbacks(read_packet, remote)
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/reader.py", line 612, in __execute_user_callbacks
    xbee_packet.dest_port, xbee_packet.ip_protocol, xbee_packet.data))
  File "/home/mike/.envs/env/src/digi-xbee/digi/xbee/models/message.py", line 247, in __init__
    raise ValueError("Protocol cannot be None")
ValueError: Protocol cannot be None

This error does not appear when using normal API mode, and also this frame is decoded by XCTU just fine.

This is when using the master version (840c024) after doing pip3 install -e git://github.com/digidotcom/python-xbee#egg=digi-xbee.

ImportError: cannot import name unique

Just launching "DiscoverDevicesSample.py"

File "DiscoverDevicesSample.py", line 17, in <module> from digi.xbee.models.status import NetworkDiscoveryStatus File "/usr/local/lib/python2.7/dist-packages/digi/xbee/models/status.py", line 15, in <module> from enum import Enum, unique ImportError: cannot import name unique

Join notification of ZigBee device

Hi,
if I start the discovery the Zigbee devices that are currently powered and connected to the network are correctly detected.
But if a device is "turned on" after the discovery process I don't receive the "join notification".
How can I capture this notification?
Thanks

Logger prints multiple times

Hi,

I have a bit of strange issue. When I run my application the logger prints lines multiple times. For instance after while when I close my application:

/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed
/dev/tty.usbserial-1420 port closed

Even the last message I received was printed 7 times. As my program runs longer this number increases.

I checked, by adding some debug printing in the library, and the printed message is actually logged once but printed multiple times. And my program isn't leaking any memory or something. So everything does look fine.

I have been searching on it a little bit and the internet is full of the same questions regarding python logger. Like (stackoverflow):

So every time you instantiate your class you add new handlers to the logger and every handler prints a line.

Any idea how to solve this? Do you think this issue be related to having multiple logger handlers?

Thanks,
Fokko

Cannot exit thread with device.close()

I started with python-xbee/examples/communication/ReceiveDataPollingSample/ReceiveDataPollingSample.py example by adding


while True:
            xbee_message = device.read_data()
            if xbee_message is not None:
                print("From %s >> %s" % (xbee_message.remote_device.get_64bit_addr(),
                                         xbee_message.data.decode()))
                device.close()
                break

The code hang after received a message even though I tried to close device and break from while loop. I have to ctrl-c to exit

Then I got below message:

Exception ignored in: <module 'threading' from '/usr/lib/python3.5/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 1288, in _shutdown
    t.join()
  File "/usr/lib/python3.5/threading.py", line 1054, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.5/threading.py", line 1070, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
KeyboardInterrupt

Any suggestion on how I can solve this?

Regarding setting parameters on a remote Xbee from a local Xbee

Hi,
I am using 2 series 1 XBee pro modules. One is on the explorer board from sparkfun ,which is my local Xbee module. Both these are connected to my computer comports. The firmware version is 10ec and both are configured as 802.15.4 devices.
Now I am using the python API to set parameters in the remote XBee from my local XBee device. I follow the SetAndGetParametersSample.py. This is what I try to do.

REMOTE_NODE_ID="REMOTE"
device = XBeeDevice(PORT, BAUD_RATE) #Local Xbee
try:
device.open()
print(device)
xbee_network = device.get_network()
remote_device = xbee_network.discover_device(REMOTE_NODE_ID)
# Set parameters.
remote_device.set_parameter("DH",utils.hex_string_to_bytes("XXXXXX"))
remote_device.set_parameter("DL",utils.hex_string_to_bytes("xxxxxxxx"))

I get a timeout exception error.
I use python 3.6 . I would like to know if this is even possible to do it this way? I am a beginner in this area, so any help would be useful. If this is not the way then could anyone tell me how the remote parameters can be set from a local device?

Related Errors:
SetAndGetParametersSample/parameter.py", line 58, in main
remote_device.set_parameter("DH",utils.hex_string_to_bytes("xxxxxx"))

\digi\xbee\devices.py", line 4805, in set_parameter
response = self._local_xbee_device.send_packet_sync_and_get_response(packet_to_send)

digi\xbee\devices.py", line 2423, in send_packet_sync_and_get_response
raise TimeoutException("Response not received in the configured timeout.")
digi.xbee.exception.TimeoutException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.