01-27-2021 05:58 AM
Hi everyone
I'm trying to make a TCP/IP connection with a PLC, using an open source DLL wrriten in .NET (This Library)
first of all I create an Action Step, and call the object ModbusClient and the Connect method:
ModbusClient().Connect("device ip", port)
then I create the second Action Step, and call the WriteSingleCoil method to write a True status to Address 8193:
ModbusClient().WriteSingleCoil(8193,True)
after second step execution I get an exception error: connection error
it seems that first step execute independently and when the program execute the second step, the connected TCP/IP connection at the first step does not exist anymore.
I've read somewhere that we must store Object Reference in a Local variable and define it in the rest of the functions in different steps.. but I don't know what it means and don't know what to do..
I'm quite new to Teststand.. can anybody help ??
Thank you, Eric.
Solved! Go to Solution.
02-02-2021 01:05 AM - edited 02-02-2021 01:40 AM
02-10-2021 06:42 PM
Hi ericmateovisan,
You can create first object reference then use "Use Existing Object(EasyModbus.ModbusClient).Connect(System.String, Int32)" in your next steps.
1. Create object .NET Invocation = ModbusClient(), return value is object reference
2. .NET Invocation= Use Existing Object(EasyModbus.ModbusClient).Connect(System.String, Int32)
3. .NET Invocation= Existing Object(EasyModbus.ModbusClient).WriteSingleCoil(Int32, Boolean)
important point is here, that you need to use only existing object.
check it please here topic: Use Existing Object
https://zone.ni.com/reference/en-XX/help/370052AB-01/tsref/infotopics/db_editnetcall_module/
02-13-2021 05:03 AM - edited 02-13-2021 05:08 AM
02-13-2021 05:08 AM
@sezgin.caluk wrote:
Hi ericmateovisan,
You can create first object reference then use "Use Existing Object(EasyModbus.ModbusClient).Connect(System.String, Int32)" in your next steps.
1. Create object .NET Invocation = ModbusClient(), return value is object reference
2. .NET Invocation= Use Existing Object(EasyModbus.ModbusClient).Connect(System.String, Int32)
3. .NET Invocation= Existing Object(EasyModbus.ModbusClient).WriteSingleCoil(Int32, Boolean)
important point is here, that you need to use only existing object.
check it please here topic: Use Existing Object
https://zone.ni.com/reference/en-XX/help/370052AB-01/tsref/infotopics/db_editnetcall_module/
thank you for your reply... this solved my problem. thank you so much 😊💙