• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(4622)  |  Call(4188)  |  Derive(0)  |  Import(434)
byref(C instance[, offset=0]) -> byref-object
Return a pointer lookalike to a C instance, only usable
as function argument

src/p/y/pyserial-HEAD/trunk/pyserial/examples/scanwin32.py   pyserial(Download)
    flags = DIGCF_DEVICEINTERFACE
    if available_only:
        flags |= DIGCF_PRESENT
    g_hdi = SetupDiGetClassDevs(ctypes.byref(GUID_CLASS_COMPORT), None, NULL, flags);
    #~ for i in range(256):
    for dwIndex in range(256):
        did = SP_DEVICE_INTERFACE_DATA()
        did.cbSize = ctypes.sizeof(did)
 
        if not SetupDiEnumDeviceInterfaces(
            g_hdi,
            None,
            ctypes.byref(GUID_CLASS_COMPORT),
            None,
            ctypes.byref(GUID_CLASS_COMPORT),
            dwIndex,
            ctypes.byref(did)
        ):
            if ctypes.GetLastError() != ERROR_NO_MORE_ITEMS:
                raise ctypes.WinError()
            break
 
        dwNeeded = DWORD()
        # get the size
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
            None, 0, ctypes.byref(dwNeeded),
            None
        ):
            # Ignore ERROR_INSUFFICIENT_BUFFER
        devinfo.cbSize = ctypes.sizeof(devinfo)
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
            ctypes.byref(idd), dwNeeded, None,
            ctypes.byref(devinfo)
        ):
            raise ctypes.WinError()
 
        # hardware ID
        szHardwareID = ctypes.create_string_buffer(250)
        if not SetupDiGetDeviceRegistryProperty(
            g_hdi,
            ctypes.byref(devinfo),
            ctypes.byref(devinfo),
            SPDRP_HARDWAREID,
            None,
            ctypes.byref(szHardwareID), ctypes.sizeof(szHardwareID) - 1,
            None
        ):
            # Ignore ERROR_INSUFFICIENT_BUFFER
        szFriendlyName = ctypes.create_string_buffer(1024)
        if not SetupDiGetDeviceRegistryProperty(
            g_hdi,
            ctypes.byref(devinfo),
            SPDRP_FRIENDLYNAME,
            None,
            ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1,
                szFriendlyName = ctypes.create_string_buffer(1024)
                if SetupDiGetDeviceRegistryProperty(
                    g_hdi,
                    ctypes.byref(devinfo),
                    SPDRP_LOCATION_INFORMATION,
                    None,
                    ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1,

src/p/y/pyserial-HEAD/pyserial/examples/scanwin32.py   pyserial(Download)
    flags = DIGCF_DEVICEINTERFACE
    if available_only:
        flags |= DIGCF_PRESENT
    g_hdi = SetupDiGetClassDevs(ctypes.byref(GUID_CLASS_COMPORT), None, NULL, flags);
    #~ for i in range(256):
    for dwIndex in range(256):
        did = SP_DEVICE_INTERFACE_DATA()
        did.cbSize = ctypes.sizeof(did)
 
        if not SetupDiEnumDeviceInterfaces(
            g_hdi,
            None,
            ctypes.byref(GUID_CLASS_COMPORT),
            None,
            ctypes.byref(GUID_CLASS_COMPORT),
            dwIndex,
            ctypes.byref(did)
        ):
            if ctypes.GetLastError() != ERROR_NO_MORE_ITEMS:
                raise ctypes.WinError()
            break
 
        dwNeeded = DWORD()
        # get the size
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
            None, 0, ctypes.byref(dwNeeded),
            None
        ):
            # Ignore ERROR_INSUFFICIENT_BUFFER
        devinfo.cbSize = ctypes.sizeof(devinfo)
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
            ctypes.byref(idd), dwNeeded, None,
            ctypes.byref(devinfo)
        ):
            raise ctypes.WinError()
 
        # hardware ID
        szHardwareID = ctypes.create_string_buffer(250)
        if not SetupDiGetDeviceRegistryProperty(
            g_hdi,
            ctypes.byref(devinfo),
            ctypes.byref(devinfo),
            SPDRP_HARDWAREID,
            None,
            ctypes.byref(szHardwareID), ctypes.sizeof(szHardwareID) - 1,
            None
        ):
            # Ignore ERROR_INSUFFICIENT_BUFFER
        szFriendlyName = ctypes.create_string_buffer(1024)
        if not SetupDiGetDeviceRegistryProperty(
            g_hdi,
            ctypes.byref(devinfo),
            SPDRP_FRIENDLYNAME,
            None,
            ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1,
                szFriendlyName = ctypes.create_string_buffer(1024)
                if SetupDiGetDeviceRegistryProperty(
                    g_hdi,
                    ctypes.byref(devinfo),
                    SPDRP_LOCATION_INFORMATION,
                    None,
                    ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1,

src/p/y/pyserial-2.5/examples/scanwin32.py   pyserial(Download)
    flags = DIGCF_DEVICEINTERFACE
    if available_only:
        flags |= DIGCF_PRESENT
    g_hdi = SetupDiGetClassDevs(ctypes.byref(GUID_CLASS_COMPORT), None, NULL, flags);
    #~ for i in range(256):
    for dwIndex in range(256):
        did = SP_DEVICE_INTERFACE_DATA()
        did.cbSize = ctypes.sizeof(did)
 
        if not SetupDiEnumDeviceInterfaces(
            g_hdi,
            None,
            ctypes.byref(GUID_CLASS_COMPORT),
            None,
            ctypes.byref(GUID_CLASS_COMPORT),
            dwIndex,
            ctypes.byref(did)
        ):
            if ctypes.GetLastError() != ERROR_NO_MORE_ITEMS:
                raise ctypes.WinError()
            break
 
        dwNeeded = DWORD()
        # get the size
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
            None, 0, ctypes.byref(dwNeeded),
            None
        ):
            # Ignore ERROR_INSUFFICIENT_BUFFER
        devinfo.cbSize = ctypes.sizeof(devinfo)
        if not SetupDiGetDeviceInterfaceDetail(
            g_hdi,
            ctypes.byref(did),
            ctypes.byref(idd), dwNeeded, None,
            ctypes.byref(devinfo)
        ):
            raise ctypes.WinError()
 
        # hardware ID
        szHardwareID = ctypes.create_string_buffer(250)
        if not SetupDiGetDeviceRegistryProperty(
            g_hdi,
            ctypes.byref(devinfo),
            ctypes.byref(devinfo),
            SPDRP_HARDWAREID,
            None,
            ctypes.byref(szHardwareID), ctypes.sizeof(szHardwareID) - 1,
            None
        ):
            # Ignore ERROR_INSUFFICIENT_BUFFER
        szFriendlyName = ctypes.create_string_buffer(1024)
        if not SetupDiGetDeviceRegistryProperty(
            g_hdi,
            ctypes.byref(devinfo),
            SPDRP_FRIENDLYNAME,
            None,
            ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1,
                szFriendlyName = ctypes.create_string_buffer(1024)
                if SetupDiGetDeviceRegistryProperty(
                    g_hdi,
                    ctypes.byref(devinfo),
                    SPDRP_LOCATION_INFORMATION,
                    None,
                    ctypes.byref(szFriendlyName), ctypes.sizeof(szFriendlyName) - 1,

src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjdenx.py   pysundials(Download)
cvadj_mem = cvodes.CVadjMalloc(cvode_mem, steps, cvodes.CV_HERMITE)
 
print "Forward integration ... "
cvodes.CVodeF(cvadj_mem, 4.0e7, y, ctypes.byref(time), cvodes.CV_NORMAL, ctypes.byref(ncheck))
print "done ( nst = %ld )"%(cvodes.CVodeGetNumSteps(cvode_mem))
cvodes.CVodeGetQuad(cvode_mem, 4.0e7, q)
print "--------------------------------------------------------"
cvodes.CVodeSetQuadErrConB(cvadj_mem, True, cvodes.CV_SS, reltolB, abstolQB)
 
print "Backward integration ...",
cvodes.CVodeB(cvadj_mem, 0.0, yB, ctypes.byref(time), cvodes.CV_NORMAL)
print "done ( nst = %ld )"%(cvodes.CVodeGetNumSteps(cvodes.CVadjGetCVodeBmem(cvadj_mem)))
cvodes.CVodeGetQuadB(cvadj_mem, qB)
PrintOutput(4.0e7, yB, qB)
cvodes.CVodeQuadReInitB(cvadj_mem, fQB, qB) 
 
print "Backward integration ...",
cvodes.CVodeB(cvadj_mem, 0.0, yB, ctypes.byref(time), cvodes.CV_NORMAL)
print "done ( nst = %ld )"%(cvodes.CVodeGetNumSteps(cvodes.CVadjGetCVodeBmem(cvadj_mem)))
cvodes.CVodeGetQuadB(cvadj_mem, qB)
PrintOutput(50.0, yB, qB)

src/d/a/DAQpy-HEAD/examples/test_system.py   DAQpy(Download)
		with daqmx.start_task(taskHandle):
			value = ctypes.c_double()
			for i in xrange(samples):
				c_daqmx.DAQmxReadAnalogScalarF64(taskHandle, 10.0, ctypes.byref(value), None)
 
 
@test_utils.report_results
			value = ctypes.c_double()
			isLate = ctypes.c_uint32()
			for i in xrange(samples):
				c_daqmx.DAQmxReadAnalogScalarF64(taskHandle, 10.0, ctypes.byref(value), None)
				c_daqmx.DAQmxWaitForNextSampleClock(taskHandle, 10, ctypes.byref(isLate))
				assert isLate.value == 0, "%d" % isLate.value
 
				DataBuffer = ctypes.c_double * DATA_BUFFER_SIZE
				data = DataBuffer()
				samplesRead = ctypes.c_int()
				c_daqmx.DAQmxReadAnalogF64(taskHandle, DATA_BUFFER_SIZE, 10.0, c_daqmx.DAQmx_Val_GroupByChannel, data, DATA_BUFFER_SIZE, ctypes.byref(samplesRead), None)
				assert samplesRead.value == DATA_BUFFER_SIZE, "%s != %s" % (samplesRead.value, DATA_BUFFER_SIZE)
				totalSamples += samplesRead.value
			assert totalSamples == samplesPerChannel, "%s != %s" % (totalSamples, samplesPerChannel)
		samplesRead = ctypes.c_int()
 
		try:
			c_daqmx.DAQmxReadAnalogF64(taskHandle, DATA_BUFFER_SIZE, 10.0, c_daqmx.DAQmx_Val_GroupByChannel, data, DATA_BUFFER_SIZE, ctypes.byref(samplesRead), None)
		except daqmxutils.DAQmxError, e:
			self.__status = e.code
 

src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjkryx_pnt.py   pysundials(Download)
wdata.cvadj_mem = cvadj_mem;
 
print "\nForward integration"
cvodes.CVodeF(cvadj_mem, TOUT, c, ctypes.byref(t), cvodes.CV_NORMAL, ctypes.byref(ncheck))
 
print "\n   g = int_x int_y c%d(Tfinal,x,y) dx dy = %f \n"%(ISPEC, c[NEQ])
 
cvodes.CVSpilsSetPreconditionerB(cvadj_mem, PrecondB, PSolveB, ctypes.pointer(wdata))
 
print "\nBackward integration"
cvodes.CVodeB(cvadj_mem, T0, cB, ctypes.byref(t), cvodes.CV_NORMAL)
 
PrintOutput(cB, NS, MXNS, wdata)
 

src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjkryx_int.py   pysundials(Download)
wdata.cvadj_mem = cvadj_mem;
 
print "\nForward integration"
cvodes.CVodeF(cvadj_mem, TOUT, c, ctypes.byref(t), cvodes.CV_NORMAL, ctypes.byref(ncheck))
 
print "\n   G = int_t int_x int_y c%d(t,x,y) dx dy dt = %f \n"%(ISPEC, c[NEQ])
 
cvodes.CVSpilsSetPreconditionerB(cvadj_mem, PrecondB, PSolveB, ctypes.pointer(wdata))
 
print "\nBackward integration"
cvodes.CVodeB(cvadj_mem, T0, cB, ctypes.byref(t), cvodes.CV_NORMAL)
 
PrintOutput(cB, NS, MXNS, wdata)
 

src/p/y/pysundials-HEAD/2.3.0/examples/cvodes/serial/cvsadjbanx.py   pysundials(Download)
cvadj_mem = cvodes.CVadjMalloc(cvode_mem, NSTEP, cvodes.CV_HERMITE)
 
print "\nForward integration"
cvodes.CVodeF(cvadj_mem, TOUT, u, ctypes.byref(t), cvodes.CV_NORMAL, ctypes.byref(ncheck))
 
reltolB = RTOLB
abstolB = ATOL
cvodes.CVBandSetJacFnB(cvadj_mem, JacB, ctypes.pointer(data))
 
print "\nBackward integration"
cvodes.CVodeB(cvadj_mem, T0, uB, ctypes.byref(t), cvodes.CV_NORMAL)
 
PrintOutput(uB, data)
 

src/p/y/python-cookbook-HEAD/cb2_examples/cb2_17_4_sol_1.py   python-cookbook(Download)
from ctypes import windll, c_int, c_string, byref
# load 'Ehllapi.dll' (from current dir), and function 'hllapi' from the DLL
Ehllap32 = windll.ehllapi
hllapi = Ehllap32.hllapi
# prepare the arguments with types and initial values
h_func = c_int(1)
h_text = c_string('A')
h_len = c_int(1)
h_ret = c_int(999)
# call the function
hllapi(byref(h_func), h_text, byref(h_len), byref(h_ret))

src/p/y/py_examples-HEAD/opencv/CVtypes.py   py_examples(Download)
# --- Importe ----------------------------------------------------------------
 
import ctypes, os
from ctypes import Structure, Union, POINTER, SetPointerType, CFUNCTYPE, cdll, byref
from ctypes import c_char_p, c_double, c_float, c_byte, c_ubyte, c_int, c_void_p, c_ulong
from ctypes import c_uint32, c_short, c_char, c_longlong
 
    def from_param(self, param):
        return byref(param)
 
class CallableToFunc(object):
    '''Make the callable argument into a C callback'''
    def __init__(self, cbacktype):
        self.cbacktype = cbacktype

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next