Public Member Functions | |
def | __getattr__ (self, name) |
def | __init__ (self, ser, shorthand=True, callback=None, escaped=False) |
def | halt (self) |
def | run (self) |
def | send (self, cmd, kwargs) |
def | wait_read_frame (self) |
Public Attributes | |
serial | |
shorthand | |
Private Member Functions | |
def | _build_command (self, cmd, kwargs) |
def | _parse_samples (self, io_bytes) |
def | _parse_samples_header (self, io_bytes) |
def | _split_response (self, data) |
def | _wait_for_frame (self) |
def | _write (self, data) |
Private Attributes | |
_callback | |
_escaped | |
_thread_continue | |
_thread_quit | |
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.
def xbee.base.XBeeBase.__init__ | ( | self, | |
ser, | |||
shorthand = True , |
|||
callback = None , |
|||
escaped = False |
|||
) |
def xbee.base.XBeeBase.__getattr__ | ( | self, | |
name | |||
) |
|
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.
|
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.
|
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
|
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.
|
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.
|
private |
def xbee.base.XBeeBase.halt | ( | self | ) |
def xbee.base.XBeeBase.run | ( | self | ) |
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).
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