Author Topic: Check for connection  (Read 574 times)

gfulk

  • Newbie
  • *
  • Posts: 8
    • View Profile
Check for connection
« on: August 11, 2017, 02:33:47 PM »
Is there a way to check if a ModbusRTU connection is there or not?
I tried the IsSubscriptionActive() method, but it didn't behave how i thought it would.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5261
    • View Profile
    • AdvancedHMI
Re: Check for connection
« Reply #1 on: August 12, 2017, 09:15:29 AM »
ModbusRTU does not have a "connection" per se as doesn't something like an Ethernet socket. The only way to know if there is a connection is to perform a read and see if it fails.

Try
   ModbusRTUCom1.Read("40001")
   MsgBox ("Successful connection")
Catch ex as exception
   MsgBox ("Failed")
End Try