Skip to content

Commit

Permalink
Write arrays when writing lists of tags/values
Browse files Browse the repository at this point in the history
When writing lists of tags, if an item was attempting to
write a list of values, only the first value would be written.
This is because only the first value was passed to the method
generating the request.  This will pass all of the values, allowing
writing the whole list of values

[Issue #136]
  • Loading branch information
dmroeder committed Jun 3, 2021
1 parent eb5a753 commit 88b72e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions pylogix/eip.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,16 @@ def _multiWrite(self, write_data):
typ = type(wd[1])
value = typ(wd[1])

# ensure that write values are always a list
if isinstance(value, (list, tuple)):
value = value
else:
value = [value]

if BitofWord(tag_name) or data_type == 0xd3:
write_service = self._add_mod_write_service(tag_name, ioi, [value], data_type)
write_service = self._add_mod_write_service(tag_name, ioi, value, data_type)
else:
write_service = self._add_write_service(ioi, [value], data_type)
write_service = self._add_write_service(ioi, value, data_type)

serviceSegments.append(write_service)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py27, py34, py35, py37
envlist = py27, py34, py35, py37, py38

[testenv]
deps =
Expand Down

0 comments on commit 88b72e3

Please sign in to comment.