Author Topic: ModbusTCPCom1.DisableSubscriptions = True not Working  (Read 1771 times)

Slowpaddle

  • Newbie
  • *
  • Posts: 4
    • View Profile
ModbusTCPCom1.DisableSubscriptions = True not Working
« on: March 19, 2023, 11:13:37 AM »
Overview: I have an ESP-01 programmed using the ModbusIP_ESP8266.h library. The AHMI can read and write the registers without issue. I am using 12 basic buttons to set the register bits and 12 pilot lamps to give register state feedback. But there is something that's confusing me about the connection.

I have two buttons that Enable and Disable the ModbusTCPCom1 connection.

Enable = ModbusTCPCom1.DisableSubscriptions = False
Disable = ModbusTCPCom1.DisableSubscriptions = True

Oddly though, after I disable the subscriptions the program is still able to communicate with the external device when I use the basic buttons to change register values. The pilot lamps however do not respond to the changes.

Can anyone here explain why this happens?

I hope I gave enough detail. If not I can give more. Thanks.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: ModbusTCPCom1.DisableSubscriptions = True not Working
« Reply #1 on: March 19, 2023, 11:37:11 AM »
To me, that seems like a correct behavior.

You are really disabling subscriptions and not the connection.
That's why your buttons are still sending the Write requests out while your pilot lamps are not receiving the data.

Maybe you could add some more code to disable/enable those buttons when you disable/enable subscriptions.

Slowpaddle

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: ModbusTCPCom1.DisableSubscriptions = True not Working
« Reply #2 on: March 19, 2023, 03:32:11 PM »
I did that and it works fine. I thought disabling the subscriptions meant disconnecting altogether.

Anyway, thanks for the help.