Git Product home page Git Product logo

Comments (10)

OrangeTux avatar OrangeTux commented on August 22, 2024

If I understand you correctly the validate_crc of a response failes? Could you post a stacktrace/error?

from umodbus.

petonic avatar petonic commented on August 22, 2024

Hi! Thanks for responding.

I can dig up the exception, but it has to do with the fact that write_multiple_registers() is expecting a response and when it times out, it still calls validate_crc() with an empty buffer, which then gives the exception. Should I trap for that and then handle exceptions that way?

Do you still need a stack trace or is that expected behavior?

from umodbus.

OrangeTux avatar OrangeTux commented on August 22, 2024

I understand the case and I agree that the raising the exception in validate_crc is a bit weird. Earlier in the process an error should be raised.

def send_message(adu, serial_port):
    """ Send Modbus message over serial port and parse response. """
    serial_port.write(adu)
    response = serial_port.read(serial_port.in_waiting)

    if len(response) == 0:
        raise TimeoutError

    return parse_response_adu(response, adu)

from umodbus.

petonic avatar petonic commented on August 22, 2024

from umodbus.

OrangeTux avatar OrangeTux commented on August 22, 2024

If you want to fix it I'm happy to receive a pull request.

from umodbus.

petonic avatar petonic commented on August 22, 2024

from umodbus.

OrangeTux avatar OrangeTux commented on August 22, 2024

Good finding. I don't think that validate_crc is a proper place to do the length check. What would be
good error tho raise in this place and how should both rtu client and server handle it?

I think rtu.RTUServer.serve_once should check if length of request_adu. If length is 0 the method must not return the try to process the request and return a response, like you said, but it should raise an error. I think a TimeoutError fits best.

from umodbus.

clevert-pretto avatar clevert-pretto commented on August 22, 2024

Hi there,
Is this issue is still unsolved?

from umodbus.

OrangeTux avatar OrangeTux commented on August 22, 2024

No, it isn't yet. But the solution already thought trough in the above comments. So it's very easy to implement. I'll try to fix in somewhere this week.

from umodbus.

OrangeTux avatar OrangeTux commented on August 22, 2024

This has been fixed in the 1.0.0

from umodbus.

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.