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

Fix KeyError when reading > 124 modbus tags #72

Merged
merged 2 commits into from
Jun 28, 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
7 changes: 3 additions & 4 deletions productivity/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ async def read_registers(self, address, count, type='holding', max_count=125):
# if the last address read will be in the middle of a 32-bit tag
# read one less address to avoid bad replies
# https://github.com/numat/productivity/issues/38
last_address = self.map.get(TYPE_START[type] + address + max_count, # type: ignore
None)
last_type = self.tags[last_address]['type'] # type: ignore
offset = -1 if (last_address and last_type in ['int32', 'float']) else 0
last_address = self.map.get(TYPE_START[type] + address + max_count, None) # type: ignore
offset = -1 if (last_address
and self.tags[last_address]['type'] in ['int32', 'float']) else 0 # type: ignore
r = await self._request(f'read_{type}_registers', address, max_count + offset)
address, count = address + (max_count + offset), count - (max_count + offset)
registers += r.registers
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='productivity',
version='0.9.1',
version='0.9.2',
description="Python driver for AutomationDirect Productivity Series PLCs.",
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down