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

Response address xxx is different from request address 33 #168

Open
Syavash-kazemi opened this issue Jul 8, 2022 · 0 comments
Open

Response address xxx is different from request address 33 #168

Syavash-kazemi opened this issue Jul 8, 2022 · 0 comments

Comments

@Syavash-kazemi
Copy link

Syavash-kazemi commented Jul 8, 2022

Hi,
I am trying to read some Modbus addresses from a multi-transducer through a serial port. I am running a loop to get around 5 readings per second.

Here is a snippet of the code:

    try:
        # Connect to the slave
        master = modbus_rtu.RtuMaster(
            serial.Serial(port=CONFIGS["PORT"], baudrate=CONFIGS["SERIAL_BAUDRATE"],
                          bytesize=CONFIGS["SERIAL_BYTESIZE"], parity=CONFIGS["SERIAL_PARITY"],
                          stopbits=CONFIGS["SERIAL_STOPBITS"], xonxoff=0)
        )
        master.set_timeout(0.5)
        master.set_verbose(False)
        logger.info("connected")
        LOGGER_MTR.debug("modbus slave connected")

        while True:
            utc_now = datetime.utcnow()

            master.open()
            try:
                frequency = master.execute(slave=CONFIGS["MODBUS_SLAVE"],
                                           function_code=CONFIGS["MODBUS_HZ_FUNCTION_CODE"],
                                           starting_address=CONFIGS["MODBUS_HZ_STARTING_ADDRESS"],
                                           quantity_of_x=CONFIGS["MODBUS_HZ_BYTES"])
                frequency = unsigned_measurement_to_float(frequency)
            except Exception as try_error:
                LOGGER_MTR.error("failed reading from slave")
                LOGGER_MTR.error(try_error)
                frequency = None
            master.close()
           
            time.sleep(0.15)

So the loop works well and I get readings. However, sometimes I get the next error (this is just an example) for some minutes, before coming back and streaming values again:

...
failed reading from slave
Response address 193 is different from request address 33
Freq: None
failed reading from slave
Response address 193 is different from request address 33
....

So MODBUS_SLAVE is 33, but I don't understand why the master is calling the address 193. I have seen any number being called between 1 and 255.

Am I missing something? What could it be the reason to end up

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