Code Monkey home page Code Monkey logo

Comments (15)

dmroeder avatar dmroeder commented on July 18, 2024

'pack' is part of the struct module. It's most likely with how struct is being imported. You may need to provide a little more of the error in order to figure out what file is throwing the error but make sure that eip.py imports struct like this:

from struct import *

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

I just put all of your .py files in a folder. In this same folder I put my .py file. I also create a init.py in the folder. I have to modify any file? Or I just have to put all together and run?

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

You don't have to modify any of my files to use them. You just have to create an instance of PLC() properly, set the IP address (and processor slot if other than 0), then call Read or Write. So I'd be interested in what is in your init.py (assuming that is where you are you are creating an instance of PLC).

Also, you should be using python 2.7.x, not python 3. If you would like, I can take a look at how you are using it. You can email it directly to me if you prefer.

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

Undestand. I'm using python 2.7.x. My init.py is an empty file, I created this file because I read in a lot of websites that python needs an init.py to run. I don't know why, I just put it in my folder.

Thank you for the answer, I'm going to test one more time tomorrow and then I reply this issue!

Have a good night!

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

I see.

If you check out the readme, it has a simple example. Create a new python file, you can call it read.py. In it you would put something like this:

from eip import PLC
comm = PLC()
comm.IPAddress = '192.168.1.10' # replace with the IP address of your PLC
print comm.Read('TagName')
print comm.Read('TagName2')
comm.Close()

(You should only call .Close() when you are done reading/writing. It doesn't need to be called after each read/write).

Let me know ether way how it goes.

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

Yes. Thanks. I put exactly this code, but I didn't put comm.Close(). I think that wasn't the problem.

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

Hmm, calling .Close() won't cause a problem. It just closes the connection with the PLC. If you don't call it, the connection would be dropped by the PLC eventually anyway.

The only way I've really been able to re-create the same error is by modifying the import of struct in eip.py, which you shouldn't be doing.

If you want, zip up what you have and email it to me when you get a chance. Also, mention your operating system and the PLC you are connecting to.

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

The code works now. I just remove old .py files and I downloaded new ones. Thank you for support. I have one last question: Your code uses only the network connection to read or write data in a PLC or it uses the OPC server connection? Can I communicate with an PLC using Profinet, Modbus and etc?

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

Great, thanks for the update. You can only communicate with ControlLogix, CompactLogix and Micro8xx, Ethernet I/P only.

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

Got it! Will you develop more communication protocols?

from pylogix.

Piepiopi avatar Piepiopi commented on July 18, 2024

AB will only communicate over EtherNet I/P on those products. If you are coming from a different protocol, you will need a bridge/server to allow translation between the two protocols. Those PLCs are not going to respond to Profinet or ModBus TCP requests.

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

I hadn't really planned on it Leobraic. There are other libraries out there. In fact, there are other Ethernet I/P libraries as well. This has been a learning project for me. I almost exclusively work with AB products so it wouldn't be very easy for me to work with other protocols.

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

The question was because I'm new on PLC world. My first contact with PLC was in an AB PLC. Now I'm run to learn more and more information about PLCs but I'm having some difficulties.

from pylogix.

dmroeder avatar dmroeder commented on July 18, 2024

from pylogix.

leopoliveira avatar leopoliveira commented on July 18, 2024

Yeah thanks. The code works now. Thank you for all!

from pylogix.

Related Issues (20)

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.