The return value is different when using a multi write compared to a single write for a string.
Destination2Unknown opened this issue · 4 comments
Destination2Unknown commented
Description of issue
When writing to a string using a Multi Write, the return value is in raw byte format.
Whereas with a single Write, the return value is a string.
Code
from pylogix import PLC
with PLC() as comm:
comm.IPAddress = "192.168.1.9"
write_data = [("myDint", 100), ("myString", "Hello")]
# write the values
ret = comm.Write(write_data)
# print the status of the writes
for r in ret:
print(r.TagName, r.Value)
Prints:
myDint [100]
myString [[5, 0, 0, 0, 72, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
Whereas if I just do a single write:
ret = comm.Write("myString", "Hello")
print(ret.TagName, ret.Value)
Prints:
myString Hello
Versions
- pylogix: 0.8.11
- python: 3.11
- OS: Windows
Destination2Unknown commented
For this, could you just include the original data when calling _parse_multi_write
as well as the data in byte format?
And then parse accordingly.
dmroeder commented
Yeah, something along those lines. Hopefully I'll have a fix for that one today, then I'll push an update.
Destination2Unknown commented
Destination2Unknown commented
Amalgamated into #224