pycomm3
- A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.#
Introduction#
pycomm3
started as a Python 3 fork of pycomm, which is a Python 2 library for
communicating with Allen-Bradley PLCs using Ethernet/IP. The initial Python 3 port was done
in this fork and was used as the base for pycomm3
. Since then, the library has been
almost entirely rewritten and the API is no longer compatible with pycomm
. Without the
hard work done by the original pycomm
developers, pycomm3
would not exist. This
library seeks to expand upon their great work.
Drivers#
pycomm3
includes 3 drivers:
- CIPDriver
This driver is the base driver for the library, it handles common CIP services used by the other drivers. Things like opening/closing a connection, register/unregister sessions, forward open/close services, device discovery, and generic messaging. It can be used to connect to any Ethernet/IP device, like: drives, switches, meters, and other non-PLC devices.
- LogixDriver
This driver supports services specific to ControlLogix, CompactLogix, and Micro800 PLCs. Services like reading/writing tags, uploading the tag list, and getting/setting the PLC time.
- SLCDriver
This driver supports basic reading/writing data files in a SLC500 or MicroLogix PLCs. It is a port of the
SlcDriver
frompycomm
with minimal changes to make the API similar to the other drivers. Currently this driver is considered legacy and it’s development will be on a limited basis.
Disclaimer#
PLCs can be used to control heavy or dangerous equipment, this library is provided “as is” and makes no guarantees on its reliability in a production environment. This library makes no promises in the completeness or correctness of the protocol implementations and should not be solely relied upon for critical systems. The development for this library is aimed at providing quick and convenient access for reading/writing data inside Allen-Bradley PLCs.
Setup#
The package can be installed from PyPI using pip
: pip install pycomm3
or python -m pip install pycomm3
.
Optionally, you may configure logging using the Python standard logging library. A convenience method is provided to help configure basic logging, see the Logging Section in the docs for more information.
Python and OS Support#
pycomm3
is a Python 3-only library and is supported on Python versions from 3.6.1 up to 3.10.
There should be no OS-specific requirements and should be able to run on any OS that Python is supported on.
Development and testing is done primarily on Windows 10. If you encounter an OS-related problem, please open an issue
in the GitHub repository and it will be investigated.
Attention
Python 3.6.0 is not supported due to NamedTuple
not supporting
default values and methods until 3.6.1
Contents#
- Getting Started
- Driver Usage
- Examples
- API Reference
- CIPDriver API
- LogixDriver API
LogixDriver
LogixDriver.__init__()
LogixDriver.open()
LogixDriver.revision_major
LogixDriver.tags
LogixDriver.tags_json
LogixDriver.data_types
LogixDriver.connected
LogixDriver.info
LogixDriver.name
LogixDriver.get_plc_name()
LogixDriver.get_plc_info()
LogixDriver.get_plc_time()
LogixDriver.set_plc_time()
LogixDriver.get_tag_list()
LogixDriver.read()
LogixDriver.write()
LogixDriver.get_tag_info()
- SLCDriver API
- Data Types
DataType
ElementaryDataType
BOOL
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
STIME
DATE
TIME_OF_DAY
DATE_AND_TIME
StringDataType
LOGIX_STRING
STRING
BytesDataType
n_bytes()
BitArrayType
BYTE
WORD
DWORD
LWORD
STRING2
FTIME
LTIME
ITIME
STRINGN
SHORT_STRING
TIME
EPATH
PACKED_EPATH
PADDED_EPATH
ENGUNIT
STRINGI
DerivedDataType
ArrayType
StructType
CIPSegment
PortSegment
LogicalSegment
NetworkSegment
SymbolicSegment
DataSegment
ConstructedDataTypeSegment
ElementaryDataTypeSegment
DataTypes
DataTypes.bool
DataTypes.sint
DataTypes.int
DataTypes.dint
DataTypes.lint
DataTypes.usint
DataTypes.uint
DataTypes.udint
DataTypes.ulint
DataTypes.real
DataTypes.lreal
DataTypes.stime
DataTypes.date
DataTypes.time_of_day
DataTypes.date_and_time
DataTypes.logix_string
DataTypes.string
DataTypes.byte
DataTypes.word
DataTypes.dword
DataTypes.lword
DataTypes.string2
DataTypes.ftime
DataTypes.ltime
DataTypes.itime
DataTypes.stringn
DataTypes.short_string
DataTypes.time
DataTypes.padded_epath
DataTypes.packed_epath
DataTypes.engunit
DataTypes.stringi
- Custom Types
- CIP Reference
- Contributing
- Release History