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

Improve doc for area_read in client #493

Closed
bruceunx opened this issue Mar 26, 2024 · 3 comments
Closed

Improve doc for area_read in client #493

bruceunx opened this issue Mar 26, 2024 · 3 comments
Milestone

Comments

@bruceunx
Copy link

  def read_area(self, area: Areas, dbnumber: int, start: int, size: int) -> bytearray:
        """Reads a data area from a PLC
        With it you can read DB, Inputs, Outputs, Merkers, Timers and Counters.

        Args:
            area: area to be read from.
            dbnumber: number of the db to be read from. In case of Inputs, Marks or Outputs, this should be equal to 0.
            start: byte index to start reading.
            size: number of bytes to read.

        Returns:
            Buffer with the data read.

        Raises:
            :obj:`ValueError`: if the area is not defined in the `Areas`

        Example:
            >>> import snap7
            >>> client = snap7.client.Client()
            >>> client.connect("192.168.0.1", 0, 0)
            >>> buffer = client.read_area(Areas.DB, 1, 10, 4)  # Reads the DB number 1 from the byte 10 to the byte 14.
            >>> buffer
            bytearray(b'\\x00\\x00')
        """

dbnumber: number of the db to be read from. In case of Inputs, Marks or Outputs, this should be equal to 0.

from snap7 reference

DB Number if Area = S7AreaDB, otherwise is ignored.

I think maybe use dbnumber: number of the db to be read from when area type is DB, otherwise is ignored to consist with snap7 and less confused.

@lupaulus
Copy link
Contributor

I Agree, the documentation need better reference related to the snap7 library

The set "calls this should be equal to 0", have not the same signification then "otherwise is ignored"

@gijzelaerr
Copy link
Owner

we happily accept PRs with improvements.

@gijzelaerr gijzelaerr added this to the 1.5 milestone May 2, 2024
@gijzelaerr
Copy link
Owner

implemented in #524

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

3 participants