pycomm3/clx.py
def generic_message(self,
                        service: bytes,
                        class_code: bytes,
                        instance: bytes,
                        attribute: Optional[bytes] = b'',
                        request_data: Optional[bytes] = b'',
                        data_format: Optional[DataFormatType] = None,
                        name: str = 'generic',
                        connected: bool = True,
                        unconnected_send: bool = False,
                        route_path: Union[bool, bytes] = True) -> Tag:
        """
        Perform a generic CIP message.  Similar to how MSG instructions work in Logix.

        :param service: service code for the request (single byte)
        :param class_code: request object class ID
        :param instance: instance ID of the class
        :param attribute: (optional) attribute ID for the service/class/instance
        :param request_data: (optional) any additional data required for the request
        :param data_format: (reads only) If provided, a read response will automatically be unpacked into the attributes
                            defined, must be a sequence of tuples, (attribute name, data_type).
                            If name is ``None`` or an empty string, it will be ignored. If data-type is an ``int`` it will
                            not be unpacked, but left as ``bytes``.  Data will be returned as a ``dict``.
                            If ``None``, response data will be returned as just ``bytes``.
        :param name:  return ``Tag.tag`` value, arbitrary but can be used for tracking returned Tags
        :param connected: ``True`` if service required a CIP connection (forward open), ``False`` to use UCMM
        :param unconnected_send: (Unconnected Only) wrap service in an UnconnectedSend service
        :param route_path: (Unconnected Only) ``True`` to use current connection route to destination, ``False`` to ignore,
                           Or provide a packed EPATH (``bytes``) route to use.
        :return: a Tag with the result of the request. (Tag.value for writes will be the request_data)
        """

        if connected:
            with_forward_open(lambda _: None)(self)

        _kwargs = {
            'service': service,
            'class_code': class_code,
            'instance': instance,
            'attribute': attribute,
            'request_data': request_data,
            'data_format': data_format,
        }

        if not connected:
            if route_path is True:
                _kwargs['route_path'] = Pack.epath(self.attribs['cip_path'], pad_len=True)
            elif route_path:
                _kwargs['route_path'] = route_path

            _kwargs['unconnected_send'] = unconnected_send

        request = self.new_request('generic_connected' if connected else 'generic_unconnected')

        request.build(**_kwargs)

        response = request.send()

        return Tag(name, response.value, None, error=response.error)

        Perform a generic CIP message.  Similar to how MSG instructions work in Logix.

        :param service: service code for the request (single byte)
        :param class_code: request object class ID
        :param instance: instance ID of the class
        :param attribute: (optional) attribute ID for the service/class/instance
        :param request_data: (optional) any additional data required for the request
        :param data_format: (reads only) If provided, a read response will automatically be unpacked into the attributes
                            defined, must be a sequence of tuples, (attribute name, data_type).
                            If name is ``None`` or an empty string, it will be ignored. If data-type is an ``int`` it will
                            not be unpacked, but left as ``bytes``.  Data will be returned as a ``dict``.
                            If ``None``, response data will be returned as just ``bytes``.
        :param name:  return ``Tag.tag`` value, arbitrary but can be used for tracking returned Tags
        :param connected: ``True`` if service required a CIP connection (forward open), ``False`` to use UCMM
        :param unconnected_send: (Unconnected Only) wrap service in an UnconnectedSend service
        :param route_path: (Unconnected Only) ``True`` to use current connection route to destination, ``False`` to ignore,
                           Or provide a packed EPATH (``bytes``) route to use.
        :return: a Tag with the result of the request. (Tag.value for writes will be the request_data)
        
Perform a generic CIP message.  Similar to how MSG instructions work in Logix.
Perform a generic CIP message . Similar to how MSG instructions work in Logix .
def generic_message(self,
                        service: bytes,
                        class_code: bytes,
                        instance: bytes,
                        attribute: Optional[bytes] = b'',
                        request_data: Optional[bytes] = b'',
                        data_format: Optional[DataFormatType] = None,
                        name: str = 'generic',
                        connected: bool = True,
                        unconnected_send: bool = False,
                        route_path: Union[bool, bytes] = True) -> Tag:
        if connected:
            with_forward_open(lambda _: None)(self)
        _kwargs = {
            'service': service,
            'class_code': class_code,
            'instance': instance,
            'attribute': attribute,
            'request_data': request_data,
            'data_format': data_format,
        }
        if not connected:
            if route_path is True:
                _kwargs['route_path'] = Pack.epath(self.attribs['cip_path'], pad_len=True)
            elif route_path:
                _kwargs['route_path'] = route_path
            _kwargs['unconnected_send'] = unconnected_send
        request = self.new_request('generic_connected' if connected else 'generic_unconnected')
        request.build(**_kwargs)
        response = request.send()
        return Tag(name, response.value, None, error=response.error)
def generic_message ( self , service : bytes , class_code : bytes , instance : bytes , attribute : Optional [ bytes ] = b'' , request_data : Optional [ bytes ] = b'' , data_format : Optional [ DataFormatType ] = None , name : str = 'generic' , connected : bool = True , unconnected_send : bool = False , route_path : Union [ bool , bytes ] = True ) -> Tag : if connected : with_forward_open ( lambda _ : None ) ( self ) _kwargs = { 'service' : service , 'class_code' : class_code , 'instance' : instance , 'attribute' : attribute , 'request_data' : request_data , 'data_format' : data_format , } if not connected : if route_path is True : _kwargs [ 'route_path' ] = Pack . epath ( self . attribs [ 'cip_path' ] , pad_len = True ) elif route_path : _kwargs [ 'route_path' ] = route_path _kwargs [ 'unconnected_send' ] = unconnected_send request = self . new_request ( 'generic_connected' if connected else 'generic_unconnected' ) request . build ( ** _kwargs ) response = request . send ( ) return Tag ( name , response . value , None , error = response . error )
Perform a generic CIP message.
Perform a generic CIP message .
"""
        Perform a generic CIP message.  Similar to how MSG instructions work in Logix.

        :param service: service code for the request (single byte)
        :param class_code: request object class ID
        :param instance: instance ID of the class
        :param attribute: (optional) attribute ID for the service/class/instance
        :param request_data: (optional) any additional data required for the request
        :param data_format: (reads only) If provided, a read response will automatically be unpacked into the attributes
                            defined, must be a sequence of tuples, (attribute name, data_type).
                            If name is ``None`` or an empty string, it will be ignored. If data-type is an ``int`` it will
                            not be unpacked, but left as ``bytes``.  Data will be returned as a ``dict``.
                            If ``None``, response data will be returned as just ``bytes``.
        :param name:  return ``Tag.tag`` value, arbitrary but can be used for tracking returned Tags
        :param connected: ``True`` if service required a CIP connection (forward open), ``False`` to use UCMM
        :param unconnected_send: (Unconnected Only) wrap service in an UnconnectedSend service
        :param route_path: (Unconnected Only) ``True`` to use current connection route to destination, ``False`` to ignore,
                           Or provide a packed EPATH (``bytes``) route to use.
        :return: a Tag with the result of the request. (Tag.value for writes will be the request_data)
        """
a Tag with the result of the request. (Tag.value for writes will be the request_data)
a Tag with the result of the request . ( Tag . value for writes will be the request_data )
self
service
bytes
service code for the request (single byte)
service code for the request ( single byte )
class_code
bytes
request object class ID
request object class ID
instance
bytes
instance ID of the class
instance ID of the class
attribute
Optional[bytes]
(optional) attribute ID for the service/class/instance
( optional ) attribute ID for the service / class / instance
request_data
Optional[bytes]
(optional) any additional data required for the request
( optional ) any additional data required for the request
data_format
Optional[DataFormatType]
(reads only) If provided, a read response will automatically be unpacked into the attributes
defined, must be a sequence of tuples, (attribute name, data_type).
If name is ``None`` or an empty string, it will be ignored. If data-type is an ``int`` it will
not be unpacked, but left as ``bytes``.  Data will be returned as a ``dict``.
If ``None``, response data will be returned as just ``bytes``.
( reads only ) If provided a read response will automatically be unpacked into the attributes defined must be a sequence of tuples ( attribute name data_type ) . If name is ` ` None ` ` or an empty string it will be ignored . If data - type is an ` ` int ` ` it will not be unpacked but left as ` ` bytes ` ` . Data will be returned as a ` ` dict ` ` . If ` ` None ` ` response data will be returned as just ` ` bytes ` ` .
name
str
return ``Tag.tag`` value, arbitrary but can be used for tracking returned Tags
return ` ` Tag . tag ` ` value arbitrary but can be used for tracking returned Tags
connected
bool
``True`` if service required a CIP connection (forward open), ``False`` to use UCMM
` ` True ` ` if service required a CIP connection ( forward open ) ` ` False ` ` to use UCMM
unconnected_send
bool
(Unconnected Only) wrap service in an UnconnectedSend service
( Unconnected Only ) wrap service in an UnconnectedSend service
route_path
Union[bool, bytes]
(Unconnected Only) ``True`` to use current connection route to destination, ``False`` to ignore,
Or provide a packed EPATH (``bytes``) route to use.
( Unconnected Only ) ` ` True ` ` to use current connection route to destination ` ` False ` ` to ignore Or provide a packed EPATH ( ` ` bytes ` ` ) route to use .