CIPDriver API#
- class pycomm3.CIPDriver(path, *args, **kwargs)[source]#
A base CIP driver for the SLCDriver and LogixDriver classes. Implements common CIP services like (un)registering sessions, forward open/close, generic messaging, etc.
- property connected: bool#
Read-Only Property to check whether or not a connection is open.
- Return type:
bool
- Returns:
True if a connection is open, False otherwise
- property connection_size#
CIP connection size,
4000
if using Extended Forward Open else500
- classmethod list_identity(path)[source]#
Uses the ListIdentity service to identify the target
- Return type:
Optional
[str
]- Returns:
device identity if reply contains valid response else None
- classmethod discover()[source]#
Discovers available devices on the current network(s). Returns a list of the discovered devices Identity Object (as
dict
).- Return type:
List
[Dict
[str
,Any
]]
- get_module_info(slot)[source]#
Get the Identity object for a given slot in the rack of the current connection
- Return type:
dict
- open()[source]#
Creates a new Ethernet/IP socket connection to target device and registers a CIP session.
- Returns:
True if successful, False otherwise
- generic_message(service, class_code, instance, attribute=b'', request_data=b'', data_type=None, name='generic', connected=True, unconnected_send=False, route_path=True, **kwargs)[source]#
Perform a generic CIP message. Similar to how MSG instructions work in Logix.
- Parameters:
service (
Union
[int
,bytes
]) – service code for the request (single byte)class_code (
Union
[int
,bytes
]) – request object class IDinstance (
Union
[int
,bytes
]) – ID for an instance of the class If set with 0, request class attributes.attribute (
Union
[int
,bytes
]) – (optional) attribute ID for the service/class/instancerequest_data (
Any
) – (optional) any additional data required for the request.data_type (
Union
[Type
[DataType
],DataType
,None
]) – aDataType
class that will be used to decode the response, None to return just bytesname (
str
) – returnTag.tag
value, arbitrary but can be used for tracking returned Tagsconnected (
bool
) –True
if service required a CIP connection (forward open),False
to use UCMMunconnected_send (
bool
) – (Unconnected Only) wrap service in an UnconnectedSend serviceroute_path (
Union
[bool
,Sequence
[CIPSegment
],bytes
,str
]) – (Unconnected Only)True
to use current connection route to destination,False
to ignore, Or provide a path string, list of segments to be encoded as a PADDED_EPATH, or an already encoded path.
- Return type:
- Returns:
a Tag with the result of the request. (Tag.value for writes will be the request_data)