Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency pymodbus to >=3.0.2,<3.6.0 #78

Merged
merged 4 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
pymodbus-version: ["2.5.3", "3.0.2", "3.1.3", "3.2.2", "3.3.1", "3.4.1"]
pymodbus-version: ["2.5.3", "3.0.2", "3.1.3", "3.2.2", "3.3.1", "3.4.1", "3.5.0"]
exclude:
- python-version: "3.10"
pymodbus-version: "2.5.3"
Expand Down
12 changes: 8 additions & 4 deletions productivity/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ async def _write_register_value(self, key: str,

"""
start_address = self.tags[key]['address']['start'] - 400001
builder = BinaryPayloadBuilder(byteorder=Endian.Big,
wordorder=Endian.Little)
bigendian = Endian.BIG if self.pymodbus35plus else Endian.Big # type:ignore[attr-defined]
lilendian = Endian.LITTLE if self.pymodbus35plus else Endian.Little # type:ignore
builder = BinaryPayloadBuilder(byteorder=bigendian,
wordorder=lilendian)
data_type = self.tags[key]['type']
if data_type == 'float':
builder.add_32bit_float(float(value))
Expand Down Expand Up @@ -222,9 +224,11 @@ async def _read_discrete(self, addresses: dict, output=True) -> dict:
async def _read_registers(self, a_type: str) -> dict:
"""Handle reading input or holding registers from the PLC."""
r = await self.read_registers(**self.addresses[a_type], type=a_type)
bigendian = Endian.BIG if self.pymodbus35plus else Endian.Big # type:ignore[attr-defined]
lilendian = Endian.LITTLE if self.pymodbus35plus else Endian.Little # type:ignore
decoder = BinaryPayloadDecoder.fromRegisters(r,
byteorder=Endian.Big,
wordorder=Endian.Little)
byteorder=bigendian,
wordorder=lilendian)
current = self.addresses[a_type]['address'] + TYPE_START[a_type] + 1
end = current + self.addresses[a_type]['count']
result = {}
Expand Down
1 change: 1 addition & 0 deletions productivity/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _detect_pymodbus_version(self) -> None:
self.pymodbus30plus = int(pymodbus.__version__[0]) == 3
self.pymodbus32plus = self.pymodbus30plus and int(pymodbus.__version__[2]) >= 2
self.pymodbus33plus = self.pymodbus30plus and int(pymodbus.__version__[2]) >= 3
self.pymodbus35plus = self.pymodbus30plus and int(pymodbus.__version__[2]) >= 5

async def _connect(self):
"""Start asynchronous reconnect loop."""
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='productivity',
version='0.10.0',
version='0.10.1',
description="Python driver for AutomationDirect Productivity Series PLCs.",
long_description=long_description,
long_description_content_type='text/markdown',
Expand All @@ -22,7 +22,7 @@
install_requires=[
'pymodbus>=2.4.0; python_version == "3.8"',
'pymodbus>=2.4.0; python_version == "3.9"',
'pymodbus>=3.0.2,<3.5.0; python_version >= "3.10"',
'pymodbus>=3.0.2,<3.6.0; python_version >= "3.10"',
'PyYAML',
],
extras_require={
Expand Down