From 88b72e3e4657229a3ea60381c1cce28e1bd0c0f0 Mon Sep 17 00:00:00 2001 From: dmroeder Date: Wed, 2 Jun 2021 21:12:33 -0700 Subject: [PATCH] Write arrays when writing lists of tags/values 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] --- pylogix/eip.py | 10 ++++++++-- tox.ini | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pylogix/eip.py b/pylogix/eip.py index de3040a..3ae5805 100644 --- a/pylogix/eip.py +++ b/pylogix/eip.py @@ -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) diff --git a/tox.ini b/tox.ini index db50f1d..2100e93 100644 --- a/tox.ini +++ b/tox.ini @@ -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 =