How to use the pyads.constants.ADSIGRP_SYM_VALBYHND function in pyads

To help you get started, we’ve selected a few pyads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stlehmann / pyads / pyads / testserver_ex.py View on Github external
def handle_read():
            data = request.ams_header.data

            index_group = struct.unpack('
github stlehmann / pyads / pyads / testserver_ex / handler.py View on Github external
def handle_read():
            data = request.ads_data
            index_group = struct.unpack('
github stlehmann / pyads / pyads / testserver.py View on Github external
def handle_read():
            data = request.ads_data

            index_group = struct.unpack('
github stlehmann / pyads / pyads / testserver.py View on Github external
"""Handle read request."""
            data = request.ams_header.data

            index_group = struct.unpack("
github stlehmann / pyads / pyads / pyads_ex.py View on Github external
adsSyncAddDeviceNotificationReqFct = _adsDLL.AdsSyncAddDeviceNotificationReqEx

    pAmsAddr = ctypes.pointer(adr.amsAddrStruct())
    if isinstance(data, str):
        hnl = adsSyncReadWriteReqEx2(
            port,
            adr,
            ADSIGRP_SYM_HNDBYNAME,
            0x0,
            PLCTYPE_UDINT,
            data,
            PLCTYPE_STRING,
        )

        nIndexGroup = ctypes.c_ulong(ADSIGRP_SYM_VALBYHND)
        nIndexOffset = ctypes.c_ulong(hnl)
    elif isinstance(data, tuple):
        nIndexGroup = data[0]
        nIndexOffset = data[1]
        hnl = None
    else:
        raise TypeError("Parameter data has the wrong type %s. Allowed types are: str, Tuple[int, int]." % (type(data)))

    attrib = pNoteAttrib.notificationAttribStruct()
    pNotification = ctypes.c_ulong()

    nHUser = ctypes.c_ulong(0)
    if hnl is not None:
        nHUser = ctypes.c_ulong(hnl)
    if user_handle is not None:
        nHUser = ctypes.c_ulong(user_handle)
github stlehmann / pyads / pyads / pyads.py View on Github external
:param pyads.structs.AmsAddr adr: local or remote AmsAddr
    :param string dataName: data name
    :param int plcDataType: type of the data given to the PLC, according to
        PLCTYPE constants
    :rtype: PLCTYPE
    :return: value: **value**

    """
    # Get the handle of the PLC-variable
    hnl = adsSyncReadWriteReq(
        adr, ADSIGRP_SYM_HNDBYNAME, 0x0, PLCTYPE_UDINT, dataName, PLCTYPE_STRING
    )

    # Read the value of a PLC-variable, via handle
    value = adsSyncReadReq(adr, ADSIGRP_SYM_VALBYHND, hnl, plcDataType)

    # Release the handle of the PLC-variable
    adsSyncWriteReq(adr, ADSIGRP_SYM_RELEASEHND, 0, hnl, PLCTYPE_UDINT)

    return value

github stlehmann / pyads / pyads / pyads_ex.py View on Github external
of the read data type (default: True)
    :rtype: data_type
    :return: value: **value**

    """
    if handle is None:
        no_handle = True
        handle = adsGetHandle(port, address, data_name)
    else:
        no_handle = False

    # Read the value of a PLC-variable, via handle
    value = adsSyncReadReqEx2(
        port,
        address,
        ADSIGRP_SYM_VALBYHND,
        handle,
        data_type,
        return_ctypes,
        check_length,
    )

    if no_handle is True:
        adsReleaseHandle(port, address, handle)

    return value
github stlehmann / pyads / pyads / pyads.py View on Github external
:param NotificationAttrib pNoteAttrib: notification settings
    :param Callable callback: callback function
    :param int user_handle: user handle

    :rtype: Tuple[int, int]
    :return: notification handle, user handle
    """
    global callback_store  # use global variable to prevent garbage collection
    adsSyncAddDeviceNotificationReqFct = _adsDLL.AdsSyncAddDeviceNotificationReq

    pAmsAddr = ctypes.pointer(adr.amsAddrStruct())
    hnl = adsSyncReadWriteReq(
        adr, ADSIGRP_SYM_HNDBYNAME, 0x0, PLCTYPE_UDINT, data_name, PLCTYPE_STRING
    )

    nIndexGroup = ctypes.c_ulong(ADSIGRP_SYM_VALBYHND)
    nIndexOffset = ctypes.c_ulong(hnl)
    attrib = pNoteAttrib.notificationAttribStruct()

    pNotification = ctypes.c_ulong()
    nHUser = ctypes.c_ulong(hnl)
    if user_handle is not None:
        nHUser = ctypes.c_ulong(user_handle)

    if NOTEFUNC is None:
        raise TypeError("Callback function type can't be None")
    adsSyncAddDeviceNotificationReqFct.argtypes = [
        ctypes.POINTER(SAmsAddr),
        ctypes.c_ulong,
        ctypes.c_ulong,
        ctypes.POINTER(SAdsNotificationAttrib),
        NOTEFUNC,
github stlehmann / pyads / pyads / pyads_ex.py View on Github external
:param int port: local AMS port as returned by adsPortOpenEx()
    :param pyads.structs.AmsAddr address: local or remote AmsAddr
    :param string data_name: PLC storage name
    :param value: value to write to the storage address of the PLC
    :param Type data_type: type of the data given to the PLC,
        according to PLCTYPE constants
    :param int handle: PLC-variable handle (default: None)
    """
    if handle is None:
        no_handle = True
        handle = adsGetHandle(port, address, data_name)
    else:
        no_handle = False

    # Write the value of a PLC-variable, via handle
    adsSyncWriteReqEx(port, address, ADSIGRP_SYM_VALBYHND, handle, value, data_type)

    if no_handle is True:
        adsReleaseHandle(port, address, handle)
github stlehmann / pyads / pyads / pyads.py View on Github external
"""Send data synchronous to an ADS-device from data name.

    :param pyads.structs.AmsAddr adr: local or remote AmsAddr
    :param string dataName: PLC storage address
    :param value: value to write to the storage address of the PLC
    :param int plcDataType: type of the data given to the PLC,
        according to PLCTYPE constants

    """
    # Get the handle of the PLC-variable
    hnl = adsSyncReadWriteReq(
        adr, ADSIGRP_SYM_HNDBYNAME, 0x0, PLCTYPE_UDINT, dataName, PLCTYPE_STRING
    )

    # Write the value of a PLC-variable, via handle
    adsSyncWriteReq(adr, ADSIGRP_SYM_VALBYHND, hnl, value, plcDataType)

    # Release the handle of the PLC-variable
    adsSyncWriteReq(adr, ADSIGRP_SYM_RELEASEHND, 0, hnl, PLCTYPE_UDINT)