Closed Destination2Unknown closed 1 year ago
I have a fix for this.
@dmroeder Sweet!
I think this was the issue:
It should be something like:
if not conn[0]:
return [Response(t[0], None, conn[1]) for t in tags]
You mind testing the bugfix/multi-write branch when you get time? It works for me, though things weren't quite failing in the same way for me.
Pretty much sorted, only case where it didn't work was where the tags don't exist and there is no connection to the PLC (i.e. if the IP Address is incorrect):
from pylogix import PLC
with PLC() as comm:
comm.IPAddress = "192.168.133.199"
write_data = [("tag1", 100), ("tag2", 6.45), ("tag3", True)]
# write the values
ret = comm.Write(write_data)
# print the status of the writes
for r in ret:
print(r.TagName, r.Status)
prints:
tag2 Unknown error timed out
6.45 Unknown error timed out
https://github.com/dmroeder/pylogix/issues/224#issuecomment-1540346196
This fairly niche example isn't quite right either...
write_data = [("myDint", 100), ("myString", "Hello"), ("myDint.1", True)]
# write the values
ret = comm.Write(write_data)
# print the status of the writes
for r in ret:
print(r.TagName, r.Value, r.Status)
prints:
myDint 100 Success
myString Hello Success
myDint.1 (2, -1) Success
Yeah, that is weird. The latest should fix it.
Yeah, that is weird. The latest should fix it.
This case is still incorrect:
from pylogix import PLC
with PLC() as comm:
comm.IPAddress = "192.168.133.199" #incorrect IP address
write_data = [("tag1", 100), ("tag2", 6.45), ("tag3", True)]
# write the values
ret = comm.Write(write_data)
# print the status of the writes
for r in ret:
print(r.TagName, r.Status)
prints:
tag2 Unknown error timed out
6.45 Unknown error timed out
I see, somehow, I missed that comment originally
Okay, that one should be fixed on that branch too.
I considered whether to return the value that was written or the None. I went with value intended to write because that is what would be returned on a successful write. Though I could be convinced otherwise.
Okay, that one should be fixed on that branch too.
I considered whether to return the value that was written or the None. I went with value intended to write because that is what would be returned on a successful write. Though I could be convinced otherwise.
I strongly favour returning None because it would make it crystal clear that there was an issue. Otherwise, it could lead to confusion when a write value is returned despite not being sent successfully.
Thank you for your assistance. This library is exceptional, and the support provided is truly outstanding!
Sold! I'll return None. I appreciate your feedback and testing.
Looks good to me, thanks again!
Code
Prints:
Versions