Lua API Function and Module Reference
5.2.2
Module 'can'
The module can is loaded by default and can is directly available.
Function 'can.dump_data'
can.dump_data(data)
Formats data as byte hex dump, like:
can.dump_data({1, 2, 3, 4})
Function 'can. register_msg'
can.register_msg({
})
Registers a CAN/CAN-FD message for reception via on_can.
•
handle: user defined reference to the registered message, to be used inside on_can
•
port: CAN port number (1 .. 4), depending on the available CAN ports of the target device
•
format is std for 11-bit, or ext for 29-bit identifiers
•
ident: message identifier
•
data_as possible values:
–
"array": received message payload (data bytes) is provided as byte array (userdata)
–
"table": received message payload (data bytes) is provided as Lua table
•
max_frequency: value in msec for the "message load reduction filter" to reduce the CPU
load. CAN messages is forwarded to Lua with the given maximum frequency. This parameter
is optional. Default value is 0 (no filter is used).
Type "array" has better performance and is therefore the preferred type. Type "table" is
more generic and provides more possibilities to work with the received data.
Function 'can.send'
can.send(port, format, ident, payload)
Sends a CAN message.
•
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: message identifier
•
payload: data bytes of the message as array or table (see "can. register_msg")
CAN@net NT/CANbridge NT User Manual
handle = 1,
port = 1,
format = "std",
ident = 0x100,
data_as = "array",
max_frequency = 500,
--> [01, 02, 03, 04]
14 (22)
4.02.0332.20002 1.2 en-US
Need help?
Do you have a question about the IXXAT CAN@net NT and is the answer not in the manual?