-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic CIP Adapter #104
Comments
I think it is a great idea and would love to support that. It would really help for staging systems and simulating messaging between controllers when you don't have enough available physical PLCs since the emulators can't do messaging. But, I'm no where prepared to get started on it. Right now I'm in the middle of a pretty rewrite of a lot of the internals that should make it even easier to use, so all my (little) free time is focused on that. Once I get the next release out maybe I'll try and investigate it. I agree though that it would be a nice feature to have and open up a lot more possibilities. |
Like I said I am willing to help. I think I'm a pretty decent python programmer and do understand the CIP object model from a high level but would need to learn more of the details. Do you see that fitting in the cip_base.py as something like "class CIPAdapter:"? I will fork and start playing with this. Any ideas on how it should fit in would help. |
Umm, I think it would be best as it's own module and I feel it should be something like |
First off, let me know if this is the proper place to discuss details on this. I would understand if the "issues" area on github is only where one would bring up issues. Maybe discussions of details happen some other way, e.g. email, discord, etc. I haven't really worked on any open-source projects. |
I think this is the perfect spot for this type of thing. Discussions are new to me, but they seem like a better solution to just making question/discussion issues. There are specs in the spec folder, the CIP_Vol1/2 and the EIP Data Access Manual (pm020). The CIP specs will be deleted soon though when I merge in develop. I'm not sure of the legality of me having them in the repo and didn't realize they were in there until recently. So I'm removing them to be safe. Those documents are large and take awhile to understand, but they're thorough. I think you have the right idea though. It should listen for a register session command, reply with a session ID. Then certain commands require a connection, so like reading a tag would require that a forward open is done. So it should listen for a forward open request for that session. I'm not sure if it specifies anywhere which services require connections or not, but maybe to get started skip that. The new type system in the decoupling branch will make it a lot simpler to encode response objects, so you may want to work off of that branch for now. Hopefully I'll merge it soon and get a release out. I'm working on fixing the tests and documentation right now, then hopefully it'll be done and released. |
I see some time has passed since the last comment. I also think a driver acting as a generic adapter would be a great feature. It would allow PLC so send data when it's required, rather the polling the PLC looking for change. In some situations would reduce network traffic significantly. Have seen some commercial/industrial (proprietary) products that do this. |
I agree. The use case I imagined was a PLC being able to "push" data to a server that had this adapter listening. For example, a database entry on batch completion for reporting. Like @au-amck said, there would be no traffic unless needed vs. a polling loop to continually check for a "done" tag. The way I was thinking of starting this was to replicate what a PowerFlex drive does when you read a parameter. If this is a flawed approach, let me know. The way I understand it, you need to do the following:
|
So I played around with this a bit. I used a CompactLogix I had laying around and did the cip generic_message example for getting the MAC address. I captured the traffic with Wireshark to review it. Then I made a python socket script and basically replicated what the PLC did. I created a gist on Github for this if you'd like to try it: |
I've only been using Python for a short time and am learning more about it all the time. Thanks to all the work that @ottowayi and the original pycomm team have done to make pycomm3 such an easy library to use. I have tried pycomm and another library with variable results. So far I've had the best experience with pycomm3. I had a similar idea to @ASolchen creating a server to act as a PLC. I started going through the CIP documents quite some time back (before python) and was a little overwhelmed. I'm hoping I can contribute to pycomm3 in some small way, even if it's only testing. I'll definitely take a look at the code you have posted. I understand that the server side that we are talking about here is the opposite side of what pycomm3 is at the moment and while it would use of lot of the structures and classes already defined it's different logic that needs to be tested. The second functionality would be to act as a device in the I/O network. I imagine this is more complicated, even as a Generic Ethernet Device you would have to deal with all the I/O and use input/output words or Datalink style to pass data. I would be focusing on the first function before the second. |
Yeah, what you're describing is the difference between explicit (MSG, pycomm3, etc) and implicit (I/O) messaging. Handling implicit messaging is much more complicated, so if anything I would start with being able to receive explicit messages. I'm currently working on rewrite of a lot of the internals, especially the protocol implementations. I didn't design the current implementation very well, like it really blurs the line between EIP and CIP when they're really separate protocols. Once I have that work done, making a server might be easier. |
I agree that the CIPServer would use explicit messaging. Correct me if I'm wrong, but pycomm3 does not do implicit messages currently, even from the client side. I spoke about this a bit in the discussions area Connected CIP Adapter but from what I saw in captures is that the implicit version establishes a session and then switches to UDP sockets to pass data at an RPI. I would also say that initially the CIPServer would most likely only provide the base for responding to generic messages. When @au-amck says the MSG block of a PLC (or pycomm CIPDriver) "contain the tagname", that is really a Rockwell specific service. The user would need to extend this class to provide advanced services like reading tags by name. (initially, at least) |
I have been making some progress on this. At first I "rigged" a python server to just mimic the data I saw a PLC give. Then broke the response packet apart to see how it's built. Then I started using the data_type encodes, services I guess what I'm asking is do you think that both the Request and Response classes should be able to dynamically "decide", or be told, which side of the connection they are on. Seems like in the end, the |
I have functioning version of the I decided not to touch any of the existing classes. There is still plenty to do. I used the concept that the user would have to build a |
It sounds like you've made some good progress, this would be very useful functionality and I would like to continue with it. I'm not sure if this will be good or bad news, but I'm in the process of refactoring/throwing away the current Edit: I've pushed it to the |
sounds good. I've continued to play with it. I stopped using the |
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.
The text was updated successfully, but these errors were encountered: