# 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_hmtrp', [dirname(__file__)])
except ImportError:
import _pyupm_hmtrp
return _pyupm_hmtrp
if fp is not None:
try:
_mod = imp.load_module('_pyupm_hmtrp', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_hmtrp = swig_import_helper()
del swig_import_helper
else:
import _pyupm_hmtrp
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_hmtrp.getVersion()
getVersion = _pyupm_hmtrp.getVersion
[docs]class uint8Array(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, uint8Array, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, uint8Array, name)
__repr__ = _swig_repr
def __init__(self, nelements):
this = _pyupm_hmtrp.new_uint8Array(nelements)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_hmtrp.delete_uint8Array
__del__ = lambda self: None
def __getitem__(self, index):
return _pyupm_hmtrp.uint8Array___getitem__(self, index)
def __setitem__(self, index, value):
return _pyupm_hmtrp.uint8Array___setitem__(self, index, value)
[docs] def cast(self):
return _pyupm_hmtrp.uint8Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_hmtrp.uint8Array_frompointer
if _newclass:
frompointer = staticmethod(_pyupm_hmtrp.uint8Array_frompointer)
uint8Array_swigregister = _pyupm_hmtrp.uint8Array_swigregister
uint8Array_swigregister(uint8Array)
def uint8Array_frompointer(t):
return _pyupm_hmtrp.uint8Array_frompointer(t)
uint8Array_frompointer = _pyupm_hmtrp.uint8Array_frompointer
[docs]class uint16Array(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, uint16Array, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, uint16Array, name)
__repr__ = _swig_repr
def __init__(self, nelements):
this = _pyupm_hmtrp.new_uint16Array(nelements)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_hmtrp.delete_uint16Array
__del__ = lambda self: None
def __getitem__(self, index):
return _pyupm_hmtrp.uint16Array___getitem__(self, index)
def __setitem__(self, index, value):
return _pyupm_hmtrp.uint16Array___setitem__(self, index, value)
[docs] def cast(self):
return _pyupm_hmtrp.uint16Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_hmtrp.uint16Array_frompointer
if _newclass:
frompointer = staticmethod(_pyupm_hmtrp.uint16Array_frompointer)
uint16Array_swigregister = _pyupm_hmtrp.uint16Array_swigregister
uint16Array_swigregister(uint16Array)
def uint16Array_frompointer(t):
return _pyupm_hmtrp.uint16Array_frompointer(t)
uint16Array_frompointer = _pyupm_hmtrp.uint16Array_frompointer
[docs]class uint32Array(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, uint32Array, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, uint32Array, name)
__repr__ = _swig_repr
def __init__(self, nelements):
this = _pyupm_hmtrp.new_uint32Array(nelements)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_hmtrp.delete_uint32Array
__del__ = lambda self: None
def __getitem__(self, index):
return _pyupm_hmtrp.uint32Array___getitem__(self, index)
def __setitem__(self, index, value):
return _pyupm_hmtrp.uint32Array___setitem__(self, index, value)
[docs] def cast(self):
return _pyupm_hmtrp.uint32Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_hmtrp.uint32Array_frompointer
if _newclass:
frompointer = staticmethod(_pyupm_hmtrp.uint32Array_frompointer)
uint32Array_swigregister = _pyupm_hmtrp.uint32Array_swigregister
uint32Array_swigregister(uint32Array)
def uint32Array_frompointer(t):
return _pyupm_hmtrp.uint32Array_frompointer(t)
uint32Array_frompointer = _pyupm_hmtrp.uint32Array_frompointer
[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_hmtrp.new_charArray(nelements)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_hmtrp.delete_charArray
__del__ = lambda self: None
def __getitem__(self, index):
return _pyupm_hmtrp.charArray___getitem__(self, index)
def __setitem__(self, index, value):
return _pyupm_hmtrp.charArray___setitem__(self, index, value)
[docs] def cast(self):
return _pyupm_hmtrp.charArray_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_hmtrp.charArray_frompointer
if _newclass:
frompointer = staticmethod(_pyupm_hmtrp.charArray_frompointer)
charArray_swigregister = _pyupm_hmtrp.charArray_swigregister
charArray_swigregister(charArray)
def charArray_frompointer(t):
return _pyupm_hmtrp.charArray_frompointer(t)
charArray_frompointer = _pyupm_hmtrp.charArray_frompointer
_pyupm_hmtrp.HMTRP_DEFAULT_UART_swigconstant(_pyupm_hmtrp)
HMTRP_DEFAULT_UART = _pyupm_hmtrp.HMTRP_DEFAULT_UART
[docs]class HMTRP(_object):
"""
API for the HM-TRP Serial RF Pro transceiver.
ID: hmtrp
Name: Serial RF Pro Module
Other Names: HMTRP-433 HMTRP-470 HMTRP-868 HMTRP-915
Category: wifi
Manufacturer: seeed
Connection: uart
Link:http://wiki.seeed.cc/Grove-Serial_RF_Pro/ UPM support for the
HM-TRP Serial RF Pro transceiver. This was tested specifically with
the Grove Serial RF Pro transceiver. In theory, this class should work
with the following devices:
HM-TRP-433: 414000000-454000000Hz HM-TRP-470: 450000000-490000000Hz
HM-TRP-868: 849000000-889000000Hz HM-TRP-915: 895000000-935000000Hz
The only difference is the transmit and receive frequencies supported.
By default, the device simply sends and receives any data presented on
its UART interface. It can be put into a configuration mode by
grounding the CONFIG pin on the transceiver.
C++ includes: hmtrp.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, HMTRP, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, HMTRP, name)
__repr__ = _swig_repr
RESET = _pyupm_hmtrp.HMTRP_RESET
GET_CONFIG = _pyupm_hmtrp.HMTRP_GET_CONFIG
SET_FREQUENCY = _pyupm_hmtrp.HMTRP_SET_FREQUENCY
SET_RF_DATARATE = _pyupm_hmtrp.HMTRP_SET_RF_DATARATE
SET_RX_BW = _pyupm_hmtrp.HMTRP_SET_RX_BW
SET_FREQ_MODULATION = _pyupm_hmtrp.HMTRP_SET_FREQ_MODULATION
SET_TX_POWER = _pyupm_hmtrp.HMTRP_SET_TX_POWER
SET_UART_SPEED = _pyupm_hmtrp.HMTRP_SET_UART_SPEED
GET_RF_SIGNAL_STR = _pyupm_hmtrp.HMTRP_GET_RF_SIGNAL_STR
GET_MOD_SIGNAL_STR = _pyupm_hmtrp.HMTRP_GET_MOD_SIGNAL_STR
def __init__(self, uart=0):
"""
HMTRP(int
uart=HMTRP_DEFAULT_UART)
HMTRP Serial RF Pro transceiver constructor
Parameters:
-----------
uart: Default UART to use (0 or 1)
"""
this = _pyupm_hmtrp.new_HMTRP(uart)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_hmtrp.delete_HMTRP
__del__ = lambda self: None
[docs] def dataAvailable(self, millis=0):
"""
bool
dataAvailable(unsigned int millis=0)
Checks to see if there is data available for reading
Parameters:
-----------
millis: Number of milliseconds to wait; 0 means no waiting (default).
True if there is data available for reading
"""
return _pyupm_hmtrp.HMTRP_dataAvailable(self, millis)
[docs] def readData(self, buffer, len, millis=-1):
"""
int readData(char
*buffer, int len, int millis=-1)
Reads any available data in a user-supplied buffer
Parameters:
-----------
buffer: Buffer to hold the data read
len: Length of the buffer
millis: Maximum time in milliseconds to wait for input. -1 means
waiting forever (default).
Number of bytes read; 0 if timed out and millis is >= 0
"""
return _pyupm_hmtrp.HMTRP_readData(self, buffer, len, millis)
[docs] def writeData(self, buffer, len):
"""
int writeData(char
*buffer, int len)
Writes the data in the buffer to the device
Parameters:
-----------
buffer: Buffer to hold the data read
len: Length of the buffer
Number of bytes written
"""
return _pyupm_hmtrp.HMTRP_writeData(self, buffer, len)
[docs] def setupTty(self, *args):
"""
bool setupTty(speed_t
baud=B9600)
Sets up proper tty I/O modes and the baud rate. The default baud rate
is 9,600 (B9600).
Parameters:
-----------
baud: Desired baud rate.
True if successful
"""
return _pyupm_hmtrp.HMTRP_setupTty(self, *args)
[docs] def checkOK(self):
"""
bool checkOK()
Looks for and verifies an OK response. This looks like
"OK\\r\\n"
True if OK received
"""
return _pyupm_hmtrp.HMTRP_checkOK(self)
[docs] def reset(self):
"""
bool reset()
Resets the device to default parameters, except for the UART baud rate
True if successful
"""
return _pyupm_hmtrp.HMTRP_reset(self)
[docs] def getConfig(self, freq, dataRate, rxBandwidth, modulation, txPower, uartBaud):
"""
bool getConfig(uint32_t
*freq, uint32_t *dataRate, uint16_t *rxBandwidth, uint8_t *modulation,
uint8_t *txPower, uint32_t *uartBaud)
Queries the radio to determine its configuration
Parameters:
-----------
freq: Operating frequency
dataRate: TX/RX bit rate
rxBandwidth: Receiving bandwidth in Khz
modulation: Modulation frequency in Khz
txPower: Transmission power (1-7)
uartBaud: UART baud rate
True if successful
"""
return _pyupm_hmtrp.HMTRP_getConfig(self, freq, dataRate, rxBandwidth, modulation, txPower, uartBaud)
[docs] def setFrequency(self, freq):
"""
bool
setFrequency(uint32_t freq)
Sets the frequency. Note: this is limited depending on which HM-TRP
device you are using. Consult the datasheet.
Parameters:
-----------
freq: Operating frequency
True if successful
"""
return _pyupm_hmtrp.HMTRP_setFrequency(self, freq)
[docs] def setRFDataRate(self, rate):
"""
bool
setRFDataRate(uint32_t rate)
Sets the RF data transmission rate. Valid values are between 1,200 and
115,200.
Parameters:
-----------
rate: Radio transmission rate in baud (1,200-115,200)
True if successful
"""
return _pyupm_hmtrp.HMTRP_setRFDataRate(self, rate)
[docs] def setRXBandwidth(self, rxBand):
"""
bool
setRXBandwidth(uint16_t rxBand)
Sets the RX bandwidth. Valid values are between 30 and 620 (in Khz)
Parameters:
-----------
rxBand: RX bandwidth in Khz (30-620)
True if successful
"""
return _pyupm_hmtrp.HMTRP_setRXBandwidth(self, rxBand)
[docs] def setFrequencyModulation(self, modulation):
"""
bool
setFrequencyModulation(uint8_t modulation)
Sets the frequency modulation. Valid values are between 10 and 160 (in
Khz)
Parameters:
-----------
modulation: Frequency modulation to use, in Khz (10-160)
True if successful
"""
return _pyupm_hmtrp.HMTRP_setFrequencyModulation(self, modulation)
[docs] def setTransmitPower(self, power):
"""
bool
setTransmitPower(uint8_t power)
Sets the transmit power level. Valid values are between 0 and 7, 7
being the maximum power.
Parameters:
-----------
power: Power level to use during transmission. Valid values are
between 0 and 7.
True if successful
"""
return _pyupm_hmtrp.HMTRP_setTransmitPower(self, power)
[docs] def setUARTSpeed(self, speed):
"""
bool
setUARTSpeed(uint32_t speed)
Sets the configured baud rate of the UART. It is strongly recommended
you do not change this, or you may lose the ability to communicate
with the transceiver. Valid values are 1,200-115,200.
Parameters:
-----------
speed: Desired baud rate to configure the device to use Valid values
are between 1,200 and 115,200.
True if successful
"""
return _pyupm_hmtrp.HMTRP_setUARTSpeed(self, speed)
[docs] def getRFSignalStrength(self, strength):
"""
uint8_t
getRFSignalStrength()
Gets the RF signal strength
Signal strength
Exceptions:
-----------
std::runtime_error: if reading from the sensor failed
"""
return _pyupm_hmtrp.HMTRP_getRFSignalStrength(self, strength)
[docs] def getRFSignalStrengthNoParam(self):
"""
uint8_t
getRFSignalStrength()
Gets the RF signal strength
Signal strength
Exceptions:
-----------
std::runtime_error: if reading from the sensor failed
"""
return _pyupm_hmtrp.HMTRP_getRFSignalStrengthNoParam(self)
[docs] def getModSignalStrength(self, strength):
"""
uint8_t
getModSignalStrength()
Gets the modulation signal strength.
Signal strength
Exceptions:
-----------
std::runtime_error: if reading from the sensor failed
"""
return _pyupm_hmtrp.HMTRP_getModSignalStrength(self, strength)
[docs] def getModSignalStrengthNoParam(self):
"""
uint8_t
getModSignalStrength()
Gets the modulation signal strength.
Signal strength
Exceptions:
-----------
std::runtime_error: if reading from the sensor failed
"""
return _pyupm_hmtrp.HMTRP_getModSignalStrengthNoParam(self)
HMTRP_swigregister = _pyupm_hmtrp.HMTRP_swigregister
HMTRP_swigregister(HMTRP)
# This file is compatible with both classic and new-style classes.
cvar = _pyupm_hmtrp.cvar