python类c_uint16()的实例源码

list_ports_osx.py 文件源码 项目:mt7687-serial-uploader 作者: will127534 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def get_int_property(device_type, property, cf_number_type):
    """
    Search the given device for the specified string property

    @param device_type Device to search
    @param property String to search for
    @param cf_number_type CFType number

    @return Python string containing the value, or None if not found.
    """
    key = cf.CFStringCreateWithCString(
            kCFAllocatorDefault,
            property.encode("mac_roman"),
            kCFStringEncodingMacRoman)

    CFContainer = iokit.IORegistryEntryCreateCFProperty(
            device_type,
            key,
            kCFAllocatorDefault,
            0)

    if CFContainer:
        if (cf_number_type == kCFNumberSInt32Type):
            number = ctypes.c_uint32()
        elif (cf_number_type == kCFNumberSInt16Type):
            number = ctypes.c_uint16()
        cf.CFNumberGetValue(CFContainer, cf_number_type, ctypes.byref(number))
        cf.CFRelease(CFContainer)
        return number.value
    return None
nonlinearfunction.py 文件源码 项目:crypto 作者: erose1337 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def nonlinear_function2(state_and_constant):
    state, constant = state_and_constant
    state ^= constant        
    state += 1    
    state ^= word(state >> 8).value        
    state ^= word(state << 8).value
    state = word(~state).value
  #  state ^= word(state << 5).value
  #  state ^= word(state >> 3).value


    return (eight_bit_integer(state).value, state)
nonlinearfunction.py 文件源码 项目:crypto 作者: erose1337 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def pbox(word):
    binary_word = cast(word, "binary")
    return int(''.join(binary_word[offset::8] for offset in range(8)), 2)
jlink.py 文件源码 项目:RTT-Console 作者: dudulung 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def read_16(self, addr):
        addr = ctypes.c_uint32(addr)
        data = ctypes.c_uint16()
        status = ctypes.c_byte()
        self.jlink.JLINKARM_ReadMemU16(addr, 1, ctypes.byref(data), ctypes.byref(status))
        return data.value
jlink.py 文件源码 项目:RTT-Console 作者: dudulung 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def write_16(self, addr, data):
        addr = ctypes.c_uint32(addr)
        data = ctypes.c_uint16(data)
        self.jlink.JLINKARM_WriteU16(addr, data)
cameralink.py 文件源码 项目:PPPLCalibrationFramework 作者: timothyhollabaugh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init(self):
        """
        Does one time initing of the dll
        """
        self._background = np.zeros(dtype=ctypes.c_uint16, shape=(512, 640))
        self._clib = ctypes.cdll.LoadLibrary('pdvlib.dll')
        self._pdv = self._clib.pdv_open(b'pdv', 0)
        self._clib.pdv_multibuf(self._pdv, 4)

        self._clib.pdv_wait_image.restype = np.ctypeslib.ndpointer(
            dtype=ctypes.c_uint16, shape=(512, 1280))
        self._clib.pdv_image.restype = np.ctypeslib.ndpointer(
            dtype=ctypes.c_uint16, shape=(512, 1280))
tox.py 文件源码 项目:milisia-tox 作者: milisarge 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def bootstrap(self, address, port, public_key):
        """
        Sends a "get nodes" request to the given bootstrap node with IP, port, and public key to setup connections.

        This function will attempt to connect to the node using UDP. You must use this function even if
        Tox_Options.udp_enabled was set to false.

        :param address: The hostname or IP address (IPv4 or IPv6) of the node.
        :param port: The port on the host on which the bootstrap Tox instance is listening.
        :param public_key: The long term public key of the bootstrap node (TOX_PUBLIC_KEY_SIZE bytes).
        :return: True on success.
        """
        tox_err_bootstrap = c_int()
        print(address)
        result = Tox.libtoxcore.tox_bootstrap(self._tox_pointer, c_char_p(str.encode(address)), c_uint16(port),
                                              string_to_bin(public_key), byref(tox_err_bootstrap))
        tox_err_bootstrap = tox_err_bootstrap.value
        if tox_err_bootstrap == TOX_ERR_BOOTSTRAP['OK']:
            return bool(result)
        elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['NULL']:
            raise ArgumentError('One of the arguments to the function was NULL when it was not expected.')
        elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['BAD_HOST']:
            raise ArgumentError('The address could not be resolved to an IP '
                                'address, or the IP address passed was invalid.')
        elif tox_err_bootstrap == TOX_ERR_BOOTSTRAP['BAD_PORT']:
            raise ArgumentError('The port passed was invalid. The valid port range is (1, 65535).')
toxav.py 文件源码 项目:milisia-tox 作者: milisarge 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def callback_video_receive_frame(self, callback, user_data):
        """
        Set the callback for the `video_receive_frame` event. Pass None to unset.

        :param callback: Python function.
        The function type for the video_receive_frame callback.

        Should take
        toxAV           pointer (c_void_p) to ToxAV object,
        friend_number   The friend number (c_uint32) of the friend who sent a video frame.
        width           Width (c_uint16) of the frame in pixels.
        height          Height (c_uint16) of the frame in pixels.
        y
        u
        v               Plane data (POINTER(c_uint8)).
                            The size of plane data is derived from width and height where
                            Y = MAX(width, abs(ystride)) * height,
                            U = MAX(width/2, abs(ustride)) * (height/2) and
                            V = MAX(width/2, abs(vstride)) * (height/2).
        ystride
        ustride
        vstride         Strides data (c_int32). Strides represent padding for each plane that may or may not be present. You must
                        handle strides in your image processing code. Strides are negative if the image is bottom-up
                        hence why you MUST abs() it when calculating plane buffer size.
        user_data       pointer (c_void_p) to user_data
        :param user_data: pointer (c_void_p) to user data
        """
        c_callback = CFUNCTYPE(None, c_void_p, c_uint32, c_uint16, c_uint16, POINTER(c_uint8), POINTER(c_uint8),
                               POINTER(c_uint8), c_int32, c_int32, c_int32, c_void_p)
        self.video_receive_frame_cb = c_callback(callback)
        ToxAV.libtoxav.toxav_callback_video_receive_frame(self._toxav_pointer, self.video_receive_frame_cb, user_data)
nsf2x.py 文件源码 项目:nsf2x 作者: adb014 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def NSFNoteGetInfo(self, hNote, flags):
        self.__isLoaded()
        retval = ctypes.c_uint16(0)
        self.nnotesdll.NSFNoteGetInfo(hNote, flags, ctypes.byref(retval))
        return retval
c.py 文件源码 项目:kotori 作者: daq-tools 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def setup(self):

        # counter "ValueError: number of bits invalid for bit field"
        monkeypatch_pyclibrary_ctypes_struct()

        # register header- and library paths
        # https://pyclibrary.readthedocs.org/en/latest/get_started/configuration.html#specifying-headers-and-libraries-locations
        # TODO: this probably acts on a global basis; think about it
        if self.include_path:
            add_header_locations([self.include_path])
        if self.library_path:
            add_library_locations([self.library_path])

        # define extra types suitable for embedded use
        types = {
            'uint8_t': c_uint8,
            'uint16_t': c_uint16,
            'uint32_t': c_uint32,
            'int8_t': c_int8,
            'int16_t': c_int16,
            'int32_t': c_int32,
            }

        # TODO: this probably acts on a global basis; think about it
        if not (CParser._init or CLibrary._init):
            auto_init(extra_types=types)
stream.py 文件源码 项目:pyrealsense 作者: toinsson 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, name='depth', width=640, height=480, fps=30):
        self.native = True
        self.stream = rs_stream.RS_STREAM_DEPTH
        self.format = rs_format.RS_FORMAT_Z16
        self.shape = (height, width)
        self.dtype = ctypes.c_uint16
        super(DepthStream, self).__init__(name, self.native, self.stream, width, height, self.format, fps)
stream.py 文件源码 项目:pyrealsense 作者: toinsson 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __init__(self, name='dac', width=640, height=480, fps=30):
        self.native = False
        self.stream = rs_stream.RS_STREAM_DEPTH_ALIGNED_TO_COLOR
        self.format = rs_format.RS_FORMAT_Z16
        self.shape = (height, width)
        self.dtype = ctypes.c_uint16
        super(DACStream, self).__init__(name, self.native, self.stream, width, height, self.format, fps)
core.py 文件源码 项目:pyrealsense 作者: toinsson 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _get_pointcloud(self):
        ds = [s for s in self.streams if type(s) is DepthStream][0]

        e = ctypes.POINTER(rs_error)()
        lrs.rs_get_frame_data.restype = ndpointer(dtype=ctypes.c_uint16, shape=(ds.height, ds.width))
        depth = lrs.rs_get_frame_data(self.dev, rs_stream.RS_STREAM_DEPTH, ctypes.byref(e))

        pointcloud = np.zeros((ds.height * ds.width * 3), dtype=np.float32)

        # ugly fix for outliers
        depth[0, :2] = 0

        rsutilwrapper.deproject_depth(pointcloud, self.depth_intrinsics, depth, self.depth_scale)
        return pointcloud.reshape((ds.height, ds.width, 3))
list_ports_osx.py 文件源码 项目:Jackal_Velodyne_Duke 作者: MengGuo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_int_property(device_type, property, cf_number_type):
    """
    Search the given device for the specified string property

    @param device_type Device to search
    @param property String to search for
    @param cf_number_type CFType number

    @return Python string containing the value, or None if not found.
    """
    key = cf.CFStringCreateWithCString(
            kCFAllocatorDefault,
            property.encode("mac_roman"),
            kCFStringEncodingMacRoman)

    CFContainer = iokit.IORegistryEntryCreateCFProperty(
            device_type,
            key,
            kCFAllocatorDefault,
            0)

    if CFContainer:
        if (cf_number_type == kCFNumberSInt32Type):
            number = ctypes.c_uint32()
        elif (cf_number_type == kCFNumberSInt16Type):
            number = ctypes.c_uint16()
        cf.CFNumberGetValue(CFContainer, cf_number_type, ctypes.byref(number))
        cf.CFRelease(CFContainer)
        return number.value
    return None
list_ports_osx.py 文件源码 项目:Jackal_Velodyne_Duke 作者: MengGuo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_int_property(device_type, property, cf_number_type):
    """
    Search the given device for the specified string property

    @param device_type Device to search
    @param property String to search for
    @param cf_number_type CFType number

    @return Python string containing the value, or None if not found.
    """
    key = cf.CFStringCreateWithCString(
            kCFAllocatorDefault,
            property.encode("mac_roman"),
            kCFStringEncodingMacRoman)

    CFContainer = iokit.IORegistryEntryCreateCFProperty(
            device_type,
            key,
            kCFAllocatorDefault,
            0)

    if CFContainer:
        if (cf_number_type == kCFNumberSInt32Type):
            number = ctypes.c_uint32()
        elif (cf_number_type == kCFNumberSInt16Type):
            number = ctypes.c_uint16()
        cf.CFNumberGetValue(CFContainer, cf_number_type, ctypes.byref(number))
        cf.CFRelease(CFContainer)
        return number.value
    return None
color2.py 文件源码 项目:PyLetMeCreate 作者: CreatorDev 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_color():
    """Returns the rgb color measurement as a tuple.

    Note: An exception is thrown if it fails to get a measurement from
    the click.
    """
    red = ctypes.c_uint16(0)
    green = ctypes.c_uint16(0)
    blue = ctypes.c_uint16(0)
    ret = _LIB.color2_click_get_color(ctypes.byref(red),
                                      ctypes.byref(green),
                                      ctypes.byref(blue))
    if ret < 0:
        raise Exception("color2 click get color failed")
    return (red.value, green.value, blue.value)
co.py 文件源码 项目:PyLetMeCreate 作者: CreatorDev 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_measure(mikrobus_index):
    """Measure the CO concentration in the air using the CO click.

    mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)

    Note: An exception is thrown if it fails to communicate with the CO click.
    """
    value = ctypes.c_uint16(0)
    ret = _LIB.co_click_get_measure(mikrobus_index, ctypes.byref(value))
    if ret < 0:
        raise Exception("co click read ppm failed")
    return value.value
lin_hall.py 文件源码 项目:PyLetMeCreate 作者: CreatorDev 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_measure():
    """Read 12bit measurement from LIN Hall Click.

    Note: An exception is thrown if it fails.
    """
    measure = ctypes.c_uint16(0)
    ret = _LIB.lin_hall_click_get_measure(ctypes.byref(measure))
    if ret < 0:
        raise Exception("LIN HALL get measure failed")
    return measure.value
adc.py 文件源码 项目:PyLetMeCreate 作者: CreatorDev 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_raw_value(channel):
    """Read raw value from ADC Click in range 0..4095

    channel: must be in range 0-3. Channel 2 is not available on Ci40.

    Note: An exception is thrown if it fails to communicate with the click.
    """
    value = ctypes.c_uint16(0)
    ret = _LIB.adc_click_get_raw_value(channel, ctypes.byref(value))
    if ret < 0:
        raise Exception("adc click get raw value failed")
    return value.value
alcohol.py 文件源码 项目:PyLetMeCreate 作者: CreatorDev 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_measure(mikrobus_index):
    """Returns a 16-bit integer from the Accel Click.

    mikrobus_index: must be 0 (MIKROBUS_1) or 1 (MIKROBUS_2)

    Note: An exception is thrown if it fails to get a measure from the click.
    """
    measure = ctypes.c_uint16(0)
    ret = _LIB.alcohol_click_get_measure(mikrobus_index, ctypes.byref(measure))
    if ret < 0:
        raise Exception("alcohol click get measure failed")
    return measure.value


问题


面经


文章

微信
公众号

扫码关注公众号