當前位置: 首頁>>代碼示例>>Python>>正文


Python ctypes.c_int16方法代碼示例

本文整理匯總了Python中ctypes.c_int16方法的典型用法代碼示例。如果您正苦於以下問題:Python ctypes.c_int16方法的具體用法?Python ctypes.c_int16怎麽用?Python ctypes.c_int16使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_int16方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _ar_arsdk_encode_type_info

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def _ar_arsdk_encode_type_info(cls, ar_argtype):
        arsdk_encode_type_info_map = {
            arsdkparser.ArArgType.I8: (od.ARSDK_ARG_TYPE_I8, "i8", ctypes.c_int8),
            arsdkparser.ArArgType.U8: (od.ARSDK_ARG_TYPE_U8, "u8", ctypes.c_uint8),
            arsdkparser.ArArgType.I16: (od.ARSDK_ARG_TYPE_I16, "i16", ctypes.c_int16),
            arsdkparser.ArArgType.U16: (od.ARSDK_ARG_TYPE_U16, "u16", ctypes.c_uint16),
            arsdkparser.ArArgType.I32: (od.ARSDK_ARG_TYPE_I32, "i32", ctypes.c_int32),
            arsdkparser.ArArgType.U32: (od.ARSDK_ARG_TYPE_U32, "u32", ctypes.c_uint32),
            arsdkparser.ArArgType.I64: (od.ARSDK_ARG_TYPE_I64, "i64", ctypes.c_int64),
            arsdkparser.ArArgType.U64: (od.ARSDK_ARG_TYPE_U64, "u64", ctypes.c_uint64),
            arsdkparser.ArArgType.FLOAT: (od.ARSDK_ARG_TYPE_FLOAT, "f32", ctypes.c_float),
            arsdkparser.ArArgType.DOUBLE: (od.ARSDK_ARG_TYPE_DOUBLE, "f64", ctypes.c_double),
            arsdkparser.ArArgType.STRING: (od.ARSDK_ARG_TYPE_STRING, "cstr", od.char_pointer_cast),
            arsdkparser.ArArgType.ENUM: (od.ARSDK_ARG_TYPE_ENUM, "i32", ctypes.c_int32),
        }
        return arsdk_encode_type_info_map[ar_argtype] 
開發者ID:Parrot-Developers,項目名稱:olympe,代碼行數:18,代碼來源:messages.py

示例2: _python_open_any_unit

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def _python_open_any_unit(self, resolution):
        status = None
        if len(self._open_unit.argtypes) == 3:
            if resolution is None:
                resolution = self.DEFAULT_RESOLUTION
            chandle = c_int16()
            cresolution = c_int32()
            cresolution.value = resolution
            status = self._open_unit(byref(chandle), None, cresolution)
            handle = chandle.value
        elif len(self._open_unit.argtypes) == 2:
            chandle = c_int16()
            status = self._open_unit(byref(chandle), None)
            handle = chandle.value
        else:
            handle = self._open_unit()

        return handle, status 
開發者ID:picotech,項目名稱:picosdk-python-wrappers,代碼行數:20,代碼來源:library.py

示例3: _python_get_unit_info

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def _python_get_unit_info(self, handle, info_type):
        string_size = 255
        info = self._create_empty_string_buffer()
        if len(self._get_unit_info.argtypes) == 4:
            info_len = self._get_unit_info(c_int16(handle), info, c_int16(string_size), c_int16(info_type))
            if info_len > 0:
                return info.value[:info_len]
        elif len(self._get_unit_info.argtypes) == 5:
            required_size = c_int16(0)
            status = self._get_unit_info(c_int16(handle),
                                         info,
                                         c_int16(string_size),
                                         byref(required_size),
                                         c_uint32(info_type))
            if status == self.PICO_STATUS['PICO_OK']:
                if required_size.value < string_size:
                    return info.value[:required_size.value]
        return "" 
開發者ID:picotech,項目名稱:picosdk-python-wrappers,代碼行數:20,代碼來源:library.py

示例4: set_null_trigger

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def set_null_trigger(self, device):
        auto_trigger_after_millis = 1
        if hasattr(self, '_set_trigger') and len(self._set_trigger.argtypes) == 6:
            PS2000_NONE = 5
            return_code = self._set_trigger(c_int16(device.handle),
                                            c_int16(PS2000_NONE),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(auto_trigger_after_millis))
            if return_code == 0:
                raise InvalidTriggerParameters()
        elif hasattr(self, '_set_simple_trigger') and len(self._set_simple_trigger.argtypes) == 7:
            enabled = False
            status = self._set_simple_trigger(c_int16(device.handle),
                                              c_int16(int(enabled)),
                                              c_int32(self.PICO_CHANNEL['A']),
                                              c_int16(0),
                                              c_int32(self.PICO_THRESHOLD_DIRECTION['NONE']),
                                              c_uint32(0),
                                              c_int16(auto_trigger_after_millis))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidTriggerParameters("set_simple_trigger failed (%s)" % constants.pico_tag(status))
        else:
            raise NotImplementedError("not done other driver types yet") 
開發者ID:picotech,項目名稱:picosdk-python-wrappers,代碼行數:27,代碼來源:library.py

示例5: adapt_int_width

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def adapt_int_width(n, width, signed=True):
    n = int(n)

    if width == 1:
        result = n
    elif width == 2:
        result = n
    elif width == 4:
        result = ctypes.c_int8(n).value if signed else ctypes.c_uint8(n).value
    elif width == 8:
        result = ctypes.c_int8(n).value if signed else ctypes.c_uint8(n).value
    elif width == 16:
        result = ctypes.c_int16(n).value if signed else ctypes.c_uint16(n).value
    elif width == 32:
        result = ctypes.c_int32(n).value if signed else ctypes.c_uint32(n).value
    elif width == 64:
        result = ctypes.c_int64(n).value if signed else ctypes.c_uint64(n).value
    else:
        result = n
    return result 
開發者ID:eth-sri,項目名稱:debin,代碼行數:22,代碼來源:utils.py

示例6: test_simple_concrete

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def test_simple_concrete():
    s = SimState(arch="AMD64")
    addr = 0xba5e0

    def check_read(val):
        nose.tools.assert_equal(s.solver.eval(s.memory.load(addr, 8, endness=Endness.LE), cast_to=int), val)

        nose.tools.assert_equal(s.mem[addr].char.concrete, chr(val & 0xFF).encode())
        nose.tools.assert_equal(s.mem[addr].byte.concrete, val & 0xFF)

        nose.tools.assert_equal(s.mem[addr].int16_t.concrete, ctypes.c_int16(val & 0xFFFF).value)
        nose.tools.assert_equal(s.mem[addr].uint16_t.concrete, val & 0xFFFF)

        nose.tools.assert_equal(s.mem[addr].qword.concrete, val)

    s.memory.store(addr, claripy.BVV(0x11223344aabbcc7d, 64), endness=Endness.LE)
    check_read(0x11223344aabbcc7d)

    # test storing
    s.mem[addr].uint16_t = 0xef6d
    check_read(0x11223344aabbef6d) 
開發者ID:angr,項目名稱:angr,代碼行數:23,代碼來源:test_memview.py

示例7: zone_write_int16_values

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def zone_write_int16_values(file_handle, zone, var, values):
    tecio.tecZoneVarWriteInt16Values.restype=ctypes.c_int32
    tecio.tecZoneVarWriteInt16Values.argtypes=(
            ctypes.c_void_p, #file_handle
            ctypes.c_int32,  #zone
            ctypes.c_int32,  #var
            ctypes.c_int32,  #partition
            ctypes.c_int64,  #count
            ctypes.POINTER(ctypes.c_int16)) #values

    values_ptr = (ctypes.c_int16*len(values))(*values)
    ret = tecio.tecZoneVarWriteInt16Values(file_handle,
            zone,
            var,
            0,
            len(values),
            values_ptr)
    if ret != 0:
        raise Exception("zone_write_int16_values Error") 
開發者ID:Tecplot,項目名稱:handyscripts,代碼行數:21,代碼來源:tecio_szl.py

示例8: _return_ctype

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def _return_ctype(self):
        """ Returns the associated ctype of a given datatype. """
        _datatype_ctype = {
            DataType.Bool: ctypes.c_uint8,
            DataType.I8: ctypes.c_int8,
            DataType.U8: ctypes.c_uint8,
            DataType.I16: ctypes.c_int16,
            DataType.U16: ctypes.c_uint16,
            DataType.I32: ctypes.c_int32,
            DataType.U32: ctypes.c_uint32,
            DataType.I64: ctypes.c_int64,
            DataType.U64: ctypes.c_uint64,
            DataType.Sgl: ctypes.c_float,
            DataType.Dbl: ctypes.c_double,
            DataType.Fxp: ctypes.c_uint32,
            DataType.Cluster: ctypes.c_uint32,
        }
        return _datatype_ctype[self] 
開發者ID:ni,項目名稱:nifpga-python,代碼行數:20,代碼來源:nifpga.py

示例9: __init__

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__square_int_array_with_struct__ = self.__dll__.square_int_array_with_struct
		self.__square_int_array_with_struct__.argtypes = (
			ctypes.POINTER(int_array_data),
			ctypes.POINTER(int_array_data)
			)
		self.__square_int_array_with_struct__.memsync = [
			{
				'p': [0, 'data'],
				'l': [0, 'len'],
				't': 'c_int16'
				},
			{
				'p': [1, 'data'],
				'l': [1, 'len'],
				't': 'c_int16'
				}
			] 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:23,代碼來源:test_square_int_array_with_struct.py

示例10: square_int_array_with_struct

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def square_int_array_with_struct(self, in_array):

		in_array_obj = int_array_data()
		out_array_obj = int_array_data()

		in_array_obj.data = ctypes.cast(
			ctypes.pointer((ctypes.c_int16 * len(in_array))(*in_array)),
			ctypes.POINTER(ctypes.c_int16)
			)
		in_array_obj.len = len(in_array)

		self.__square_int_array_with_struct__(
			in_array_obj,
			out_array_obj
			)

		return ctypes.cast(
			out_array_obj.data,
			ctypes.POINTER(ctypes.c_int16 * len(in_array))
			).contents[:]


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# TEST(s)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:27,代碼來源:test_square_int_array_with_struct.py

示例11: __init__

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__sum_elements_from_callback_in_struct__ = self.__dll__.sum_elements_from_callback_in_struct
		self.__sum_elements_from_callback_in_struct__.argtypes = (ctypes.POINTER(conveyor_belt_data),)
		self.__sum_elements_from_callback_in_struct__.restype = ctypes.c_int16

		self.DATA = [1, 6, 8, 4, 9, 7, 4, 2, 5, 2]

		@conveyor_belt
		def get_data(index):
			print((index, self.DATA[index]))
			return self.DATA[index]

		self.__get_data__ = get_data 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:18,代碼來源:test_callback_simple_struct.py

示例12: __init__

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__square_int_array__ = self.__dll__.square_int_array
		self.__square_int_array__.argtypes = (
			ctypes.POINTER(ctypes.c_int16),
			ctypes.c_void_p,
			ctypes.c_int16
			)
		self.__square_int_array__.memsync = [
			{
				'p': [0],
				'l': [2],
				't': 'c_int16'
				},
			{
				'p': [1, -1],
				'l': [2],
				't': 'c_int16'
				}
			] 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:24,代碼來源:test_square_int_array.py

示例13: square_int_array

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def square_int_array(self, in_array):

		in_array_p = ctypes.cast(
			ctypes.pointer((ctypes.c_int16 * len(in_array))(*in_array)),
			ctypes.POINTER(ctypes.c_int16)
			)
		out_array_p = ctypes.pointer(ctypes.c_void_p())

		self.__square_int_array__(
			in_array_p,
			out_array_p,
			ctypes.c_int16(len(in_array))
			)

		return ctypes.cast(
			out_array_p.contents,
			ctypes.POINTER(ctypes.c_int16 * len(in_array))
			).contents[:]


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# TEST(s)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:25,代碼來源:test_square_int_array.py

示例14: __init__

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		conveyor_belt = ctypes.WINFUNCTYPE(ctypes.c_int16, ctypes.c_int16)

		self.__sum_elements_from_callback__ = self.__dll__.sum_elements_from_callback
		self.__sum_elements_from_callback__.argtypes = (ctypes.c_int16, conveyor_belt)
		self.__sum_elements_from_callback__.restype = ctypes.c_int16

		self.DATA = [1, 6, 8, 4, 9, 7, 4, 2, 5, 2]

		@conveyor_belt
		def get_data(index):
			print((index, self.DATA[index]))
			return self.DATA[index]

		self.__get_data__ = get_data 
開發者ID:pleiszenburg,項目名稱:zugbruecke,代碼行數:20,代碼來源:test_callback_simple.py

示例15: test_struct_array_pointer

# 需要導入模塊: import ctypes [as 別名]
# 或者: from ctypes import c_int16 [as 別名]
def test_struct_array_pointer(self):
        from ctypes import c_int16, Structure, pointer

        class Struct(Structure):
            _fields_ = [('a', c_int16)]

        Struct3 = 3 * Struct

        c_array = (2 * Struct3)(
            Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),
            Struct3(Struct(a=4), Struct(a=5), Struct(a=6))
        )

        expected = np.array([
            [(1,), (2,), (3,)],
            [(4,), (5,), (6,)],
        ], dtype=[('a', np.int16)])

        def check(x):
            assert_equal(x.dtype, expected.dtype)
            assert_equal(x, expected)

        # all of these should be equivalent
        check(as_array(c_array))
        check(as_array(pointer(c_array), shape=()))
        check(as_array(pointer(c_array[0]), shape=(2,)))
        check(as_array(pointer(c_array[0][0]), shape=(2, 3))) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:29,代碼來源:test_ctypeslib.py


注:本文中的ctypes.c_int16方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。