digi.xbee.reader module

class digi.xbee.reader.XBeeEvent[source]

Bases: list

This class represents a generic XBee event.

New event callbacks can be added here following this prototype:

def callback_prototype(*args, **kwargs):
    #do something...

All of them will be executed when the event is fired.

See also

list (Python standard class)
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.PacketReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives any packet, independent of its frame type.

The callbacks for handle this events will receive the following arguments:
  1. received_packet (XBeeAPIPacket): the received packet.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.DataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives data.

The callbacks for handle this events will receive the following arguments:
  1. message (XBeeMessage): message containing the data received, the sender and the time.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.ModemStatusReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a XBee receives a modem status packet.

The callbacks for handle this events will receive the following arguments:
  1. modem_status (ModemStatus): the modem status received.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.IOSampleReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when a XBee receives an IO packet.

This includes:

  1. IO data sample RX indicator packet.
  2. RX IO 16 packet.
  3. RX IO 64 packet.
The callbacks that handle this event will receive the following arguments:
  1. io_sample (IOSample): the received IO sample.
  2. sender (RemoteXBeeDevice): the remote XBee device who has sent the packet.
  3. time (Integer): the time in which the packet was received.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.NetworkModified[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when the network is being modified by the addition of a new node, an existing node information is updated, a node removal, or when the network items are cleared.

The callbacks that handle this event will receive the following arguments:
  1. event_type (digi.xbee.devices.NetworkEventType): the network event type.
  2. reason (digi.xbee.devices.NetworkEventReason): The reason of the event.
  3. node (digi.xbee.devices.XBeeDevice or digi.xbee.devices.RemoteXBeeDevice): The node added, updated or removed from the network.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.DeviceDiscovered[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee discovers another remote XBee during a discovering operation.

The callbacks that handle this event will receive the following arguments:
  1. discovered_device (RemoteXBeeDevice): the discovered remote XBee device.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.DiscoveryProcessFinished[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when the discovery process finishes, either successfully or due to an error.

The callbacks that handle this event will receive the following arguments:
  1. status (NetworkDiscoveryStatus): the network discovery status.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.ExplicitDataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives an explicit data packet.

The callbacks for handle this events will receive the following arguments:
  1. message (ExplicitXBeeMessage): message containing the data received, the sender, the time
    and explicit data message parameters.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.IPDataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives IP data.

The callbacks for handle this events will receive the following arguments:
  1. message (IPMessage): message containing containing the IP address the message
    belongs to, the source and destination ports, the IP protocol, and the content (data) of the message.

See also

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.SMSReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives an SMS.

The callbacks for handle this events will receive the following arguments:
  1. message (SMSMessage): message containing the phone number that sent
    the message and the content (data) of the message.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.RelayDataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives a user data relay output packet.

The callbacks to handle these events will receive the following arguments:
  1. message (UserDataRelayMessage): message containing the source interface
    and the content (data) of the message.
append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.BluetoothDataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives data from the Bluetooth interface.

The callbacks to handle these events will receive the following arguments:
  1. data (Bytearray): received Bluetooth data.

See also

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.MicroPythonDataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives data from the MicroPython interface.

The callbacks to handle these events will receive the following arguments:
  1. data (Bytearray): received MicroPython data.

See also

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.SocketStateReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives a socket state packet.

The callbacks to handle these events will receive the following arguments:
  1. socket_id (Integer): socket ID for state reported.
  2. state (SocketState): received state.

See also

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.SocketDataReceived[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives a socket receive data packet.

The callbacks to handle these events will receive the following arguments:
  1. socket_id (Integer): ID of the socket that received the data.
  2. payload (Bytearray): received data.

See also

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.SocketDataReceivedFrom[source]

Bases: digi.xbee.reader.XBeeEvent

This event is fired when an XBee receives a socket receive from data packet.

The callbacks to handle these events will receive the following arguments:
  1. socket_id (Integer): ID of the socket that received the data.
  2. address (Tuple): a pair (host, port) of the source address where
    host is a string representing an IPv4 address like ‘100.50.200.5’, and port is an integer.
  3. payload (Bytearray): received data.

See also

append()

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count()

Return number of occurrences of value.

extend()

Extend list by appending elements from the iterable.

index()

Return first index of value.

Raises ValueError if the value is not present.

insert()

Insert object before index.

pop()

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove()

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse IN PLACE.

sort()

Stable sort IN PLACE.

class digi.xbee.reader.PacketListener(comm_iface, xbee_device, queue_max_size=None)[source]

Bases: threading.Thread

This class represents a packet listener, which is a thread that’s always listening for incoming packets to the XBee.

When it receives a packet, this class throws an event depending on which packet it is. You can add your own callbacks for this events via certain class methods. This callbacks must have a certain header, see each event documentation.

This class has fields that are events. Its recommended to use only the append() and remove() method on them, or -= and += operators. If you do something more with them, it’s for your own risk.

Here are the parameters which will be received by the event callbacks, depending on which event it is in each case:

The following parameters are passed via **kwargs to event callbacks of:

  1. PacketReceived:
    1.1 received_packet (XBeeAPIPacket): the received packet.
  2. DataReceived
    2.1 message (XBeeMessage): message containing the data received, the sender and the time.
  3. ModemStatusReceived
    3.1 modem_status (ModemStatus): the modem status received.

Class constructor. Instantiates a new PacketListener object with the provided parameters.

Parameters:
  • comm_iface (XBeeCommunicationInterface) – the hardware interface to listen to.
  • xbee_device (XBeeDevice) – the XBee that is the listener owner.
  • queue_max_size (Integer) – the maximum size of the XBee queue.
daemon

A boolean value indicating whether this thread is a daemon thread.

This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.

The entire Python program exits when only daemon threads are left.

wait_until_started(timeout=None)[source]

Blocks until the thread has fully started. If already started, returns immediately.

Parameters:timeout (Float) – timeout for the operation in seconds.
run()[source]

This is the method that will be executing for listening packets.

For each packet, it will execute the proper callbacks.

stop()[source]

Stops listening.

is_running()[source]

Returns whether this instance is running or not.

Returns:True if this instance is running, False otherwise.
Return type:Boolean
get_queue()[source]

Returns the packets queue.

Returns:the packets queue.
Return type:XBeeQueue
get_data_queue()[source]

Returns the data packets queue.

Returns:the data packets queue.
Return type:XBeeQueue
get_explicit_queue()[source]

Returns the explicit packets queue.

Returns:the explicit packets queue.
Return type:XBeeQueue
get_ip_queue()[source]

Returns the IP packets queue.

Returns:the IP packets queue.
Return type:XBeeQueue
add_packet_received_callback(callback)[source]

Adds a callback for the event PacketReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives two arguments.

add_data_received_callback(callback)[source]

Adds a callback for the event DataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

add_modem_status_received_callback(callback)[source]

Adds a callback for the event ModemStatusReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

add_io_sample_received_callback(callback)[source]

Adds a callback for the event IOSampleReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives three arguments.

  • The received IO sample as an IOSample
  • The remote XBee device who has sent the packet as a RemoteXBeeDevice
  • The time in which the packet was received as an Integer
add_explicit_data_received_callback(callback)[source]

Adds a callback for the event ExplicitDataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

add_ip_data_received_callback(callback)[source]

Adds a callback for the event IPDataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

add_sms_received_callback(callback)[source]

Adds a callback for the event SMSReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

add_user_data_relay_received_callback(callback)[source]

Adds a callback for the event RelayDataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

add_bluetooth_data_received_callback(callback)[source]

Adds a callback for the event BluetoothDataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

  • The data received as a Bytearray
add_micropython_data_received_callback(callback)[source]

Adds a callback for the event MicroPythonDataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives one argument.

  • The data received as a Bytearray
add_socket_state_received_callback(callback)[source]

Adds a callback for the event SocketStateReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The state received as a SocketState
add_socket_data_received_callback(callback)[source]

Adds a callback for the event SocketDataReceived.

Parameters:callback (Function or List of functions) –

the callback. Receives two arguments.

  • The socket ID as an Integer.
  • The status received as a SocketStatus
add_socket_data_received_from_callback(callback)[source]

Adds a callback for the event SocketDataReceivedFrom.

Parameters:callback (Function or List of functions) –

the callback. Receives three arguments.

  • The socket ID as an Integer.
  • A pair (host, port) of the source address where host is a string representing an IPv4 address
    like ‘100.50.200.5’, and port is an integer.
  • The status received as a SocketStatus
del_packet_received_callback(callback)[source]

Deletes a callback for the callback list of PacketReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of PacketReceived event.
del_data_received_callback(callback)[source]

Deletes a callback for the callback list of DataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of DataReceived event.
del_modem_status_received_callback(callback)[source]

Deletes a callback for the callback list of ModemStatusReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of ModemStatusReceived event.
del_io_sample_received_callback(callback)[source]

Deletes a callback for the callback list of IOSampleReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of IOSampleReceived event.
del_explicit_data_received_callback(callback)[source]

Deletes a callback for the callback list of ExplicitDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of ExplicitDataReceived event.
del_ip_data_received_callback(callback)[source]

Deletes a callback for the callback list of IPDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of IPDataReceived event.
del_sms_received_callback(callback)[source]

Deletes a callback for the callback list of SMSReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of SMSReceived event.
del_user_data_relay_received_callback(callback)[source]

Deletes a callback for the callback list of RelayDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of RelayDataReceived event.
del_bluetooth_data_received_callback(callback)[source]

Deletes a callback for the callback list of BluetoothDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of BluetoothDataReceived event.
del_micropython_data_received_callback(callback)[source]

Deletes a callback for the callback list of MicroPythonDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of MicroPythonDataReceived event.
del_socket_state_received_callback(callback)[source]

Deletes a callback for the callback list of SocketStateReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of SocketStateReceived event.
del_socket_data_received_callback(callback)[source]

Deletes a callback for the callback list of SocketDataReceived event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of SocketDataReceived event.
del_socket_data_received_from_callback(callback)[source]

Deletes a callback for the callback list of SocketDataReceivedFrom event.

Parameters:callback (Function) – the callback to delete.
Raises:ValueError – if callback is not in the callback list of SocketDataReceivedFrom event.
get_packet_received_callbacks()[source]

Returns the list of registered callbacks for received packets.

Returns:List of PacketReceived events.
Return type:List
get_data_received_callbacks()[source]

Returns the list of registered callbacks for received data.

Returns:List of DataReceived events.
Return type:List
get_modem_status_received_callbacks()[source]

Returns the list of registered callbacks for received modem status.

Returns:List of ModemStatusReceived events.
Return type:List
get_io_sample_received_callbacks()[source]

Returns the list of registered callbacks for received IO samples.

Returns:List of IOSampleReceived events.
Return type:List
get_explicit_data_received_callbacks()[source]

Returns the list of registered callbacks for received explicit data.

Returns:List of ExplicitDataReceived events.
Return type:List
get_ip_data_received_callbacks()[source]

Returns the list of registered callbacks for received IP data.

Returns:List of IPDataReceived events.
Return type:List
get_sms_received_callbacks()[source]

Returns the list of registered callbacks for received SMS.

Returns:List of SMSReceived events.
Return type:List
get_user_data_relay_received_callbacks()[source]

Returns the list of registered callbacks for received user data relay.

Returns:List of RelayDataReceived events.
Return type:List
get_bluetooth_data_received_callbacks()[source]

Returns the list of registered callbacks for received Bluetooth data.

Returns:List of BluetoothDataReceived events.
Return type:List
get_micropython_data_received_callbacks()[source]

Returns the list of registered callbacks for received micropython data.

Returns:List of MicroPythonDataReceived events.
Return type:List
ident

Thread identifier of this thread or None if it has not been started.

This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.

isAlive()

Return whether the thread is alive.

This method is deprecated, use is_alive() instead.

is_alive()

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.

join(timeout=None)

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

name

A string used for identification purposes only.

It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.

start()

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

class digi.xbee.reader.XBeeQueue(maxsize=10)[source]

Bases: queue.Queue

This class represents an XBee queue.

Class constructor. Instantiates a new XBeeQueue with the provided parameters.

Parameters:(Integer, default (maxsize) –
  1. the maximum size of the queue.
get(block=True, timeout=None)[source]

Returns the first element of the queue if there is some element ready before timeout expires, in case of the timeout is not None.

If timeout is None, this method is non-blocking. In this case, if there isn’t any element available, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters:
  • block (Boolean) – True to block during timeout waiting for a packet, False to not block.
  • timeout (Integer, optional) – timeout in seconds.
Returns:

a packet if there is any packet available before timeout expires.

If timeout is None, the returned value may be None.

Return type:

XBeeAPIPacket

Raises:

TimeoutException – if timeout is not None and there isn’t any packet available before the timeout expires.

get_by_remote(remote_xbee_device, timeout=None)[source]

Returns the first element of the queue that had been sent by remote_xbee_device, if there is some in the specified timeout.

If timeout is None, this method is non-blocking. In this case, if there isn’t any packet sent by remote_xbee_device in the queue, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters:
  • remote_xbee_device (RemoteXBeeDevice) – the remote XBee device to get its firs element from queue.
  • timeout (Integer, optional) – timeout in seconds.
Returns:

if there is any packet available before the timeout expires. If timeout is

None, the returned value may be None.

Return type:

XBeeAPIPacket

Raises:

TimeoutException – if timeout is not None and there isn’t any packet available that has been sent by remote_xbee_device before the timeout expires.

get_by_ip(ip_addr, timeout=None)[source]

Returns the first IP data packet from the queue whose IP address matches the provided address.

If timeout is None, this method is non-blocking. In this case, if there isn’t any packet sent by remote_xbee_device in the queue, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters:
  • ip_addr (ipaddress.IPv4Address) – The IP address to look for in the list of packets.
  • timeout (Integer, optional) – Timeout in seconds.
Returns:

if there is any packet available before the timeout expires. If timeout is

None, the returned value may be None.

Return type:

XBeeAPIPacket

Raises:

TimeoutException – if timeout is not None and there isn’t any packet available that has been sent by remote_xbee_device before the timeout expires.

get_by_id(frame_id, timeout=None)[source]

Returns the first packet from the queue whose frame ID matches the provided one.

If timeout is None, this method is non-blocking. In this case, if there isn’t any received packet with the provided frame ID in the queue, it returns None, otherwise it returns an XBeeAPIPacket.

Parameters:
  • frame_id (Integer) – The frame ID to look for in the list of packets.
  • timeout (Integer, optional) – Timeout in seconds.
Returns:

if there is any packet available before the timeout expires. If timeout is

None, the returned value may be None.

Return type:

XBeeAPIPacket

Raises:
  • TimeoutException – if timeout is not None and there isn’t any packet available that matches
  • the provided frame ID before the timeout expires.
empty()

Return True if the queue is empty, False otherwise (not reliable!).

This method is likely to be removed at some point. Use qsize() == 0 as a direct substitute, but be aware that either approach risks a race condition where a queue can grow before the result of empty() or qsize() can be used.

To create code that needs to wait for all queued tasks to be completed, the preferred technique is to use the join() method.

flush()[source]

Clears the queue.

full()

Return True if the queue is full, False otherwise (not reliable!).

This method is likely to be removed at some point. Use qsize() >= n as a direct substitute, but be aware that either approach risks a race condition where a queue can shrink before the result of full() or qsize() can be used.

get_nowait()

Remove and return an item from the queue without blocking.

Only get an item if one is immediately available. Otherwise raise the Empty exception.

join()

Blocks until all items in the Queue have been gotten and processed.

The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete.

When the count of unfinished tasks drops to zero, join() unblocks.

put(item, block=True, timeout=None)

Put an item into the queue.

If optional args ‘block’ is true and ‘timeout’ is None (the default), block if necessary until a free slot is available. If ‘timeout’ is a non-negative number, it blocks at most ‘timeout’ seconds and raises the Full exception if no free slot was available within that time. Otherwise (‘block’ is false), put an item on the queue if a free slot is immediately available, else raise the Full exception (‘timeout’ is ignored in that case).

put_nowait(item)

Put an item into the queue without blocking.

Only enqueue the item if a free slot is immediately available. Otherwise raise the Full exception.

qsize()

Return the approximate size of the queue (not reliable!).

task_done()

Indicate that a formerly enqueued task is complete.

Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.

If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue).

Raises a ValueError if called more times than there were items placed in the queue.