Read / Write Values ​​Using Ethernet / IP

I recently purchased the ACS Linear Actuator (Tolomatic Stepper), which I am trying to send data from a Python application. The device itself communicates using the Ethernet / IP protocol.

I installed the cpppo library via pip. When I issue a command in an attempt to read the status of the device, I get None. Studying the connection with Wireshark, I see that it seems but is correct, but I notice a response from the device indicating: The service is not supported.

Sample code that I use to verify reading of the "Input Assembly":

from cpppo.server.enip import client

HOST = "192.168.1.100"
TAGS = ["@4/100/3"]

with client.connector(host=HOST) as conn:
    for index, descr, op, reply, status, value in conn.synchronous(
            operations=client.parse_operations(TAGS)):
        print(": %20s: %s" % (descr, value))

I expect to read the "input assembly", but it does not seem to work this way. I assume that I am missing something, as this is the first I tried to establish an Ethernet / IP connection.

, Ethernet/IP, .

+4
2

clutton - cpppo.

. () CIP-. ControlLogix/CompactLogix EtherNet/IP CIP, CIP-. , , , * Readix * Logix "Read Tag"; " Single/All", 8- . CIP REAL, INT, DINT ..

, " ". route_path = [] send_path = '' cpppo.server.enip.getattr attribute_operations ( cpppo.server.enip.client parse_operations):

from cpppo.server.enip import client
from cpppo.server.enip.getattr import attribute_operations

HOST = "192.168.1.100"
TAGS = ["@4/100/3"]

with client.connector(host=HOST) as conn:
    for index, descr, op, reply, status, value in conn.synchronous(
        operations=attribute_operations(
            TAGS, route_path=[], send_path='' )):
        print(": %20s: %s" % (descr, value))

!

cpppo, https://github.com/pjkundert/cpppo.git Git repo, , API . cpppo CIP REAL, , ...

...

Cpppo >= 3.9.0 cpppo.server.enip.get_attribute 'proxy' 'proxy_simple' CIP- (, ControlLogix, Compactlogix) - "" CIP (, MicroLogix, PowerFlex ..):

$ python
>>> from cpppo.server.enip.get_attribute import proxy_simple
>>> product_name, = proxy_simple( '10.0.1.2' ).read( [('@1/1/7','SSTRING')] )
>>> product_name
[u'1756-L61/C LOGIX5561']

, cpppo.server.enip.poll:

import logging
import sys
import time
import threading

from cpppo.server.enip import poll
from cpppo.server.enip.get_attribute import proxy_simple as device
params                  = [('@1/1/1','INT'),('@1/1/7','SSTRING')]

# If you have an A-B PowerFlex, try:
# from cpppo.server.enip.ab import powerflex_750_series as device
# parms                 = [ "Motor Velocity", "Output Current" ]

hostname                = '10.0.1.2'
values                  = {} # { <parameter>: <value>, ... }
poller                  = threading.Thread(
    target=poll.poll, args=(device,), kwargs={
        'address':      (hostname, 44818),
        'cycle':        1.0,
        'timeout':      0.5,
        'process':      lambda par,val: values.update( { par: val } ),
        'params':       params,
    })
poller.daemon           = True
poller.start()

# Monitor the values dict (updated in another Thread)
while True:
    while values:
        logging.warning( "%16s == %r", *values.popitem() )
    time.sleep( .1 )
, ! dict. . cpppo/server/enip/poll_example *.py , , , , ..

3.9.5, CIP - cpppo.server.enip.get_attribute -. . Cpppo/server/enip/poll_example_many_with_write.py

+6

, , HOST = "192.168.1.100" , 192.168.1. *

0

Source: https://habr.com/ru/post/1598270/


All Articles