示例#1
0
def aa_i2c_monitor_read (aardvark, data):
    """usage: (int return, u16[] data) = aa_i2c_monitor_read(Aardvark aardvark, u16[] data)

    All arrays can be passed into the API as an ArrayType object or as
    a tuple (array, length), where array is an ArrayType object and
    length is an integer.  The user-specified length would then serve
    as the length argument to the API funtion (please refer to the
    product datasheet).  If only the array is provided, the array's
    intrinsic length is used as the argument to the underlying API
    function.

    Additionally, for arrays that are filled by the API function, an
    integer can be passed in place of the array argument and the API
    will automatically create an array of that length.  All output
    arrays, whether passed in or generated, are passed back in the
    returned tuple."""

    if not AA_LIBRARY_LOADED: return AA_INCOMPATIBLE_LIBRARY
    # data pre-processing
    __data = isinstance(data, int)
    if __data:
        (data, num_bytes) = (array_u16(data), data)
    else:
        (data, num_bytes) = isinstance(data, ArrayType) and (data, len(data)) or (data[0], min(len(data[0]), int(data[1])))
        if data.typecode != 'H':
            raise TypeError("type for 'data' must be array('H')")
    # Call API function
    (_ret_) = api.py_aa_i2c_monitor_read(aardvark, num_bytes, data)
    # data post-processing
    if __data: del data[max(0, min(_ret_, len(data))):]
    return (_ret_, data)
示例#2
0
def aa_i2c_monitor_read (aardvark, data):
    """usage: (int return, u16[] data) = aa_i2c_monitor_read(Aardvark aardvark, u16[] data)

    All arrays can be passed into the API as an ArrayType object or as
    a tuple (array, length), where array is an ArrayType object and
    length is an integer.  The user-specified length would then serve
    as the length argument to the API funtion (please refer to the
    product datasheet).  If only the array is provided, the array's
    intrinsic length is used as the argument to the underlying API
    function.

    Additionally, for arrays that are filled by the API function, an
    integer can be passed in place of the array argument and the API
    will automatically create an array of that length.  All output
    arrays, whether passed in or generated, are passed back in the
    returned tuple."""

    if not AA_LIBRARY_LOADED: return AA_INCOMPATIBLE_LIBRARY
    # data pre-processing
    __data = isinstance(data, int)
    if __data:
        (data, num_bytes) = (array_u16(data), data)
    else:
        (data, num_bytes) = isinstance(data, ArrayType) and (data, len(data)) or (data[0], min(len(data[0]), int(data[1])))
        if data.typecode != 'H':
            raise TypeError("type for 'data' must be array('H')")
    # Call API function
    (_ret_) = api.py_aa_i2c_monitor_read(aardvark, num_bytes, data)
    # data post-processing
    if __data: del data[max(0, min(_ret_, len(data))):]
    return (_ret_, data)