Closed Issa-Bqain closed 3 months ago
Hmm, I'm not seeing this.
with pylogix.PLC("192.168.1.10") as comm:
print(pylogix.__version__)
tags = ["BaseDINT", "BaseSTRING"]
ret = comm.Read(tags)
for r in ret:
print(r.Value)
Output:
1.0.2
-776185857
XaoOinvQTSuRFlYTPCqerSCIeNXthMjTyAvxQLBwTpTzwKTuUhopoLIKjDrn
Are you calling get_plc_data
function somewhere? My guess is that you're not.
Hi, Thank you for checking this, I appreciate the help @TheFern2 @dmroeder Fern: I had another print statement on each line of the loop to debug which executed and meant the function did run.
This is rather odd but I believe the issue might actually be a networking problem on my end and nothing to do with pylogix. Apologies.
I was accessing a private network (which the PLC is connected to ) remotely through a firewall when I ran the function get_plc_data
and it seems that this was causing some issues. I hardwired into the network and everything ran as expected.
I am still curious as to what caused this response. I just tried it again now and am not able to reproduce this (it ran as expected).
I will close the issue for now but if I run into this again I will need to dig deeper into the firewall setup as I imagine this is what may have been causing this.
Thank you
Would be much valuable to print(ret)
object since is the Response object, and you should always get it back, it probably would have tell you the exact error, a list of errors is here. If there is a connection issue as you think, then ret.Value
would be None, and it should still print None afaik, that's just the way python works has nothing to do with pylogix.
Did you have a print statement inside the with
? For me still prints None
from pylogix import PLC
from pylogix import __version__
with PLC("192.168.1.10") as comm:
print(__version__)
tags = ["BaseDINT", "BaseSTRING"]
ret = comm.Read(tags)
for r in ret:
print(r.Value)
1.0.2
None
None
# if I print the response object
BaseDINT None Register session failed
BaseSTRING None Register session failed
Would be much valuable to
print(ret)
object since is the Response object, and you should always get it back, it probably would have tell you the exact error, a list of errors is here. If there is a connection issue as you think, thenret.Value
would be None, and it should still print None afaik, that's just the way python works has nothing to do with pylogix.Did you have a print statement inside the
with
? For me still prints Nonefrom pylogix import PLC from pylogix import __version__ with PLC("192.168.1.10") as comm: print(__version__) tags = ["BaseDINT", "BaseSTRING"] ret = comm.Read(tags) for r in ret: print(r.Value)
1.0.2 None None # if I print the response object BaseDINT None Register session failed BaseSTRING None Register session failed
Good note.
I did have multiple print statements to indicate entering the loop but nothing specifically to display ret.Value
or the like, this is useful for future reference. Thank you.
I took the code in the examples and it runs just fine:
Code from example:
Code from example output (works as expected):
Code from example as a function:
Code from example in as a function:
I am wondering if anyone knows why this might be? thanks
Versions: