Using the Lantronix SGX 5150 Serial Device Server
24
CR6 Program
The following code is an example of power cycling a device, such as an SGX-5150, nightly to reconnect to a
local Wi-Fi network.
This program uses a
TimeIntoInterval
function and the SW12 function to turn off power to the connected
device at 12am for 5 seconds and then enable SW12 to turn back on.
It is important to note that a CR6 has 2 SW12 ports. The SW12 function takes in two parameters, the first is
port (1 or 2) and the second is state (ON or OFF). A 0 value in the port parameter turns the port off and any
non-zero value will turn the port on.
The TimeIntoInterval function takes three parameters listed below.
1.
TintoInt
is the time into interval, acting as an offset from the interval parameter.
2.
Interval
is how frequently the TintoInt parameter will be evaluated as true, resulting in the code within the
statement to be ran. It is important that this parameter is an integer (whole number).
3.
Units
is the parameter used to define the units of the previous two parameters. These units will be time
and the following are accepted inputs.
a. Msec (milliseconds)
b. Sec (seconds)
c. Min (minutes)
d. Hr (hours)
e. Day (days)
f.
Mon (months)
(Figure 35)