xbee::base::XBeeBase Class Reference
List of all members.
Detailed Description
Abstract base class providing command generation and response
parsing methods for XBee modules.
Constructor arguments:
ser: The file-like serial port to use.
shorthand: boolean flag which determines whether shorthand command
calls (i.e. xbee.at(...) instead of xbee.send("at",...)
are allowed.
callback: function which should be called with frame data
whenever a frame arrives from the serial port.
When this is not None, a background thread to monitor
the port and call the given function is automatically
started.
escaped: boolean flag which determines whether the library should
operate in escaped mode. In this mode, certain data bytes
in the output and input streams will be escaped and unescaped
in accordance with the XBee API. This setting must match
the appropriate api_mode setting of an XBee device; see your
XBee device's documentation for more information.
Definition at line 25 of file base.py.
Member Function Documentation
def xbee::base::XBeeBase::__getattr__ |
( |
|
self, |
|
|
|
name | |
|
) |
| | |
If a method by the name of a valid api command is called,
the arguments will be automatically sent to an appropriate
send() call
Definition at line 391 of file base.py.
def xbee::base::XBeeBase::__init__ |
( |
|
self, |
|
|
|
ser, |
|
|
|
shorthand = True , |
|
|
|
callback = None , |
|
|
|
escaped = False | |
|
) |
| | |
def xbee::base::XBeeBase::_build_command |
( |
|
self, |
|
|
|
cmd, |
|
|
|
kwargs | |
|
) |
| | [private] |
_build_command: string (binary data) ... -> binary data
_build_command will construct a command packet according to the
specified command's specification in api_commands. It will expect
named arguments for all fields other than those with a default
value or a length of 'None'.
Each field will be written out in the order they are defined
in the command definition.
Definition at line 145 of file base.py.
def xbee::base::XBeeBase::_parse_samples |
( |
|
self, |
|
|
|
io_bytes | |
|
) |
| | [private] |
_parse_samples: binary data in XBee IO data format ->
[ {"dio-0":True,
"dio-1":False,
"adc-0":100"}, ...]
_parse_samples reads binary data from an XBee device in the IO
data format specified by the API. It will then return a
dictionary indicating the status of each enabled IO port.
Definition at line 319 of file base.py.
def xbee::base::XBeeBase::_parse_samples_header |
( |
|
self, |
|
|
|
io_bytes | |
|
) |
| | [private] |
_parse_samples_header: binary data in XBee IO data format ->
(int, [int ...], [int ...], int, int)
_parse_samples_header will read the first three bytes of the
binary data given and will return the number of samples which
follow, a list of enabled digital inputs, a list of enabled
analog inputs, the dio_mask, and the size of the header in bytes
Reimplemented in xbee::zigbee::ZigBee.
Definition at line 280 of file base.py.
def xbee::base::XBeeBase::_split_response |
( |
|
self, |
|
|
|
data | |
|
) |
| | [private] |
_split_response: binary data -> {'id':str,
'param':binary data,
...}
_split_response takes a data packet received from an XBee device
and converts it into a dictionary. This dictionary provides
names for each segment of binary data as specified in the
api_responses spec.
Definition at line 200 of file base.py.
def xbee::base::XBeeBase::_wait_for_frame |
( |
|
self |
) |
[private] |
_wait_for_frame: None -> binary data
_wait_for_frame will read from the serial port until a valid
API frame arrives. It will then return the binary data
contained within the frame.
If this method is called as a separate thread
and self.thread_continue is set to False, the thread will
exit by raising a ThreadQuitException.
Definition at line 102 of file base.py.
def xbee::base::XBeeBase::_write |
( |
|
self, |
|
|
|
data | |
|
) |
| | [private] |
_write: binary data -> None
Packages the given binary data in an API frame and writes the
result to the serial port
Definition at line 78 of file base.py.
def xbee::base::XBeeBase::halt |
( |
|
self |
) |
|
halt: None -> None
If this instance has a separate thread running, it will be
halted. This method will wait until the thread has cleaned
up before returning.
Definition at line 66 of file base.py.
def xbee::base::XBeeBase::run |
( |
|
self |
) |
|
run: None -> None
This method overrides threading.Thread.run() and is automatically
called when an instance is created with threading enabled.
Definition at line 88 of file base.py.
def xbee::base::XBeeBase::send |
( |
|
self, |
|
|
|
cmd, |
|
|
|
kwargs | |
|
) |
| | |
send: string param=binary data ... -> None
When send is called with the proper arguments, an API command
will be written to the serial port for this XBee device
containing the proper instructions and data.
This method must be called with named arguments in accordance
with the api_command specification. Arguments matching all
field names other than those in reserved_names (like 'id' and
'order') should be given, unless they are of variable length
(of 'None' in the specification. Those are optional).
Definition at line 360 of file base.py.
def xbee::base::XBeeBase::wait_read_frame |
( |
|
self |
) |
|
wait_read_frame: None -> frame info dictionary
wait_read_frame calls XBee._wait_for_frame() and waits until a
valid frame appears on the serial port. Once it receives a frame,
wait_read_frame attempts to parse the data contained within it
and returns the resulting dictionary
Definition at line 378 of file base.py.
Member Data Documentation
The documentation for this class was generated from the following file: