Comments (15)
'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.
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.
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.
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.
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.
Yes. Thanks. I put exactly this code, but I didn't put comm.Close(). I think that wasn't the problem.
from pylogix.
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.
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.
Great, thanks for the update. You can only communicate with ControlLogix, CompactLogix and Micro8xx, Ethernet I/P only.
from pylogix.
Got it! Will you develop more communication protocols?
from pylogix.
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.
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.
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.
from pylogix.
Yeah thanks. The code works now. Thank you for all!
from pylogix.
Related Issues (20)
- read tag from 80 sets of plc HOT 22
- Double read packets? HOT 6
- cannot import name 'Adapter' from 'pylogix' HOT 23
- Tag Write falsely reports Success HOT 7
- "Forward open failed" when trying to read tags from Berghof PLC HOT 8
- .GetDeviceProperties always returns DeviceType of "None" HOT 5
- Issues connecting to emulate HOT 7
- micro850 connection HOT 5
- Return data gets jumbled up on a multi write when the tags don't exist. HOT 13
- The return value is different when using a multi write compared to a single write for a string. HOT 4
- cannot get a tag list HOT 3
- Is it possible to inhibit a periodic task? HOT 2
- pylogix - returning a tag list as a row of values HOT 7
- PLC REAL values HOT 5
- Pylogix - compare a previously acquired tag list with the current one HOT 5
- Discover does not work while running pylogix in docker HOT 10
- Invalid Continuation Byte HOT 5
- Abnormal code termination. HOT 8
- Do I need to use routing? HOT 20
- PLC connection best practice HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylogix.