当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_ubyte方法代码示例

本文整理汇总了Python中ctypes.c_ubyte方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_ubyte方法的具体用法?Python ctypes.c_ubyte怎么用?Python ctypes.c_ubyte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_ubyte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: decrypt_ige

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def decrypt_ige(cipher_text, key, iv):
        aes_key = AES_KEY()
        key_len = ctypes.c_int(8 * len(key))
        key = (ctypes.c_ubyte * len(key))(*key)
        iv = (ctypes.c_ubyte * len(iv))(*iv)

        in_len = ctypes.c_size_t(len(cipher_text))
        in_ptr = (ctypes.c_ubyte * len(cipher_text))(*cipher_text)
        out_ptr = (ctypes.c_ubyte * len(cipher_text))()

        _libssl.AES_set_decrypt_key(key, key_len, ctypes.byref(aes_key))
        _libssl.AES_ige_encrypt(
            ctypes.byref(in_ptr),
            ctypes.byref(out_ptr),
            in_len,
            ctypes.byref(aes_key),
            ctypes.byref(iv),
            AES_DECRYPT
        )

        return bytes(out_ptr) 
开发者ID:LonamiWebs,项目名称:Telethon,代码行数:23,代码来源:libssl.py

示例2: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def __init__(self, eventHandler, freq, gain, cal):
        threading.Thread.__init__(self)
        self.name = 'Receive'
        self.daemon = True

        self._cancel = False
        self._freq = freq
        self._gain = gain
        self._cal = cal
        self._eventHandler = eventHandler
        self._sdr = None
        self._capture = (ctypes.c_ubyte * SAMPLES)()

        devices = rtlsdr.librtlsdr.rtlsdr_get_device_count()
        if devices == 0:
            event = Event(Events.SCAN_ERROR, msg='No device found')
            post_event(eventHandler, event)
        else:
            self.start() 
开发者ID:EarToEarOak,项目名称:RF-Monitor,代码行数:21,代码来源:receive.py

示例3: encrypt_ige

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def encrypt_ige(plain_text, key, iv):
        aes_key = AES_KEY()
        key_len = ctypes.c_int(8 * len(key))
        key = (ctypes.c_ubyte * len(key))(*key)
        iv = (ctypes.c_ubyte * len(iv))(*iv)

        in_len = ctypes.c_size_t(len(plain_text))
        in_ptr = (ctypes.c_ubyte * len(plain_text))(*plain_text)
        out_ptr = (ctypes.c_ubyte * len(plain_text))()

        _libssl.AES_set_encrypt_key(key, key_len, ctypes.byref(aes_key))
        _libssl.AES_ige_encrypt(
            ctypes.byref(in_ptr),
            ctypes.byref(out_ptr),
            in_len,
            ctypes.byref(aes_key),
            ctypes.byref(iv),
            AES_ENCRYPT
        )

        return bytes(out_ptr) 
开发者ID:LonamiWebs,项目名称:Telethon,代码行数:23,代码来源:libssl.py

示例4: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def __init__(self, logger, buf, media_id, stream, yuv_packed_buffer_pool,
                 session_metadata):
        self.logger = logger
        self._buf = buf
        self._media_id = media_id
        self._stream = stream
        self._yuv_packed_buffer_pool = yuv_packed_buffer_pool
        self._session_metadata = session_metadata
        self._pdraw_video_frame = od.POINTER_T(ctypes.c_ubyte)()
        self._frame_pointer = ctypes.POINTER(ctypes.c_ubyte)()
        self._frame_size = 0
        self._frame_array = None
        self._yuv_packed_buffer = od.POINTER_T(od.struct_vbuf_buffer)()
        self._yuv_packed_video_frame_storage = od.struct_pdraw_video_frame()
        self._yuv_packed_video_frame = od.POINTER_T(
            od.struct_pdraw_video_frame)()
        self._frame_info = None
        self._metadata_pointers = [] 
开发者ID:Parrot-Developers,项目名称:olympe,代码行数:20,代码来源:pdraw.py

示例5: MessageClass

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def MessageClass(length=DMX_LENGTH):
    assert 0 <= length <= DMX_LENGTH
    assert length % 2 == 0, 'artnet only takes messages of even length'

    Char, Int8, Int16 = ctypes.c_char, ctypes.c_ubyte, ctypes.c_ushort

    class DMXMessage(ctypes.Structure):
        # http://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf p47
        _fields_ = [
            ('id', Char * 8),
            ('opCode', Int16),
            ('protVerHi', Int8),
            ('protVerLo', Int8),
            ('sequence', Int8),
            ('physical', Int8),
            ('subUni', Int8),
            ('net', Int8),
            ('lengthHi', Int8),
            ('length', Int8),
            ('data', Int8 * length),  # At position 18
        ]

    return DMXMessage 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:25,代码来源:artnet_message.py

示例6: writer

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def writer(ring, start, count):
    for i in range(start, start + count):
        data = os.urandom(random.randint(1, 1000))
        time_micros = int(time.time() * 10**6)
        record = Record(
            write_number=i,
            timestamp_microseconds=time_micros,
            length=len(data))
        # Note: You can't pass 'data' to the constructor without doing an
        # additional copy to convert the bytes type to a c_ubyte * 1000. So
        # instead, the constructor will initialize the 'data' field's bytes
        # to zero, and then this assignment overwrites the data-sized part.
        record.data[:len(data)] = data

        try:
            ring.try_write(record)
        except ringbuffer.WaitingForReaderError:
            print('Reader is too slow, dropping %d' % i)
            continue

        if i and i % 100 == 0:
            print('Wrote %d so far' % i)

    ring.writer_done()
    print('Writer is done') 
开发者ID:bslatkin,项目名称:ringbuffer,代码行数:27,代码来源:example_ctypes.py

示例7: simxReadForceSensor

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxReadForceSensor(clientID, forceSensorHandle, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''
    state = ct.c_ubyte()
    forceVector  = (ct.c_float*3)()
    torqueVector = (ct.c_float*3)()
    ret = c_ReadForceSensor(clientID, forceSensorHandle, ct.byref(state), forceVector, torqueVector, operationMode)
    arr1 = []
    for i in range(3):
        arr1.append(forceVector[i])
    arr2 = []
    for i in range(3):
        arr2.append(torqueVector[i])
    if sys.version_info[0] == 3:
        state=state.value
    else:
        state=ord(state.value)
    return ret, state, arr1, arr2 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:21,代码来源:vrep.py

示例8: simxReadVisionSensor

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxReadVisionSensor(clientID, sensorHandle, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    detectionState = ct.c_ubyte()
    auxValues      = ct.POINTER(ct.c_float)()
    auxValuesCount = ct.POINTER(ct.c_int)()
    ret = c_ReadVisionSensor(clientID, sensorHandle, ct.byref(detectionState), ct.byref(auxValues), ct.byref(auxValuesCount), operationMode)
    
    auxValues2 = []
    if ret == 0:
        s = 0
        for i in range(auxValuesCount[0]):
            auxValues2.append(auxValues[s:s+auxValuesCount[i+1]])
            s += auxValuesCount[i+1]

        #free C buffers
        c_ReleaseBuffer(auxValues)
        c_ReleaseBuffer(auxValuesCount)

    return ret, bool(detectionState.value!=0), auxValues2 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:24,代码来源:vrep.py

示例9: simxReadProximitySensor

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxReadProximitySensor(clientID, sensorHandle, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    detectionState = ct.c_ubyte()
    detectedObjectHandle = ct.c_int()
    detectedPoint  = (ct.c_float*3)()
    detectedSurfaceNormalVector = (ct.c_float*3)()
    ret = c_ReadProximitySensor(clientID, sensorHandle, ct.byref(detectionState), detectedPoint, ct.byref(detectedObjectHandle), detectedSurfaceNormalVector, operationMode)
    arr1 = []
    for i in range(3):
        arr1.append(detectedPoint[i])
    arr2 = []
    for i in range(3):
        arr2.append(detectedSurfaceNormalVector[i])
    return ret, bool(detectionState.value!=0), arr1, detectedObjectHandle.value, arr2 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:19,代码来源:vrep.py

示例10: simxGetAndClearStringSignal

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxGetAndClearStringSignal(clientID, signalName, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    signalLength = ct.c_int();
    signalValue = ct.POINTER(ct.c_ubyte)()
    if (sys.version_info[0] == 3) and (type(signalName) is str):
        signalName=signalName.encode('utf-8')
    ret = c_GetAndClearStringSignal(clientID, signalName, ct.byref(signalValue), ct.byref(signalLength), operationMode)

    a = bytearray()
    if ret == 0:
        for i in range(signalLength.value):
            a.append(signalValue[i])
    if sys.version_info[0] != 3:
        a=str(a)

    return ret, a 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:21,代码来源:vrep.py

示例11: simxReadStringStream

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxReadStringStream(clientID, signalName, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    signalLength = ct.c_int();
    signalValue = ct.POINTER(ct.c_ubyte)()
    if (sys.version_info[0] == 3) and (type(signalName) is str):
        signalName=signalName.encode('utf-8')
    ret = c_ReadStringStream(clientID, signalName, ct.byref(signalValue), ct.byref(signalLength), operationMode)

    a = bytearray()
    if ret == 0:
        for i in range(signalLength.value):
            a.append(signalValue[i])
    if sys.version_info[0] != 3:
        a=str(a)

    return ret, a 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:21,代码来源:vrep.py

示例12: simxSetStringSignal

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxSetStringSignal(clientID, signalName, signalValue, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    sigV=signalValue
    if sys.version_info[0] == 3:
        if type(signalName) is str:
            signalName=signalName.encode('utf-8')
        if type(signalValue) is bytearray:
            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)
        if type(signalValue) is str:
            signalValue=signalValue.encode('utf-8')
            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)
    else:
        if type(signalValue) is bytearray:
            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)
        if type(signalValue) is str:
            signalValue=bytearray(signalValue)
            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)
    sigV=ct.cast(sigV,ct.POINTER(ct.c_ubyte)) # IronPython needs this
    return c_SetStringSignal(clientID, signalName, sigV, len(signalValue), operationMode) 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:24,代码来源:vrep.py

示例13: simxAppendStringSignal

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxAppendStringSignal(clientID, signalName, signalValue, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    sigV=signalValue
    if sys.version_info[0] == 3:
        if type(signalName) is str:
            signalName=signalName.encode('utf-8')
        if type(signalValue) is bytearray:
            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)
        if type(signalValue) is str:
            signalValue=signalValue.encode('utf-8')
            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)
    else:
        if type(signalValue) is bytearray:
            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)
        if type(signalValue) is str:
            signalValue=bytearray(signalValue)
            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)
    sigV=ct.cast(sigV,ct.POINTER(ct.c_ubyte)) # IronPython needs this
    return c_AppendStringSignal(clientID, signalName, sigV, len(signalValue), operationMode) 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:24,代码来源:vrep.py

示例14: simxWriteStringStream

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxWriteStringStream(clientID, signalName, signalValue, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    sigV=signalValue
    if sys.version_info[0] == 3:
        if type(signalName) is str:
            signalName=signalName.encode('utf-8')
        if type(signalValue) is bytearray:
            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)
        if type(signalValue) is str:
            signalValue=signalValue.encode('utf-8')
            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)
    else:
        if type(signalValue) is bytearray:
            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)
        if type(signalValue) is str:
            signalValue=bytearray(signalValue)
            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)
    sigV=ct.cast(sigV,ct.POINTER(ct.c_ubyte)) # IronPython needs this
    return c_WriteStringStream(clientID, signalName, sigV, len(signalValue), operationMode) 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:24,代码来源:vrep.py

示例15: simxReadForceSensor

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ubyte [as 别名]
def simxReadForceSensor(clientID, forceSensorHandle, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''
    state = ct.c_ubyte()
    forceVector  = (ct.c_float*3)()
    torqueVector = (ct.c_float*3)()
    ret = c_ReadForceSensor(clientID, forceSensorHandle, ct.byref(state), forceVector, torqueVector, operationMode)
    arr1 = []
    for i in range(3):
        arr1.append(forceVector[i])
    arr2 = []
    for i in range(3):
        arr2.append(torqueVector[i])
    #if sys.version_info[0] == 3:
    #    state=state.value
    #else:
    #    state=ord(state.value)
    return ret, state.value, arr1, arr2 
开发者ID:andyzeng,项目名称:visual-pushing-grasping,代码行数:21,代码来源:vrep.py


注:本文中的ctypes.c_ubyte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。