Coder Social home page Coder Social logo

Comments (4)

ruscito avatar ruscito commented on July 26, 2024

from pycomm.

gman8a avatar gman8a commented on July 26, 2024

For this reason I always send a single tag request as a 'multi' tag request. i.e., read_tag(['tag_1']). Then an error does NOT occur, if tag_1 does not exist. The function response returns None.

If indeed, the tag_1 does exist, then a read_tag('tag_1') works fine.

from pycomm.

ruscito avatar ruscito commented on July 26, 2024

Ahnaf first of all thank, that helped to improve the read_tag method. I slightly change from what you propose because I decided to check self._status and return None instead of a string. There is a method called get_status that normally return a tuple with a number (sort of error number) and a string (containing the error message). See the code below for details

        # Get the data type
        if self._status[0] == SUCCESS:
            data_type = unpack_uint(self._reply[50:52])
            try:
                return UNPACK_DATA_FUNCTION[I_DATA_TYPE[data_type]](self._reply[52:]), I_DATA_TYPE[data_type]
            except Exception as e:
                raise DataError(e)
        else:
            return None

from pycomm.

aporan avatar aporan commented on July 26, 2024

aah, that looks neater. Glad to have helped. I'll close the issue then. Perhaps, you could delete the pr.

from pycomm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.