Author Topic: ModbusTCPCom1.write returns a value, what is it?  (Read 921 times)

scott.clark

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
ModbusTCPCom1.write returns a value, what is it?
« on: April 14, 2021, 05:36:55 PM »
When executing:

Code: [Select]
dim strReturn as string
 strReturn = ModbusTCPCom1.write(PLCTagAddress,Value)

What does the value returned represent?  its typically a varying number between 250 and 300.

I was looking for a way to detect when the target PLC is not communicating. 

With a ModbusTCPCom1.read, if there is no communications, there is and exception the can be handled with at Try/Catch.

I haven't been able to figure out how to validate that a ModbusTCPCom1.write is successful.

Alpaslan

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: ModbusTCPCom1.write returns a value, what is it?
« Reply #1 on: May 01, 2021, 08:21:20 PM »
Try this.

Quote
       Try
         ModbusTCPCom1.write(PLCTagAddress,Value)
       Catch ex As Exception
           System.Windows.Forms.MessageBox.Show("Couldn't write to PLC. Error: " & ex.Message)
       End Try
One step at a time baby, One step at a time.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: ModbusTCPCom1.write returns a value, what is it?
« Reply #2 on: May 05, 2021, 11:21:51 PM »
The value returned is a transaction ID that can be used in the Error and DataReceived events.

scott.clark

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: ModbusTCPCom1.write returns a value, what is it?
« Reply #3 on: May 11, 2021, 09:38:43 AM »
Thanks for the explanation!