Source code for pyupm_xbee

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.





from sys import version_info
if version_info >= (2, 6, 0):
    def swig_import_helper():
        from os.path import dirname
        import imp
        fp = None
        try:
            fp, pathname, description = imp.find_module('_pyupm_xbee', [dirname(__file__)])
        except ImportError:
            import _pyupm_xbee
            return _pyupm_xbee
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_xbee', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_xbee = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_xbee
del version_info
try:
    _swig_property = property
except NameError:
    pass  # Python < 2.2 doesn't have 'property'.


def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
    if (name == "thisown"):
        return self.this.own(value)
    if (name == "this"):
        if type(value).__name__ == 'SwigPyObject':
            self.__dict__[name] = value
            return
    method = class_type.__swig_setmethods__.get(name, None)
    if method:
        return method(self, value)
    if (not static):
        if _newclass:
            object.__setattr__(self, name, value)
        else:
            self.__dict__[name] = value
    else:
        raise AttributeError("You cannot add attributes to %s" % self)


def _swig_setattr(self, class_type, name, value):
    return _swig_setattr_nondynamic(self, class_type, name, value, 0)


def _swig_getattr_nondynamic(self, class_type, name, static=1):
    if (name == "thisown"):
        return self.this.own()
    method = class_type.__swig_getmethods__.get(name, None)
    if method:
        return method(self)
    if (not static):
        return object.__getattr__(self, name)
    else:
        raise AttributeError(name)

def _swig_getattr(self, class_type, name):
    return _swig_getattr_nondynamic(self, class_type, name, 0)


def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)

try:
    _object = object
    _newclass = 1
except AttributeError:
    class _object:
        pass
    _newclass = 0



def getVersion():
    return _pyupm_xbee.getVersion()
getVersion = _pyupm_xbee.getVersion

_pyupm_xbee.XBEE_DEFAULT_UART_swigconstant(_pyupm_xbee)
XBEE_DEFAULT_UART = _pyupm_xbee.XBEE_DEFAULT_UART
[docs]class XBee(_object): """ API for the XBee modules. ID: xbee Name: XBee Serial Module Category: wifi Manufacturer: sparkfun Connection: uart Link:https://www.sparkfun.com/products/11215 This is a generic UART driver for use with Digi XBee modules. It was tested with the XBee S1 802.15.4 module and the XBee S6B WiFi module. It provides basic UART support for sending and receiving data to and from the device. It is controlled by an AT or API command set. It is connected at 9600 baud by default. These devices are typically configured using Digi's X-CTU windows software, however it is possible of course to configure them manually using AT commands. See the examples. XBee Sensor image provided by SparkFun* underCC BY-NC-SA-3.0. C++ includes: xbee.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, XBee, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, XBee, name) __repr__ = _swig_repr def __init__(self, uart=0): """ XBee(int uart=XBEE_DEFAULT_UART) XBee object constructor Parameters: ----------- uart: Default UART to use (0 or 1). Default is 0. """ this = _pyupm_xbee.new_XBee(uart) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_xbee.delete_XBee __del__ = lambda self: None
[docs] def dataAvailable(self, millis): """ bool dataAvailable(unsigned int millis) Checks to see if there is data available for reading Parameters: ----------- millis: Number of milliseconds to wait; 0 means no waiting true if there is data available for reading """ return _pyupm_xbee.XBee_dataAvailable(self, millis)
[docs] def readData(self, buffer, len): """ int readData(char *buffer, unsigned int len) Reads any available data into a user-supplied buffer. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking. Parameters: ----------- buffer: Buffer to hold the data read len: Length of the buffer Number of bytes read """ return _pyupm_xbee.XBee_readData(self, buffer, len)
[docs] def readDataStr(self, len): """ std::string readDataStr(int len) Reads any available data and returns it in a std::string. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking. Parameters: ----------- len: Maximum length of the data to be returned string containing the data read """ return _pyupm_xbee.XBee_readDataStr(self, len)
[docs] def writeData(self, buffer, len): """ int writeData(char *buffer, unsigned len) Writes the data in the buffer to the device. If you are writing an AT command, be sure to terminate it with a carriage return () Parameters: ----------- buffer: Buffer to hold the data to write len: Length of the buffer Number of bytes written """ return _pyupm_xbee.XBee_writeData(self, buffer, len)
[docs] def writeDataStr(self, data): """ int writeDataStr(std::string data) Writes the std:string data to the device. If you are writing an AT command, be sure to terminate it with a carriage return () Parameters: ----------- data: Buffer to write to the device Number of bytes written """ return _pyupm_xbee.XBee_writeDataStr(self, data)
[docs] def setBaudRate(self, baud=9600): """ mraa::Result setBaudRate(int baud=9600) Sets the baud rate for the device. The default is 9600. Parameters: ----------- baud: Desired baud rate true if successful """ return _pyupm_xbee.XBee_setBaudRate(self, baud)
[docs] def commandMode(self, *args): """ bool commandMode(std::string cmdChars="+++", int guardTimeMS=1000) Attempts to enter AT Command Mode. When Idle, data sent to the device (assuming it is not in API mode) is silently transmitted to the configured destination. Running this command attempts to place the device into command mode, allowing you to send AT commands. Note, after a configurable period of inactivity, the device will exit command mode automatically (default 10 seconds). Both the cmdChars (+++) and the Guard Time can be configured on the device to different values using AT configuration commands. Parameters: ----------- cmdChars: The command mode characters, default "+++" guardTimeMS: The number of milliseconds to wait before and after sending the command characters. Default is 1000 (1 second). true if successful (received an "OK"), false otherwise """ return _pyupm_xbee.XBee_commandMode(self, *args)
[docs] def stringCR2LF(self, str): """ string stringCR2LF(std::string str) This is a convenience method that converts each CR () in a string to a LF ( ) and returns it. This is useful for outputting the response to an AT command for instance, which is typically CR terminated. Parameters: ----------- str: The string to convert The converted string """ return _pyupm_xbee.XBee_stringCR2LF(self, str)
XBee_swigregister = _pyupm_xbee.XBee_swigregister XBee_swigregister(XBee)
[docs]class charArray(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, charArray, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, charArray, name) __repr__ = _swig_repr def __init__(self, nelements): this = _pyupm_xbee.new_charArray(nelements) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_xbee.delete_charArray __del__ = lambda self: None def __getitem__(self, index): return _pyupm_xbee.charArray___getitem__(self, index) def __setitem__(self, index, value): return _pyupm_xbee.charArray___setitem__(self, index, value)
[docs] def cast(self): return _pyupm_xbee.charArray_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_xbee.charArray_frompointer if _newclass: frompointer = staticmethod(_pyupm_xbee.charArray_frompointer)
charArray_swigregister = _pyupm_xbee.charArray_swigregister charArray_swigregister(charArray) def charArray_frompointer(t): return _pyupm_xbee.charArray_frompointer(t) charArray_frompointer = _pyupm_xbee.charArray_frompointer # This file is compatible with both classic and new-style classes.