Skip to content

Simulator not returning proper exception codes. #2642

@Lucas-Morais-Freire

Description

@Lucas-Morais-Freire

Hi. I would like to report that I have found an use case where the library does not conform to modbus protocol.

Trying to reach invalid addresses should return an exception code 0x02 as per the protocol. The pymodbus library conveniently has a way to label some addresses as invalid in the setup.json file, but this functionality has been a bit broken since the change from 3.9.0.

Steps to reproduce:

  1. clone this simple repo that I made to illustrate the issue.
  2. install version 3.8.6 of pymodbus
  3. execute python simulator.py
  4. execute python client.py 0
  5. execute python client.py 4
  6. Now install version 3.9.0 of pymodbus
  7. repeat steps 3 through 5

The setup.json in this file has only 4 memory locations where addresses 0 and 1 are invalid and addresses higher than 3 do not exist. Observe that with version 3.8.6, accessing address 0 makes the server print the correct function code (131) with the correct exception code (2), because 0 is marked as invalid in setup.json. Still, accessing address 4 should have made the server print the same values as the case with address 0 since it is invalid because its out of range. Instead, the server builds a 0x00 exception response with SLAVE_FAILURE exception code. which the client understands as IO failiure instead of a normal exception. Now, with version 3.9.0, the case with address 0 returns no issue, and the problem with address 4 still exists.

I would really appreciate if you would let me know if I did anything wrong in my setup to cause these issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions