Read connected interface with BASIC IDE

Hello guys

At the moment I’m trying to read this information in BASIC IDE and write it to my PLC-variables
grafik

I tried it with

`Setsys COM,“load”
WANFbckCnx$ = GETSYS COM,“WANFbckCnx”

and

Setsys COM,“load”
WANCnx$ = GETSYS COM,“WANCnx”
`

But then I only know what is configured.
How can I read which one is active?

Additional Information:

My PLC now already knows the following things:

  • If Internet is connected or not
  • If VPN is established or not
  • Which interface is configured for normal mode
  • Which interface is configured for fallback mode

Now basically the only additional information i’d need to be able to read via BASIC IDE is whether fallback is active or not.

Any Ideas?

Hello,

I would review this document below. It will show all the com.cfg parameters and what they mean. You will need to write some code to define the intergar parameters as well.

This com.cfg has all connection status, and connect types. It will display a an intergar that you will need to translate via code.

Hello @Kevin_hms

Basically all I need to know is which interface is connected at the moment.
I looked through the whole comcfg documentation twice but I couldn’t find anything useful. I even looked through the programming reference guide and wasn’t able to find anything there either.

Any ideas how to solve my problem?

Cheers
pstark

For the WAN connection type and Fallback, you will need to reference two COM parameters: WANCNX & WANFBCKCNX

image

image

This will show which which is active, and what type is active. You can code it to to send either the integar to a Tag, or translate it to the String definition to send to a Mem String Tag.

This integer only shows what is configured for main connection and what is configured for fallback connection.

In my case I want to see which one is active - I don’t want to see what is configured.

You can use the following script to verifiy which Connection is active:

ONTIMER 1,“GOTO T1”
TSET 1,1

T1:
SETSYS INF, “LOAD”
IsFallBackActive% = VAL GETSYS INF, ‘IsWANFallbackUsed’
SETSYS COM, “LOAD”
IF IsFallBackActive% THEN
PRINT GETSYS COM, “WANFbckCNX”
ELSE
PRINT GETSYS COM, “WANCNX”
ENDIF
END

This is an example, so you will need to modify code to fit your needs. The most important part of the script is

IsFallBackActive% = VAL GETSYS INF, ‘IsWANFallbackUsed’

Hello @Kevin_hms

Thank you very very much!
I haven’t checked the estat.htm file yet which is accessible via GETSYS INF yet.
This might be the solution to my problem!

Will try it tomorrow.

Cheers,
pstark

Hello,

Excellent, Let me know your results.

I tested the script on my end and it does work to verify which connection is being used.

Hello Kevin

This works perfect! Thank you.

One more thing I don’t quite know how to fix:

I am changing my main and fallback connection with the following code in the init section in BASIC:

GET_EWON_INTERFACES:
SETSYS INF, "load"
FallbackActive@ = VAL GETSYS INF, "IsWANFallbackUsed"

Setsys COM,"load"
WANCnx$ = GETSYS COM,“WANCnx” //0 None 1 GSM 2 Ethernet 4 Wi-Fi
WANCnx@ = FCNV WANCnx$, 30, 0, "%d"
WANFbckCnx$ = GETSYS COM,“WANFbckCnx” //0 None 1 GSM 2 Ethernet 4 Wi-Fi
WANFbckCnx@ = FCNV WANFbckCnx$, 30, 0, "%d"
VPNCnxType$ = GETSYS COM,"VPNCnxType"
VPNCnxType@ = FCNV VPNCnxType$, 30, 0, “%d” //0 = disabled, 1 = Incoming VPN, 2 = VPN to Server
WANIP@ = GETSYS PRG,"WANIP"
VPNIP@ = GETSYS PRG,"VPNIP"
GET_EWON_INTERFACES@ = 0
Print "[GET_EWON_INTERFACES] executed"
END

SET_EWON_INTERFACES:
//Stop current connection
Setsys COM,"load"
Setsys COM,“WANCnx”,"0"
Setsys COM,“WANFbckCnx”,"0"
Setsys COM,“WANPermCnx”,"0"
Setsys COM,"save"
//Reset Connection
Setsys COM,"load"
Setsys COM,“WANFbckCnx”, WANFbckCnx@ //0 None 1 GSM 2 Ethernet 4 Wi-Fi
Setsys COM,“WANCnx”, WANCnx@ //0 None 1 GSM 2 Ethernet 4 Wi-Fi
Setsys COM,“WANPermCnx”,"1"
Setsys COM,"save"
Print "[SET_EWON_INTERFACES] executed"
SET_EWON_INTERFACES@ = 0
END

This works perfectly fine as the connection builds up with the new selected interface.
Also when i check comcfg.txt the parameters are set.

Now i tested 3 reboot options:

  1. Reboot via Reboot button in the Web Interface
  2. Reboot via REBOOT in BASIC
  3. Turn off the Ewon’s power supply (in order to simulate a user turning off the machine)

With option 1) the newly set connection is saved
With option 2) and 3) the connection is reset to a previous state.

Now when a plant has a power failure, my connection setup will be reset.
The weird thing is that comcfg.txt has been changed but still after rebooting the old config is back.
How can i solve this problem?

Cheers,
pstark

Hello

Nevermind, I found the “CFGSAVE” command.

This topic can be closed. Thanks again.

Greets,
pstark

Exellent. I am glad you were able to resolve this issue.