Git Product home page Git Product logo

pycomm3's People

Contributors

acedrew avatar augustooazi avatar bpaterni avatar bshep00 avatar colt-h avatar ddeckercpf avatar dependabot[bot] avatar eduardohi avatar gamegrime avatar githubdragonfly avatar jamesbraza avatar kgustine avatar mbuesch avatar nos86 avatar ottowayi avatar patrickjmcd avatar philipphaefele avatar rahul14189 avatar ruscito avatar shadetree01010100 avatar tlf30 avatar zenware avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycomm3's Issues

I think this project should have Contribution Guidelines

This basically amounts to a contributing.md file in the root of the project which explains the expectations of contributors to the project. Typically it will include things like "what are the expectations of an Issue, a PR.. what code/comment styleguide is meant to be followed. And any expectations on the git workflow itself, i.e. is work done in feature branches, is work done on a development branch, etc. It may also include a code of conduct and any other information deemed useful. It could also bs very simple and brief, even to the point where all of it fits inside the main readme file, as some projects do.

I bring this up because in my late night contribution I didn't notice there was a 'develop' branch, which is as of this writing 1 commit ahead, 2 commits behind master. I now sort of expect that I should've requested my PR be merged into develop rather than master.

Here's an example of my favorite short and sweet contributing file https://github.com/shazow/ssh-chat/blob/master/CONTRIBUTING.md

Github has a document with a guide for this that provides links to several examples near the bottom.

https://docs.github.com/en/github/building-a-strong-community/setting-guidelines-for-repository-contributors

Missing IO Tags

Hello. I'm using the following code to read the tag structure of a PLC:

with LogixDriver(ipPlusSlot, large_packets=False, init_program_tags=True) as plc:
   result["tagStructure"] = plc.tags

plc.tags is returning 49 tag values. However, when I use PyLogix's GetTagList() on the same PLC, I get 87 values back. I believe the extra PyLogix tags are IO tags, such as "VFD_CV_313:I" and "IV:I". Does PyComm have the ability to retrieve these types of tags?

Thanks

[FEATURE] - type hints or library stubs for library users

First of all thanks for this useful library !
Now, I noticed that pycomm3 uses typing hints and typechecking internally, But when using mypy I get the error:
Skipping analyzing 'pycomm3': found module but no type hints or library stubs (I might be doing something wrong with my setup so I apologize if that's the case and would appreciate guidance on how to set that up properly).

Here's more information about it
from the users perspective: https://mypy.readthedocs.io/en/stable/running_mypy.html?#missing-type-hints-for-third-party-library
and from the maintainers perspective: https://www.python.org/dev/peps/pep-0561/

Type of Feature Request

  • missing feature
    • feature available in another library: please specify
  • change to API
  • enhancing a current feature
  • removal of a broken/unsupported/etc feature
  • other: please specify

Feature Description
A way to have library users typecheck their usage of pycomm3.

Possible Solution
From what I understand there are 3 different approach that might apply here:

  1. Add py.typed marker file to signal mypy that type information is inlined.
  2. Add *.pyi stubs files
  3. create a separate pycomm3-stubs package and let users optionally dowload that

With some guidance I am willing to do the work and send PR, let me know what you think !

Support for ESP32

Hello
How can I use this library with an ESP32, what changes should I make to be able to use it in a microcontroller? is it possible to use it with micropython?

Program Tags using init_program_tags

Hello

I'm trying to scan program tags from a plc, but this code isn't returning them. I'm probably doing something dumb, but just wondering if you see an issue. Thanks!

from pycomm3 import LogixDriver

ipAndSlot = '10.11.12.218/0'
plc = LogixDriver(ipAndSlot, init_program_tags=True)
print(plc.get_tag_list())

V1.0.0 Release Tests

This issue will be used to track the testing against various devices. For each device tested against, please leave a comment with the device model and firmware version, the tests performed (i.e.: the built-in ones, user custom scripts/apps, etc), and whether or not they were successful. Once I feel like the beta releases have been adequately tested and no major issues are found a new stable release will be created.

Reconnect to PLC after broken interrupted

Hi,

I need to read some PLC tags periodically, for example, inside a while loop, like the example below:

from pycomm3 import LogixDriver
import time

plc = LogixDriver('192.168.1.210/2')

while(True):
    tag_read = plc.read('DateTime[5]')
    print(time.ctime(), tag_read)
    time.sleep(1.0)

If the connection is interrupted, for example, by a problem on the network, the tag value returns as None, as expected
But when the PLC is again available, the following error messages are reported:

Wed Jul 29 20:48:09 2020 DateTime[5], 6, DINT, None
Wed Jul 29 20:48:10 2020 DateTime[5], 7, DINT, None
Wed Jul 29 20:48:16 2020 DateTime[5], None, None, timed out
Wed Jul 29 20:48:22 2020 DateTime[5], None, None, timed out
Wed Jul 29 20:48:28 2020 DateTime[5], None, None, timed out
Wed Jul 29 20:48:30 2020 DateTime[5], None, None, [WinError 10054] An existing connection was forcibly closed by the remote host
Wed Jul 29 20:48:31 2020 DateTime[5], None, None, socket connection broken.
Wed Jul 29 20:48:32 2020 DateTime[5], None, None, socket connection broken.
Wed Jul 29 20:48:33 2020 DateTime[5], None, None, socket connection broken.

Is there any configuration so that the socket connection is not closed, or that a new one is created?

Thanks

Tag List Error

Hey man

I had a script that was successfully reading a PLC's tag list. I believe someone at my work added addition tags/logic to that PLC's program. Now I get the following error:

Traceback (most recent call last):
File "getTagListAB.py", line 6, in
with LogixDriver(ipPlusSlot, large_packets=False, init_program_tags=True) as plc:
File "C:\Users\Engineer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pycomm3\clx.py", line 180, in init
self.get_tag_list(program='*' if init_program_tags else None)
File "C:\Users\Engineer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pycomm3\clx.py", line 77, in wrapped
return func(self, *args, **kwargs)
File "C:\Users\Engineer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pycomm3\clx.py", line 603, in get_tag_list
tags = self._get_tag_list()
File "C:\Users\Engineer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pycomm3\clx.py", line 621, in _get_tag_list
tag['data_type'] = self._get_data_type(tag['template_instance_id'])
File "C:\Users\Engineer\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pycomm3\clx.py", line 956, in _get_data_type
return self._cache['id:udt'][instance_id]
KeyError: 2610

Here's the python code:

from pycomm3 import LogixDriver

ip = '192.168.50.48'
slot = '0'
ipPlusSlot = ip + '/' + slot
with LogixDriver(ipPlusSlot, large_packets=False, init_program_tags=True) as plc:
print(plc.tags)

The PLC is a ControlLogix 1756. Any ideas?

forward_open failed - Service not supported [Micro800 Support]

The functionality you have here looks really cool and I'd love to try it out on our next project, but I'm having some forward_open issues on both PLCs that I have tried with.

I am using a 1756-L72 in slot zero with a 1756-ENBT ethernet/IP card in slot 1 using the newly added CIP routing from 2020/03/10 as '10.101.123.4/backplane/0' but get back:

(venv) PS C:\Python\PyCommApp> & c:/Python/PyCommApp/venv/Scripts/python.exe c:/Python/PyCommApp/LogixApp.py
forward_open failed - Service not supported - Extended status info not present
Traceback (most recent call last):
File "c:/Python/PyCommApp/LogixApp.py", line 3, in
with LogixDriver('10.101.123.4/backplane/0') as plc:
File "C:\Python\PyCommApp\venv\lib\site-packages\pycomm3\clx.py", line 100, in init
self.get_plc_info()
File "C:\Python\PyCommApp\venv\lib\site-packages\pycomm3\clx.py", line 55, in wrapped
raise DataError(msg)
pycomm3.DataError: Target did not connected. get_plc_info will not be executed.

I have python 3.8.2, using VSCode as the IDE with a virtual env. I also tried it IDLE IDE and without a venv, but keep getting the same error. Am I doing something wrong?

I was also trying it with a Micro820 with '10.101.123.x' getting a similar error, but assumed it may not be supported yet.

CIP Generic Message - Accept either bytes or ints for service, class, instance, and attribute args

Pre-checks

  • running latest version (pip show pycomm3)
  • enabled logging
  • consulted the docs

Description
I'm going to report this as a bug, although I'm not sure if it's necessarily a bug with the module or the way CIP Generic Messaging works. I'm building an app to get parameters from a PF525. If I try to get an instance greater than 255 (hex: FF), I get a "Object does not exist" error back. I'm almost positive it is because once you're above 255 in hexadecimal, it's 3 characters.

example:

    service=CommonService.get_attribute_single,
    class_code=b'\x93'
    instance=b'\x1F'
    ...

will return Motor NP Volts no problem. However,

    service=CommonService.get_attribute_single,
    class_code=b'\x93'
    instance=b'\x216'
    ...

Returns the "Object Does Not Exist" error. Note that this does work when setting up a MSG instruction in ladder, which is why I decided to report it as a bug.

Target Devices
Model: 1756-L71, 25B-D2P3N104
Firmware Revision: 24.11, 6.001

Instance Addressing

When pycomm3 reads a tag, such as:

plc.read('DINT1')

does it send the tag name 'DINT1' to the PLC, or does it send 'DINT1's instance ID?

I'm curious because recently I learned that Kepware can send the tag address instead of the tag name during read requests. This increases the amount of data that can fit in a packet and vastly speed up reads.

Thanks!

Accessing String and Ascii files on Micrologix1400

Great work here but I'm unclear on the correct syntax pycomm3 expects for accessing ST and A files. I am trying to make a simple reference to ST52:0 as show here.
Capture
I'm cool stringing together bits from the A53 file as well.
image

Can't find array variables on Micro850

hi,

We're using a Micro850 PLC and when printing the tags, we notice that user defined array variables are not listed.
They can also not be found when trying to read.

Simple user defined type variables like INT can be found.

See picture attached. Are we missing something in the code / settings?
Our goal is to use pycomm3 to read/write arrays and structured variables.

Note: in the picture attached we're trying to read but as mentioned, using print(plc.tags) doesn't show the array variables either.

Thanks in advance,
Christophe

Missing Array Variables

Can't read some structures - "Permission denied - No Extended Status"

Hi,

I've been using this library for a bit and it has been amazing upgrade to the other ones I've used in the past. I am enjoying the structure reading but I have noticed that on some structures it fails with an permission denied - no extended status while on others (eg, TIMER) it reads all the attributes just fine.

I can get around this by using the datatypes collected by pycomm3 and manually explode the tag into its attributes and reading that way but I was curious as to what causes the "permission denied - no extended status".

>>> plc.read("M_1001.FTS")
Tag(tag='M_1001.FTS', value=None, type=None, error='Permission denied - No Extended Status')
>>> plc.read("M_1001.HMI_START") 
Tag(tag='M_1001.HMI_START', value={'Control': 0, 'PRE': 2000, 'ACC': 0, 'EN': False, 'TT': False, 'DN': False}, type='TIMER', error=None)

HMI_START is a TIMER whilst FTS is an ALM_DIG (which is an add-on instruction). Like I said I can get around it by manually reading each individual attribute but I was curious if there is something misconfigured or something to look for as to why it fails on some structures but not others.

Thank you!

Proper way to handle reconnects?

This is more so an extension off of #60...

Occasionally, a connection to a PLC will get interrupted due to some network issue and the following error is reported back when trying to perform a read failed to receive reply.

When the PLC becomes available, the error switches to failed to send message.

Handling this error and then performing a close() followed by an open() does not get communication back up and running.

Is there a better way of handling this situation?

Micrologix Status

Hello

I asked this on issue #15, but thought I'd ask in it's own issue:

What's the status of MicroLogix support? If it's being developed, do you have any thoughts on when it will be ready?

Thanks!

Cant read string using generic_message

Hey,

I have been working on a project lately using generic CIP messaging to a Lexium mdrive stepper motor. I have found an issue and am not sure where the problem is. I have the following code.

def get_setup_function(path): with CIPDriver(path) as driver: param = drive.generic_message( service=CommonService.get_attribute_single, class_code=b'\x67', instance=1, attribute=b'\x0F, connected=True, unconnected_send=False, route_path=False, data_format=[('IS','string')], name='data' ) return param[1]

I dont get any errors just a return of None. I have tried to set the data_format to None and I get a bytestring but the data isnt complete. Any help would be great

Thanks

Client/Scanner Application

Hi,

I need to write an application (client/scanner) that establish a communication with an ETHERNET/IP adapter/server using both explicit and implicit(I/O) messaging.
The adapter will be coded in C/C++ using EIPStackGroup/OpENer library.

So, my questions are:
Is This library meant for that ?
Which is the max polling rate ?

I Thank in advance for the answers.

Sérgio

disable debug logging

i want to disable debug level logging, but keep errors. i tried:

logging.getLogger("pycomm3").setLevel(logging.ERROR)

but it doesn't do anything. i use same line to disable requests lib logging and it works fine

pycomm3 vs pycomm

Hi

I see on the main page that pycomm3 is a fork of pycomm. Did you add a bunch of features that aren't in pycomm? I'm trying to use pycomm to read micrologix tags, and it seems like all it does is read and write, there's no tag discovery.

Thanks!

forward_open failed, UDT names without values, and multi-reading

Sweet library!

I have 3 questions:

1.) Do you know why this message is being generated - "forward_open failed - Service not supported - Extended status info not present". The code is working despite this message. Here is the script and output:

`
from pycomm3 import LogixDriver

ip = '192.168.50.29'
tagName = 'DAQ_Batch_Number'
udt = 'DAQ_UDT'

with LogixDriver(ip) as plc:
print(plc.read(tagName))
print(plc.read(udt))

`

pycommOutput

2.) Is it possible to only read the names/type of UDT children, but not their values? This may seem odd, but I'm just concerned about performance. If a UDT is huge, that could be a lot of data coming back if we just need children names. Any thoughts?

3.) Is there a limit to how many tags can be read when calling plc.read(*tags)? I believe PyLogix does have a limit for multi-reads.

I'm really excited about this library! I didn't know it existed until your recent post.

Thanks

Writing a structure

I have some user defined types I need to write to.

The UDT is structured as follows:

UDT Name: PR_Real

  • Description - STRING
  • Min - REAL
  • Max - REAL
  • Units - STRING
  • AccessLevel - DINT

TA_0EB01 is of type PR_Real
Doing a test, this works:

from pycomm3 import LogixDriver
PRB05_PLC = LogixDriver('10.9.1.187')

PRB05_PLC.write(('TA_0EB01.Description', 'BDC Cam'))
PRB05_PLC.write(('TA_0EB01.Min', 10.0))
PRB05_PLC.write(('TA_0EB01.Max', 80.0))
PRB05_PLC.write(('TA_0EB01.Value', 5.6))
PRB05_PLC.write(('TA_0EB01.AccessLevel', 9999))

Is there a way to use a dictionary or list like this without writing a loop?

PRB05_PLC = LogixDriver('10.9.1.187')
tagvalues = {'Description': 'BDC Cam', 'Min': 10.0, 'Max': 80.0, 'Value': 5.6, 'AccessLevel': 9999}
PRB05_PLC.write(('TA_0EB01', tagvalues))

The example writes for UDT shows using several lists, but it was unclear how the recipe example was structured in the PLC?

Does pycomm automatically close the connection?

In issue #32 , you mentioned calling plc.close() for a long lasting driver. I haven't seen plc.close() in any example code. Does pycomm3 automatically call plc.close under normal conditions, and under what circumstance should I manually call plc.close?

Thanks!

Generic CIP Adapter

Forgive me if this was proposed already.

Has any thought been given to making a adapter-side version of the CIPDriver? Not only would it be great for a testing, but I could envision someone using a MSG command from a PLC to connect to a PC or Raspberry Pi as an IO adapter. Another use may be the ability for a PLC to conditionally "Push" info to a server and not required the server to continually poll for info.

Are there any large technical challenges to this or would this seem useful? I would be willing to help but am not sure where to start. I do have access to many PLCs, drives, AB programming software, etc.

Reading a Field Inside a UDT

I'm able to read contents inside a UDT:

ip = '192.168.50.29'
tagName = 'INT_Equip0_Step1_TMR'
with LogixDriver(ip, large_packets=False) as plc:
print(plc.read(tagName))

pyCommUdt

The response shows that the timer has a CTL field. However, when I use tagName = 'INT_Equip0_Step1_TMR.CTL ', I get the following error:

pyCommUdt2

I'm guessing this is a boneheaded move on my part, haha, but any ideas what's wrong?

Asyncronous Reads & Connection Timeout

  1. Is there a way to read from multiple PLCs asynchronously? For example, if I'm reading from 3 PLCs, can I send 3 read requests in quick succession and wait for them all to return, as opposed to reading each PLC individually and waiting for its response before reading the next PLC?

  2. Do you have an suggestions for decreasing the connection timeout? For example, only waiting 0.5 seconds before deeming the PLC inaccessible? Also, related to question 1, if there is a way to asynchronously read, is there a way to set the timeout for all responses?

Trying to write to an element in a Data File

Hello. I would simply like to write a 1 into Data File N11:1. Am I missing something in my code?

    with LogixDriver(plc_ip_address) as plc:
        plc.write(("N11[1]", 1))

Log output:

2021-01-26 08:38:54,847 [DEBUG]: porter_rest.py(GET:74) >> plc_ip_address = 10.0.0.5
2021-01-26 08:38:54,862 [DEBUG]: requests.py(send:133) >> Sent: RegisterSessionRequestPacket(message=[b'\x01\x00', b'\x00\x00'])
2021-01-26 08:38:54,871 [DEBUG]: requests.py(send:139) >> Received: RegisterSessionResponsePacket(session=930230157, error=None)
2021-01-26 08:38:54,871 [INFO]: cip_base.py(_register_session:252) >> Session = 930230157 has been registered.
2021-01-26 08:38:54,872 [DEBUG]: requests.py(send:133) >> Sent: ListIdentityRequestPacket(message=[])
2021-01-26 08:38:54,881 [DEBUG]: requests.py(send:139) >> Received: ListIdentityResponsePacket(identity={'item_type_code': 53, 'item_length': 1, 'encap_protocol_version': 512, '_socket_address_struct': b'\xaf\x12\n\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00', 'vendor_id': 14, 'product_code': 90, 'revision_major': 2, 'revision_minor': 11, 'status': 4, 'serial_number': 1080144404, 'product_name': '1766-L32BWA B/11.00', 'state': 0}, error=None)
2021-01-26 08:38:54,881 [DEBUG]: requests.py(send:133) >> Sent: GenericUnconnectedRequestPacket(message=[b'R\x02 \x06$...1\x00\x01\x00'])
2021-01-26 08:38:54,891 [DEBUG]: requests.py(send:139) >> Received: GenericUnconnectedResponsePacket(service=b'R', command=b'o\x00', error='Service not supported - No Extended Status')
2021-01-26 08:38:54,891 [ERROR]: porter_rest.py(GET:85) >> Failed to get PLC info

My PLC setup:

Screenshot

I have tried N11:1 and that does not work either. I do not see any similar examples for this basic operation on your website.

  • PLC: MicroLogix 1400
  • OS: Windows 10

Question about Array Structure in plc.tags

When should I look at 'dim' & 'dimensions' to determine if a tag is an array, and when should I look at 'array' to determine if a tag is an array?

Here's a picture of a particular tag in plc.tag. It has 'dim' & 'dimensions' attributes, but not 'array'. It's child 'RecStage' has the 'array' attribute, but not 'dim' nor 'dimensions'.

pycomm3TagStructure

[BUG] - Reading Complex UDTs returns incorrect data

Pre-checks

  • [ x] running latest version
  • enabled logging
  • [x ] consulted the docs

Description
Reading a complex tag returns wrong values when nested structures are too deep

Target PLC
Model: [e.g. 1756-L82ES]
Firmware Revision: [e.g. 31]
Other Devices in CIP Path: [e.g. 1756-EN2T v11.002]

Code Sample
Minimal reproduceable code sample

from  pycomm3 import LogixDriver as ld
from pprint import pprint

if __name__ == "__main__":
    with ld('192.168.0.41') as plc:
        #pprint(plc)
        #pprint(plc.info)


        result = plc.read('gstRecipeDownloaded')
        
        for t in result:
            pprint(t)

Additional context
The UDT I'm reading is complex in that it has several other UDTs and Array nested, so this may simply be outside of the scope of the library.

This is a sample of what I get:

 'stCamDataX': [{'arrstMotionData': [{'rEndAngle': 36.0,
                                      'rPosition': 1400.0,
                                      'rStartAngle': 324.0},
                                     {'rEndAngle': 216.0,
                                      'rPosition': 1908.0,
                                      'rStartAngle': 144.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0}],
                 'intNumberOfMoves': 2},
 'stCamDataY': [{'arrstMotionData': [{'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 2.444985560553941e-41,
                                      'rPosition': 0.0,
                                      'rStartAngle': -2.0},
                                     {'rEndAngle': 2.436577769767992e-41,
                                      'rPosition': -2.4221443955854463e-41,
                                      'rStartAngle': 2.4253673820533934e-41},
                                     {'rEndAngle': 2.459839324275784e-41,
                                      'rPosition': 2.37548115672343e-41,
                                      'rStartAngle': -2.3939782964525175e-41},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0},
                                     {'rEndAngle': 0.0,
                                      'rPosition': 0.0,
                                      'rStartAngle': 0.0}],
                 'intNumberOfMoves': 0},

When I take a read by tunneling a little deeper I get what i expect. The first is stCamDataX the second is stCamDataY. The first one seems to read ok the stCamDataY is not.

{'arrstMotionData': [{'rEndAngle': 36.0,
                      'rPosition': 1400.0,
                      'rStartAngle': 324.0},
                     {'rEndAngle': 216.0,
                      'rPosition': 1908.0,
                      'rStartAngle': 144.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0}],
 'intNumberOfMoves': 2}


{'arrstMotionData': [{'rEndAngle': 313.0,
                      'rPosition': 675.0,
                      'rStartAngle': 266.0},
                     {'rEndAngle': 94.0,
                      'rPosition': 472.0,
                      'rStartAngle': 46.0},
                     {'rEndAngle': 0.0,
                      'rPosition': 1172.0,
                      'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0},
                     {'rEndAngle': 0.0, 'rPosition': 0.0, 'rStartAngle': 0.0}],
 'intNumberOfMoves': 2}

As you can see it seems to read the first instance of the structure but seems to fall apart afterwards.
I've attached a screen shot of part of the structure.

image

Find datatype of tag within tag list

Is there an easy way of finding out the datatype of a known tag using the tag list? For example, can I give the system a tag "Tag1[40].Temp.Scl" and have it spit back "Float"? Or even the tag in the list? I am not opposed to converting it to a "path" either like "Tag1\40\Temp\Scl"...

Is there anything like that I can use?

CJ

List(s) of tags

I need to give the read function a list of tags or convert that to something the read function can understand - I tried a tuple but that didn't work.
I need to give the write function a list of tags and values or convert that to something the convert that to something it would understand.
For example:

tags = ['tag1', 'tag2', 'tag3']
results = plc.read(tags)

or something like.....
tag_q = CType(something, tags)
results = plc.read(tag_q)

Any information you can provide to help me would be greatly appreciated. I thought before I go forking the code and overriding these methods I would ask you.

CJ

Writing STRING array fails above 4000 bytes

Only 45 strings can be in a write before the exception.
"pycomm3.RequestError: Fragmented write of structures is not supported"
This falls in the "struct" tag_type and "Write_tag_fragmented"
It would be great to have this fixed. Thank you.

[BUG] - get_module_info attempts to concatenate 'int' and 'bytes'.

Pre-checks

  • running latest version (pip show pycomm3)
    Name: pycomm3
    Version: 0.10.1.post0
    Summary: A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
    Home-page: https://github.com/ottowayi/pycomm3
    Author: Ian Ottoway
    Author-email: [email protected]
    License: MIT
    Location: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
    Requires:
    Required-by:
    Note: you may need to restart the kernel to use updated packages.
  • enabled logging
  • consulted the docs

Description
A clear and concise description of what the bug is.

The function get_module_info attempts to concatenate 'int' and 'bytes'. It's not clear what the format for 'slot' should be. It would be helpful to have function help included in the code so that help(pycomm3.clx.LogixDriver.get_module_info) displays more useful information.

I've tried tracing this down, but I'm unclear what is being attempted / the purpose of this line in the function. Pack.sint(slot) with sint = lambda n: pack('b', n) appears to require an integer.

Target PLC
Model: 1756-L73S/B LOGIX5573SAFETY
Firmware Revision: 28.12
Other Devices in CIP Path: 1756-EN2T

Code Sample
Minimal reproduceable code sample

 plc.get_module_info(1)

Additional context

  • if reading/writing a tag, describe it's type/structure/etc
  • attach any relevant L5X or data files
  • paste/attach logging output
plc.get_module_info(0)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pycomm3/cip_base.py", line 224, in get_module_info
    route_path=PATH_SEGMENTS['bp'] + Pack.sint(slot)
TypeError: unsupported operand type(s) for +: 'int' and 'bytes'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-31842fcba601>", line 1, in <module>
    plc.get_module_info(0)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pycomm3/cip_base.py", line 233, in get_module_info
    raise DataError('error sending request') from err
pycomm3.exceptions.DataError: error sending request

Any update about slc.py

Hey ottowayi and all other contributors, first of all, I appreciate all of your work here. I am currently working on a project with Rockwell Micrologix 1400 plc with python 3 environment. And I needed slc.py to work with this project, so I am asking you all that is there any plan to update that, its very urgent and important for me. As I'm not that great at python else I would have done that myself and contributed to your work. 
Thanks in advance !

Read tags using their aliases

Hi,

I could not find it in the docs or the examples but is is possible to read/write tags based on the tags Alias?
The alias is not part of the Tag class I see...

Update README

  • examples for read method
  • examples for write method
  • explain differences between new and old methods
  • #examples for tag list

Add more tests

create more tests to cover all use cases. For both successful and failed operations. Include methods other than read/write.

[BUG] - improper unpacking of session id leads to crashes

Pre-checks

  • [x ] running latest version (pip show pycomm3)
    Name: pycomm3
    Version: 0.8.1
    Summary: A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
    Home-page: https://github.com/ottowayi/pycomm3
    Author: Ian Ottoway
    Author-email: [email protected]
    License: MIT
    Location: /home/vagrant/.local/lib/python3.6/site-packages
    Requires: autologging
  • [?] enabled logging
  • consulted the docs

Description
A clear and concise description of what the bug is.

Target PLC
Model: [Micro820]
Firmware Revision: [11]
Other Devices in CIP Path: []

Code Sample
Minimal reproduceable code sample

with LogixDriver("192.169.10.7") as plc:
     print(plc.read("Data_out_control"))

Additional context

  • Reading a tag that is Boolean type

Looking for virtual PLC

First, great work by the pycomm developers!
Can someone point me to a virtual PLC that I can simulate/send commands with pycomm3 ?
TNX

Tag Listing

This started as a question about simplifying the code for the tag listing within listbox of the tkinter GUI but ended up in submitting a PR.

The output of the code looks like in the attached picture.

Tags - List Box

The full GUI looks like the following attached picture, which was initially created for pylogix.
The driver selection, LogixDriver or SLCDriver, combobox was also added as well as the label showing pycomm3 version.

Pycomm3 GUI

Queston: Program Scoped Tags

Is there a way to handle program-scoped tags? I've tried adding "Program:{myprogram}.{tagtoread}" but I only get an invalid tag request from it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.