
— 29 —
10. Program initialization
Like filters, the initialization section is defined by the keyword
init()
with no parameters, after which
its subprogram follows in curly brackets:
init()
{
}
The
init()
function
can be used to initialize program variables. Its subprogram code will be executed
on Device power-up prior to any other code. It is not possible to
send()
data from
init()
, as
init()
code is executed before the Device finishes NMEA 2000 "address claim" procedures. All
send()
calls from
init()
will be ignored.
11. Heartbeat
Like filters or
init()
, heartbeat is defined by the keyword
heartbeat(ms)
after which its subprogram
follows in curly brackets. Heartbeat requires integer parameter (constant) which specifies repeat interval
in milliseconds.
heartbeat(1000)
{ # This code will be executed every second
}
Function
heartbeat()
can be used when a code must be executed periodically. The
heartbeat()
is first
called from the user's program immediately after
init()
.
12. User function: func() and call()
Device supports one user function
func()
which can be called from any other subprogram via
call()
. Like
filters or
init()
, user function is defined by the keyword
func()
after which its subprogram follows in
curly brackets. Example 5 shows
func()
called from
heartbeat()
function via
call()
.