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

get can try to read registers where none exist in the tags file #69

Open
alexrudd2 opened this issue Jun 19, 2023 · 0 comments
Open

get can try to read registers where none exist in the tags file #69

alexrudd2 opened this issue Jun 19, 2023 · 0 comments

Comments

@alexrudd2
Copy link
Member

alexrudd2 commented Jun 19, 2023

The code in get() to determine if registers should be read has an overly-broad match:

    async def get(self) -> dict:
        """Get values of all tags with assigned modbus addresses.

        Returns:
            A dictionary of {tag: value} pairs.
        """
        result = {}
        if 'discrete_output' in self.addresses:
            result.update(await self._read_discrete(self.addresses['discrete_output']))
        if 'discrete_input' in self.addresses:
            result.update(await self._read_discrete(self.addresses['discrete_input'],
                                                    output=False))

        for type in ['input', 'holding']:
            if type in self.addresses:
                result.update(await self._read_registers(type))

for type in ['input'][...] will match discrete_input and therefore try to read input registers, even if none are present in the tags file / self.addresses. This will eventually raise ValueError("Missing data type.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant