Beispiel #1
0
 def set_user_handle_type(self, user_handle):
     # Actually, it's not necessary to change ViHndlr *globally*.  However,
     # I don't want to break symmetry too much with all the other VPP43
     # routines.
     global ViHndlr
     if user_handle is None:
         user_handle_p = c_void_p
     else:
         user_handle_p = POINTER(type(user_handle))
     ViHndlr = FUNCTYPE(types.ViStatus, types.ViSession, types.ViEventType,
                        types.ViEvent, user_handle_p)
     self.__lib.viInstallHandler.argtypes = [
         types.ViSession, types.ViEventType, ViHndlr, user_handle_p
     ]
     self.__lib.viUninstallHandler.argtypes = [
         types.ViSession, types.ViEventType, ViHndlr, user_handle_p
     ]
    @property
    def fw_version(self): return self.m_dwFwVersionEx

    @property
    def product_code(self): return self.m_dwProductCode

    @property
    def unique_id(self): return self.m_dwUniqueId0, self.m_dwUniqueId1, self.m_dwUniqueId2, self.m_dwUniqueId3

    @property
    def flags(self): return self.m_dwFlags


# void PUBLIC UcanCallbackFktEx (Handle UcanHandle_p, DWORD dwEvent_p,
#                                BYTE bChannel_p, void* pArg_p);
CallbackFktEx = FUNCTYPE(None, Handle, DWORD, BYTE, LPVOID)


class HardwareInitInfo(Structure):
    """
    Structure including information about the enumeration of USB-CANmoduls.

    .. seealso:: :meth:`UcanServer.enumerate_hardware`

    .. note:: This structure is only used internally.
    """
    _pack_ = 1
    _fields_ = [
        ("m_dwSize", DWORD),  # size of this structure
        ("m_fDoInitialize", BOOL),  # specifies if the found module should be initialized by the DLL
        ("m_pUcanHandle", Handle),  # pointer to variable receiving the USB-CAN-Handle
Beispiel #3
0
import tellcore.constants as const


if platform.system() == 'Windows':
    from ctypes import WINFUNCTYPE as FUNCTYPE, windll as DllLoader
    LIBRARY_NAME = 'TelldusCore.dll'
else:
    from ctypes import CFUNCTYPE as FUNCTYPE, cdll as DllLoader
    if platform.system() == 'Darwin':
        from ctypes.util import find_library
        LIBRARY_NAME = find_library('TelldusCore') or \
            '/Library/Frameworks/TelldusCore.framework/TelldusCore'
    else:
        LIBRARY_NAME = 'libtelldus-core.so.2'

DEVICE_EVENT_FUNC = FUNCTYPE(
    None, c_int, c_int, c_char_p, c_int, c_void_p)
DEVICE_CHANGE_EVENT_FUNC = FUNCTYPE(
    None, c_int, c_int, c_int, c_int, c_void_p)
RAW_DEVICE_EVENT_FUNC = FUNCTYPE(
    None, c_char_p, c_int, c_int, c_void_p)
SENSOR_EVENT_FUNC = FUNCTYPE(
    None, c_char_p, c_char_p, c_int, c_int, c_char_p, c_int, c_int, c_void_p)
CONTROLLER_EVENT_FUNC = FUNCTYPE(
    None, c_int, c_int, c_int, c_char_p, c_int, c_void_p)


class TelldusError(Exception):
    """Error returned from Telldus Core API.

    Automatically raised when a function in the C API returns an error.