Lua Api Function And Module Reference; Lua Callback Functions Called From C; Function 'Initialize; Function 'Loop - HMS Networks IXXAT CAN@net NT User Manual

Table of Contents

Advertisement

Lua API Function and Module Reference

5
Lua API Function and Module Reference
5.1

Lua Callback Functions Called from C

5.1.1

Function 'initialize'

initialize()
Called once while the firmware is being initialized. It is used to register CAN and MQTT messages
for reception and to initialize variables.
5.1.2

Function 'loop'

loop(ticks, elapsed)
Called cyclically every 100 ms after the initialization phase, when the device is up and running. It
is used to trigger cyclically recurring tasks.
ticks: counter value that is incremented with each call of loop
elapsed: time in ms since the last call of loop
5.1.3

Function 'on_can'

on_can(topic, port, format, ident, data)
Called on each CAN message reception, based on message registrations via
can.register_msg.
topic: user defined reference value used by
port: CAN port number (1 .. 4), depending on the available CAN ports of the target device
format: combination of three characters to specify the message format, e.g.:
csr means: "classic CAN", "standard identifier (11 bit)", "remote frame"
fed means: "CAN-FD", "extended identifier (29 bit)", "data frame"
ident: CAN message identifier (0 .. 0x7FF for standard messages and 0 .. 0x1FFFFFFF
for extended messages)
data: message data bytes provided as Lua table or as byte array (see module array)
5.1.4

Function 'on_mqtt'

on_mqtt(handle, topic, payload, qos)
Called on each MQTT message reception, based on message registrations via
mqtt.subscribe.
handle: user defined reference value used by
topic: message topic as string
paqload: message data as string
qos: quality of service (0, 1, 2)
CAN@net NT/CANbridge NT User Manual
can.register_msg
mqtt.subscribe
4.02.0332.20002 1.2 en-US
12 (22)

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the IXXAT CAN@net NT and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Ixxat canbridge nt

Table of Contents