Flexy reboot if PLC communication is lost?

Would it be possible to get a script example that would reboot the Flexy if the communication with the PLC dropped out? Thank you in advance.

@wesmoore Please see below for the script example. What I’ve done is I’ve modified the example from our developer portal (I’ve included a link to this script at the bottom of the post). While the eWON does not have a ping function, it does have a similar function called OPEN. First, you would set a timer in your Init section such as below:

INIT SECTION

TSET 2,20
ONTIMER 2, "goto Ping"

In my example, I’ve set timer 2 to occur every 20 seconds and to point to the Ping process, which you can see below. You can adjust this to occur more or less frequently. I have placed the following script in a custom section which I’ve named “Ping” on my device.

PING (CUSTOM SECTION):

Ping:  
    PRINT "Initiating PING to PLC IP 10.0.120.122:80,10 at ";Time$  
    CLOSE 1  
    ONSTATUS "goto ProcessStatus" 
    OPEN "tcp:10.0.120.122:80,10" FOR BINARY OUTPUT AS 1  
    a% = GETSYS PRG,"ACTIONID" 
END  
   
ProcessStatus:  
    PRINT "Process starting ";Time$  
    b% = GETSYS PRG,"EVTINFO" 
    IF b%=a% THEN  
        SETSYS PRG,"ACTIONID",a%  
        c% = GETSYS PRG,"ACTIONSTAT" 
        IF c%=0 THEN  
            PRINT "PING 10.0.120.122:80 success" 
        ELSE  
            PRINT "PING FAILED, initiating reboot at ";Time$
            REBOOT
        ENDIF  
        CLOSE 1  
    ENDIF  
END

My example utilizes the example IP address of 10.0.120.122 with port 80. You can customize the IP address, ports, and print statements depending on if it is successful or unsuccessful. As you can see in the second part of the script, the command REBOOT initiates the eWON to reboot.

As stated above, please navigate to https://developer.websupport.ewon.biz/content/perform-ping-function-basic to see the example I referred to for this example.

Please let me know if this answers your question and if you have any other questions or concerns that I can help you with!

Best regards,
Ashley

1 Like

Hi!

I would like to do something similar. I would like to initiate an auto-reboot command/script when eWon cant ping the server/IP address.

Can you help me with configuring this? My main problem is that I cant find:
" INIT SECTION" and “Custom Section” where I can configure this script.

I have a Flexy 202 and 205 on firmware version Firmware: 14.3s0 (#1427).

Thank you!

Br, Miloš