pjkundert / cpppo

Communications Protocol Python Parser and Originator -- EtherNet/IP CIP
https://hardconsulting.com/products/6-cpppo-enip-api
Other
332 stars 109 forks source link

Cannot use tag names when polling cpppo's server.enip.main server simulation #17

Closed codylandry closed 7 years ago

codylandry commented 8 years ago

I'm evaluating this library for potential commercial use in the future, but am running into some issues. Maybe I'm doing something wrong...

I'm attempting to use the poll.poll example to poll tags from a server simulator I created. The simulator essentially just calls the server.enip.main function with some tags and has two clients (in other threads) that are writing random/function data (sine, cosine, etc.). I want to poll this server using the tag names. I tried both the proxy and proxy_simple classes with no luck. I also tried using different values in the 'params' list:

params = ['random_integer', 'random_boolean']

I get: Unrecognized parameter name: 'random_integer'

params = [('random_integer', 'INT')]

I get: ('random_integer', 'INT') == None I'm also monitoring this data from the web interface and in the terminal and know this value is successfully being written to.

I can use the class/object/attribute address to target this tag as you would using proxy_simple just fine. This makes me think the issue lies with the server. It doesn't seem to lookup the tag correctly.

I'm working on getting a PLC to test against rather than the simulator, but that may be a while. Any help is appreciated!

PS Also, may I make a suggestion for the web api? It would be great to have the json object that gets return be much more fleshed out. At a minimum, the tag values should be in raw form rather than a string. It's painful to parse out the tag values from the huge string, particularly when the tag is an array.

pjkundert commented 8 years ago

Thanks for the efforts you've put in! The API can be a bit hairy; it developed over time, as I discovered more nooks and crannies in EtherNet/IP CIP...

When you use the poll API, if you want to use Tags, make sure you set the 'pass_thru=True' keyword. Otherwise, every parameter processed by the 'parameter_substitution' method is expected to be set up in the parmaters (or self.PARAMETERS) dictionaries. With this set, anything not found will be assumed to be a Tag name, and will be passed thru.

Give that a try, and see if there is anything else.

Also, when you get a None back -- this generally the flag that means that there was an error in reading the target attribute. Unfortunately, you'll need to increase logging to get more details about the failure. If you are using some of the advanced cpppo.server.enip.client APIs that return a large tuple of details about the operation (eg. client.connector.pipeline), then one of the tuple elements will be the CIP status code. However, increasing logging has usually been most useful to me.

Hope that helps!