NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling .NET DLL Error

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(163 Views)

Hi Eric jan,

Check this link, for the part of Local variables.

And also take a look at this, for TestStand.  

Regards.

Message 2 of 5
(118 Views)
Solution
Accepted by topic author ericmateovisan

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/

Message 3 of 5
(95 Views)

@IDASYAN wrote:

Hi Eric jan,

Check this link, for the part of Local variables.

And also take a look at this, for TestStand.  

Regards.




Thank you for your reply 👌

 
0 Kudos
Message 4 of 5
(81 Views)

@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 😊💙

0 Kudos
Message 5 of 5
(78 Views)