Open KaloyanR opened 4 years ago
There was a related discussion going on in issue #93
ok, thanks maybe broadcast msg is not good idea, but can I ask all devices one by one with a list of my IPs something like for loop to present themselves: IP, Product Name + Product Id + Vendor/Device ID ect.
I recently added GetDeviceProperties() that will get the properties of a device a particular IP address:
from pylogix import PLC
with PLC('192.168.1.10') as comm:
ret = comm.GetDeviceProperties().Value
print(ret.ProductName)
It differs from GetModuleProperties() in that requesting module properties requires a slot (for getting properties of I/O modules in a chassis) and device properties will allow you to target things like PowerFlex drives or servo drives.
Or for a list of addresses, you might have to do something like this:
from pylogix import PLC
addresses = ['192.168.1.10',
'192.168.1.11']
for address in addresses:
with PLC(address) as comm:
ret = comm.GetDeviceProperties().Value
print(ret.ProductName)
OK, Thanks I will try it.
Traceback (most recent call last):
File "C:\MotorService\testpylogix.py", line 14, in
I'm guessing address in your code is a list. If you want help with your code, post it.
OK It works. My fault in installation and venv settings.
================== RESTART: C:\MotorService\testpylogix.py ================== PowerFlex 525 3P 600V 1.0HP PowerFlex 525 3P 600V 1.0HP
Okay, cool. Out of curiosity, what version of python and pylogix are you using?
import pylogix
pylogix.__version__
Pytnon 3.7 pylogix 0.6.2 Now the code works. But there is new problem, in given IP with no device ... error timeout and that stop code execution! How I can pass and continue to next IP, cause i need kind of network inventory/discovery. The idea is to make WinService code (auto execution) with for loop for All Vlans (subnets) one time per week and put all valid data to SQL.. Product code, Name, IPs ect. After that in SCADA I can periodicaly check Drives (select all PoweFlex 525 for example) saved in my SQL table for state, display and archive the faults. For communication with simple CIP device I use cpppo lib. //check all parameters directly from drive PF525. Is the pylogix can do that? Get Attribute Single/All - class/instance/attribute.
@KaloyanR In regards to the timeout use a try catch.
yes, 'except: pass' works, thanks.
@KaloyanR np. Normally you'd want to handle the exception. Print to the console or log, or something else. I guess if the IP doesn't exist, there's nothing to do hence why pass might be acceptable in your case.
Is there a way to discover devices in differents subnets? or with a list of addresses not broadcaast msg?