Source code for pyupm_zfm20

# 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_zfm20', [dirname(__file__)])
        except ImportError:
            import _pyupm_zfm20
            return _pyupm_zfm20
        if fp is not None:
            try:
                _mod = imp.load_module('_pyupm_zfm20', fp, pathname, description)
            finally:
                fp.close()
            return _mod
    _pyupm_zfm20 = swig_import_helper()
    del swig_import_helper
else:
    import _pyupm_zfm20
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_zfm20.getVersion()
getVersion = _pyupm_zfm20.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_zfm20.new_uint8Array(nelements) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_zfm20.delete_uint8Array __del__ = lambda self: None def __getitem__(self, index): return _pyupm_zfm20.uint8Array___getitem__(self, index) def __setitem__(self, index, value): return _pyupm_zfm20.uint8Array___setitem__(self, index, value)
[docs] def cast(self): return _pyupm_zfm20.uint8Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_zfm20.uint8Array_frompointer if _newclass: frompointer = staticmethod(_pyupm_zfm20.uint8Array_frompointer)
uint8Array_swigregister = _pyupm_zfm20.uint8Array_swigregister uint8Array_swigregister(uint8Array) def uint8Array_frompointer(t): return _pyupm_zfm20.uint8Array_frompointer(t) uint8Array_frompointer = _pyupm_zfm20.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_zfm20.new_uint16Array(nelements) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_zfm20.delete_uint16Array __del__ = lambda self: None def __getitem__(self, index): return _pyupm_zfm20.uint16Array___getitem__(self, index) def __setitem__(self, index, value): return _pyupm_zfm20.uint16Array___setitem__(self, index, value)
[docs] def cast(self): return _pyupm_zfm20.uint16Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_zfm20.uint16Array_frompointer if _newclass: frompointer = staticmethod(_pyupm_zfm20.uint16Array_frompointer)
uint16Array_swigregister = _pyupm_zfm20.uint16Array_swigregister uint16Array_swigregister(uint16Array) def uint16Array_frompointer(t): return _pyupm_zfm20.uint16Array_frompointer(t) uint16Array_frompointer = _pyupm_zfm20.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_zfm20.new_uint32Array(nelements) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_zfm20.delete_uint32Array __del__ = lambda self: None def __getitem__(self, index): return _pyupm_zfm20.uint32Array___getitem__(self, index) def __setitem__(self, index, value): return _pyupm_zfm20.uint32Array___setitem__(self, index, value)
[docs] def cast(self): return _pyupm_zfm20.uint32Array_cast(self)
__swig_getmethods__["frompointer"] = lambda x: _pyupm_zfm20.uint32Array_frompointer if _newclass: frompointer = staticmethod(_pyupm_zfm20.uint32Array_frompointer)
uint32Array_swigregister = _pyupm_zfm20.uint32Array_swigregister uint32Array_swigregister(uint32Array) def uint32Array_frompointer(t): return _pyupm_zfm20.uint32Array_frompointer(t) uint32Array_frompointer = _pyupm_zfm20.uint32Array_frompointer def new_intp(): return _pyupm_zfm20.new_intp() new_intp = _pyupm_zfm20.new_intp def copy_intp(value): return _pyupm_zfm20.copy_intp(value) copy_intp = _pyupm_zfm20.copy_intp def delete_intp(obj): return _pyupm_zfm20.delete_intp(obj) delete_intp = _pyupm_zfm20.delete_intp def intp_assign(obj, value): return _pyupm_zfm20.intp_assign(obj, value) intp_assign = _pyupm_zfm20.intp_assign def intp_value(obj): return _pyupm_zfm20.intp_value(obj) intp_value = _pyupm_zfm20.intp_value _pyupm_zfm20.ZFM20_DEFAULT_UART_swigconstant(_pyupm_zfm20) ZFM20_DEFAULT_UART = _pyupm_zfm20.ZFM20_DEFAULT_UART _pyupm_zfm20.ZFM20_START1_swigconstant(_pyupm_zfm20) ZFM20_START1 = _pyupm_zfm20.ZFM20_START1 _pyupm_zfm20.ZFM20_START2_swigconstant(_pyupm_zfm20) ZFM20_START2 = _pyupm_zfm20.ZFM20_START2 _pyupm_zfm20.ZFM20_MAX_PKT_LEN_swigconstant(_pyupm_zfm20) ZFM20_MAX_PKT_LEN = _pyupm_zfm20.ZFM20_MAX_PKT_LEN _pyupm_zfm20.ZFM20_TIMEOUT_swigconstant(_pyupm_zfm20) ZFM20_TIMEOUT = _pyupm_zfm20.ZFM20_TIMEOUT _pyupm_zfm20.ZFM20_DEFAULT_PASSWORD_swigconstant(_pyupm_zfm20) ZFM20_DEFAULT_PASSWORD = _pyupm_zfm20.ZFM20_DEFAULT_PASSWORD _pyupm_zfm20.ZFM20_DEFAULT_ADDRESS_swigconstant(_pyupm_zfm20) ZFM20_DEFAULT_ADDRESS = _pyupm_zfm20.ZFM20_DEFAULT_ADDRESS
[docs]class ZFM20(_object): """ API for the ZFM-20 Fingerprint Sensor Module. ID: zfm20 Name: Fingerprint Sensor Module Other Names: Grove Fingerprint Sensor Category: touch Manufacturer: seeed Link:http://wiki.seeed.cc/Grove-Fingerprint_Sensor/ Connection: uart This class was tested on the Grove Fingerprint Sensor Module. It can store up to 163 fingerprints. It is connected via a UART at 57,600 baud. This example demonstrates how to register and store a new fingerprintThis example demonstrates reading a fingerprint and locating it in the DB C++ includes: zfm20.hpp """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, ZFM20, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, ZFM20, name) __repr__ = _swig_repr CMD_GEN_IMAGE = _pyupm_zfm20.ZFM20_CMD_GEN_IMAGE CMD_IMG2TZ = _pyupm_zfm20.ZFM20_CMD_IMG2TZ CMD_MATCH = _pyupm_zfm20.ZFM20_CMD_MATCH CMD_SEARCH = _pyupm_zfm20.ZFM20_CMD_SEARCH CMD_REGMODEL = _pyupm_zfm20.ZFM20_CMD_REGMODEL CMD_STORE = _pyupm_zfm20.ZFM20_CMD_STORE CMD_LOAD_TMPL = _pyupm_zfm20.ZFM20_CMD_LOAD_TMPL CMD_UPLOAD_TMPL = _pyupm_zfm20.ZFM20_CMD_UPLOAD_TMPL CMD_DOWNLOAD_TMPL = _pyupm_zfm20.ZFM20_CMD_DOWNLOAD_TMPL CMD_UPLOAD_IMAGE = _pyupm_zfm20.ZFM20_CMD_UPLOAD_IMAGE CMD_DOWNLOAD_IMAGE = _pyupm_zfm20.ZFM20_CMD_DOWNLOAD_IMAGE CMD_DELETE_TMPL = _pyupm_zfm20.ZFM20_CMD_DELETE_TMPL CMD_EMPTYDB = _pyupm_zfm20.ZFM20_CMD_EMPTYDB CMD_SET_SYSPARAMS = _pyupm_zfm20.ZFM20_CMD_SET_SYSPARAMS CMD_GET_SYSPARAMS = _pyupm_zfm20.ZFM20_CMD_GET_SYSPARAMS CMD_SET_PASSWORD = _pyupm_zfm20.ZFM20_CMD_SET_PASSWORD CMD_VERIFY_PASSWORD = _pyupm_zfm20.ZFM20_CMD_VERIFY_PASSWORD CMD_GET_RANDOM_NUMBER = _pyupm_zfm20.ZFM20_CMD_GET_RANDOM_NUMBER CMD_SET_ADDRESS = _pyupm_zfm20.ZFM20_CMD_SET_ADDRESS CMD_GET_TMPL_COUNT = _pyupm_zfm20.ZFM20_CMD_GET_TMPL_COUNT CMD_GET_INDEX_TABLE = _pyupm_zfm20.ZFM20_CMD_GET_INDEX_TABLE ERR_OK = _pyupm_zfm20.ZFM20_ERR_OK ERR_PACKET_RX_ERROR = _pyupm_zfm20.ZFM20_ERR_PACKET_RX_ERROR ERR_NO_FINGER = _pyupm_zfm20.ZFM20_ERR_NO_FINGER ERR_FP_IMAGE_FAILED = _pyupm_zfm20.ZFM20_ERR_FP_IMAGE_FAILED ERR_FP_TOO_MESSY = _pyupm_zfm20.ZFM20_ERR_FP_TOO_MESSY ERR_FP_IMAGE_FEW_FEATURES = _pyupm_zfm20.ZFM20_ERR_FP_IMAGE_FEW_FEATURES ERR_FP_NOMATCH = _pyupm_zfm20.ZFM20_ERR_FP_NOMATCH ERR_FP_NOTFOUND = _pyupm_zfm20.ZFM20_ERR_FP_NOTFOUND ERR_FP_ENROLLMISMATCH = _pyupm_zfm20.ZFM20_ERR_FP_ENROLLMISMATCH ERR_BAD_LOCATION = _pyupm_zfm20.ZFM20_ERR_BAD_LOCATION ERR_DB_ERROR = _pyupm_zfm20.ZFM20_ERR_DB_ERROR ERR_UPLOAD_FEAT_FAILED = _pyupm_zfm20.ZFM20_ERR_UPLOAD_FEAT_FAILED ERR_NO_MORE_PACKETS = _pyupm_zfm20.ZFM20_ERR_NO_MORE_PACKETS ERR_UPLOAD_IMG_FAILED = _pyupm_zfm20.ZFM20_ERR_UPLOAD_IMG_FAILED ERR_RM_TMPL_FAILED = _pyupm_zfm20.ZFM20_ERR_RM_TMPL_FAILED ERR_EMPTY_DB_FAILED = _pyupm_zfm20.ZFM20_ERR_EMPTY_DB_FAILED ERR_INVALID_PWD = _pyupm_zfm20.ZFM20_ERR_INVALID_PWD ERR_INVALID_IMAGE = _pyupm_zfm20.ZFM20_ERR_INVALID_IMAGE ERR_RW_FLASH_ERROR = _pyupm_zfm20.ZFM20_ERR_RW_FLASH_ERROR ERR_INVALID_REG = _pyupm_zfm20.ZFM20_ERR_INVALID_REG ERR_INVALID_ADDR = _pyupm_zfm20.ZFM20_ERR_INVALID_ADDR ERR_NEEDS_PWD = _pyupm_zfm20.ZFM20_ERR_NEEDS_PWD ERR_INTERNAL_ERR = _pyupm_zfm20.ZFM20_ERR_INTERNAL_ERR PKT_COMMAND = _pyupm_zfm20.ZFM20_PKT_COMMAND PKT_DATA = _pyupm_zfm20.ZFM20_PKT_DATA PKT_ACK = _pyupm_zfm20.ZFM20_PKT_ACK PKT_END_DATA = _pyupm_zfm20.ZFM20_PKT_END_DATA def __init__(self, *args): """ ZFM20(std::string uart_raw, int baud=57600) ZFM20 constructor Parameters: ----------- uart: File path (/dev/ttyXXX to uart baud: Desired baud rate """ this = _pyupm_zfm20.new_ZFM20(*args) try: self.this.append(this) except Exception: self.this = this __swig_destroy__ = _pyupm_zfm20.delete_ZFM20 __del__ = lambda self: None
[docs] def readData(self, buffer, len): """ int readData(char *buffer, int len) Reads any available data in a user-supplied buffer. Note: the call blocks until data is available to be read. 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_zfm20.ZFM20_readData(self, buffer, len)
[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_zfm20.ZFM20_writeData(self, buffer, len)
[docs] def setupTty(self, baud=57600): """ bool setupTty(uint32_t baud=57600) Sets up proper tty I/O modes and the baud rate. For this device, the default baud rate is 57,600. Parameters: ----------- baud: Desired baud rate. True if successful """ return _pyupm_zfm20.ZFM20_setupTty(self, baud)
[docs] def writeCmdPacket(self, pkt, len): """ int writeCmdPacket(uint8_t *pkt, int len) Composes and writes a command packet Parameters: ----------- pkt: Packet len: Length of packet Number of bytes written """ return _pyupm_zfm20.ZFM20_writeCmdPacket(self, pkt, len)
[docs] def verifyPacket(self, pkt, len): """ bool verifyPacket(uint8_t *pkt, int len) Verifies the packet header and indicates its validity Parameters: ----------- pkt: Packet to check len: Length of packet True if the packet is valid, false otherwise """ return _pyupm_zfm20.ZFM20_verifyPacket(self, pkt, len)
[docs] def getMillis(self): """ uint32_t getMillis() Returns the number of milliseconds elapsed since initClock() was last called Elapsed milliseconds """ return _pyupm_zfm20.ZFM20_getMillis(self)
[docs] def initClock(self): """ void initClock() Resets the clock """ return _pyupm_zfm20.ZFM20_initClock(self)
[docs] def setAddress(self, addr): """ void setAddress(uint32_t addr) Sets the address that should be used to access the module Parameters: ----------- addr: Address to use """ return _pyupm_zfm20.ZFM20_setAddress(self, addr)
[docs] def setPassword(self, pw): """ void setPassword(uint32_t pw) Sets the password that should be used to access the module Parameters: ----------- pw: Password to use """ return _pyupm_zfm20.ZFM20_setPassword(self, pw)
[docs] def getResponse(self, pkt, len): """ bool getResponse(uint8_t *pkt, int len) Gets the returned data from a request Parameters: ----------- pkt: Buffer to store the returned data len: Expected response length; pkt should be at least this large True if successful """ return _pyupm_zfm20.ZFM20_getResponse(self, pkt, len)
[docs] def verifyPassword(self): """ bool verifyPassword() Verifies and authenticates to the module. The password used is the last one set by setPassword(). True if successful """ return _pyupm_zfm20.ZFM20_verifyPassword(self)
[docs] def getNumTemplates(self): """ int getNumTemplates() Queries the module for the number of stored templates (fingerprints). Number of currently stored templates """ return _pyupm_zfm20.ZFM20_getNumTemplates(self)
[docs] def setNewPassword(self, pwd): """ bool setNewPassword(uint32_t pwd) Sets a new password for the module. This passowrd is stored in the module, and is required to access the module in the future. Parameters: ----------- pwd: New password to set on the module True if successful """ return _pyupm_zfm20.ZFM20_setNewPassword(self, pwd)
[docs] def setNewAddress(self, addr): """ bool setNewAddress(uint32_t addr) Sets a new address for the module. This address is stored in the module, and is required to access the module in the future. Parameters: ----------- addr: New address to set on the module True if successful """ return _pyupm_zfm20.ZFM20_setNewAddress(self, addr)
[docs] def generateImage(self): """ uint8_t generateImage() Generates a new fingerprint image (scans a fingerprint) One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_generateImage(self)
[docs] def image2Tz(self, slot): """ uint8_t image2Tz(int slot) Converts the image in the image buffer (generated by generateImage()) and stores it in one of the two characteristics buffers, 1 or 2 Parameters: ----------- slot: Characteristics buffer to use; must be 1 or 2 One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_image2Tz(self, slot)
[docs] def createModel(self): """ uint8_t createModel() Based on the two characteristics buffers (1 & 2), creates a fingerprint model. Once a model is successfully created, it can be stored in the module with storeModel(). One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_createModel(self)
[docs] def storeModel(self, slot, id): """ uint8_t storeModel(int slot, uint16_t id) Once a fingerprint model is created, this method can be used to store it (via one of the characteristics buffers) in a given location. Parameters: ----------- slot: Characteristics buffer to store the model, 1 or 2 id: Location to store the model One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_storeModel(self, slot, id)
[docs] def deleteModel(self, id): """ uint8_t deleteModel(uint16_t id) Deletes a stored model Parameters: ----------- id: Location containing the model to delete One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_deleteModel(self, id)
[docs] def deleteDB(self): """ uint8_t deleteDB() Deletes the model database (DB) One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_deleteDB(self)
[docs] def search(self, slot): """ uint8_t search(int slot, uint16_t &id, uint16_t &score) Searches the fingerprint DB and returns an ID and score, if found Parameters: ----------- slot: Slot containing a converted image to search for id: ID if found, 0 otherwise score: Score if found, 0 otherwise One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_search(self, slot)
[docs] def match(self): """ uint8_t match(uint16_t &score) Compares the features in characteristics buffers 1 and 2 and returns a score if they match Parameters: ----------- score: Score One of the ZFM20_ERRORS_T values """ return _pyupm_zfm20.ZFM20_match(self)
ZFM20_swigregister = _pyupm_zfm20.ZFM20_swigregister ZFM20_swigregister(ZFM20) # This file is compatible with both classic and new-style classes.