VijeoDesigner 6.2 modbus IP reading script error

Hello,

I am using VijeoDesigner 6.2 SP10.
I try to read Modbus IP using this script:

Code:
int [] data = ModbusEquipment01.getProperty( "Con_IPAddress" );
for( int i = 0; i < data.length; i++ )
{
IP.IPaddr.write( data );
}
and I get this error:
Error S8037: [Switch05- Script] [Line:3] Type "Tag.INTEGER" is not an array type
Variable IPaddr Data Type is INT, I try to use different data types, but the error still remains.

There could be a problem?
 
You appear to be trying to write the entire data array into IPaddr and don't appear to be using the index i anywhere
Variable IPaddr need to be defined as an array of 4 integers
1607666900287.png
Then correct syntax would be
Code:
int [ ] data = ModbusEquipment01.getProperty( "Con_IPAddress" );
for( int i = 0; i < data.length; i++ )
{
IP.IPaddr.write( data );
}
Moderators note : Please use code tags for pieces of code
 
Thank you @agr , then I defined IPaddr as an array of 4 integers, the script do not have anymore errors, but when I am trying to run the script I get the error whitch you can see bellow:
1607686907446.png

As I understood, with this script I should read ModbusEquipment01 IP address, in this case, it should be 10.10.2.247
1607687095318.png

Could you please advice, how I can solve this issue?
 
Thank you @agr , then I defined IPaddr as an array of 4 integers, the script do not have anymore errors, but when I am trying to run the script I get the error whitch you can see bellow:
View attachment 790

As I understood, with this script I should read ModbusEquipment01 IP address, in this case, it should be 10.10.2.247
View attachment 791

Could you please advice, how I can solve this issue?
sorry forgot to make the change to the script after cut/paste.

You are not specifying the index in the data write

your for loop should be

IP.IPaddr.write( data );
 
I dont understand where your issue could be. I setup a new project and added the script/variables and it works fine?

Attached is a copy of my test project (V6.2 SP8)
 

Attachments

Thank you, I found my mistake.
I always do "Start device simulation", I think, that's why I get zero.
Using "Start simulation", everything works fine.
 
You may already be aware of this but the one (or two) IP addresses assigned to the HMI are easily accessible by using System Varialbles. I use this to display the IP address(es) of the HMI on a screen. Configure a "String Display" object on a screen using the variable "Sys.getInfoString(IP_ADDRESS_1)" or ADDRESS_2. The script you are using is for the connected devices such as PLCs.

Regarding simulation: It is possible to connect the simulator (Start Simulation Build) which "duplicates" the "real HMI" to external devices such as a PLC and also to the Unity Pro simulator to test without hardware.
 
Top