Advertisement

Quick Links

CAN@net NT/CANbridge NT
Lua ADK
USER MANUAL
4.02.0332.20002 1.2 en-US ENGLISH

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

Summary of Contents for HMS Networks IXXAT CAN@net NT

  • Page 1 CAN@net NT/CANbridge NT Lua ADK USER MANUAL 4.02.0332.20002 1.2 en-US ENGLISH...
  • Page 2 HMS Networks reserves the right to modify its products in line with its policy of continuous product development. The information in this document shall therefore not be construed as a commitment on the part of HMS Networks and is subject to change without notice. HMS Networks makes no commitment to update or keep current the information in this document.
  • Page 3: Table Of Contents

    Table of Contents Page Purpose of this Document ....................3 Description of Ixxat Lua ADK ....................4 Difference between Standard Lua and Ixxat Lua ADK..............4 Lua Library Functions Enabling the Registration of Lua Callbacks ..........4 Limitations of the Ixxat Lua ADK ..................5 Specifics in Coding for the Ixxat Lua ADK ................5 2.4.1 Bit Model 32 Bit Version..................
  • Page 4 This page intentionally left blank...
  • Page 5: Purpose Of This Document

    3 (22) Purpose of this Document The Lua ADK FAQ answers common questions concerning the development of Lua applications for Ixxat CAN@net NT and CANbridge NT. For information how to program in Lua, refer to Lua resources on the internet: •...
  • Page 6: Description Of Ixxat Lua Adk

    Description of Ixxat Lua ADK 4 (22) Description of Ixxat Lua ADK The Ixxat Lua ADK is based on the standard Lua 5.3.5 distribution, a fully featured implementation of Lua 5.3. The implementation is optimized for embedded system development and execution to provide a scripting framework that can be used to deliver useful applications within the limited RAM and Flash memory resources of embedded processors.
  • Page 7: Limitations Of The Ixxat Lua Adk

    Description of Ixxat Lua ADK 5 (22) For more information see the module documentation in Lua API Function and Module Reference, Limitations of the Ixxat Lua ADK The Ixxat Lua ADK has hardware resource limitations because code is loaded from the Flash file system into off-chip RAM and executed there.
  • Page 8: Declaring Variables

    Description of Ixxat Lua ADK 6 (22) 2.4.3 Declaring Variables Two types of data can be assigned to Lua variables: • values such as numbers, booleans, and strings • references such as functions, tables, and user data For example, if the contents of variable a are assigned to variable b, there is a difference between values and references.
  • Page 9: Using Lua Adk With The Can Nt Devices

    Using Lua ADK with the CAN NT Devices 7 (22) Using Lua ADK with the CAN NT Devices The use of the ADK is only possible in Bridge operational modes. The Lua ADK supports two operational modes: • running the Lua script on the target device in autonomous mode (target mode) •...
  • Page 10: How To Use Lua In Target Mode

    Using Lua ADK with the CAN NT Devices 8 (22) How to Use Lua in Target Mode? In the CAN-Gateway Configurator enable the use of the Lua ADK in target mode (see How to ► Enable the Use of the Lua ADK?, p. In the toolbar open menu Target and select Write configuration to target to write the ►...
  • Page 11: How To Use Lua In Remote Mode

    Using Lua ADK with the CAN NT Devices 9 (22) How to Use Lua in Remote Mode? Running the Lua script on the host PC and using it in remote mode can be used for example for debugging. The recommend IDE is ZeroBrane Studio.
  • Page 12: Creating Lua Scripts

    Creating Lua Scripts 10 (22) Creating Lua Scripts How does the Lua ADK Event System Work? Understanding how the system executes the code can help you to structure the code better and to improve both performance and memory usage. • Ixxat Lua ADK uses the tree kinds of callback functions initialize, on_...
  • Page 13: Example Applications

    Creating Lua Scripts 11 (22) Example Applications Various example applications can be found after installation of the CAN-Gateway Configurator download package in folder C:\Users\Public\Documents\HMS\Ixxat CAN-Gateway Configurator \\Examples\Lua. Example application Description \can_demo.lua Shows how to handle (send and receive) CAN messages via Lua. \canfd_demo.lua Shows how to handle (send and receive) CAN FD messages via Lua.
  • Page 14: Lua Api Function And Module Reference

    Lua API Function and Module Reference 12 (22) Lua API Function and Module Reference 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.
  • Page 15: C Functions Called From Lua

    Lua API Function and Module Reference 13 (22) C Functions Called from Lua 5.2.1 Module 'misc' Functions from the module misc are loaded by default and are directly available. Function 'hex' hex(val) Converts the parameter val into a hexadecimal representation. Function 'dump' dump(o, indent, nested, level) Dumps values in a one-statement format.
  • Page 16: Module 'Can

    Lua API Function and Module Reference 14 (22) 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}) --> [01, 02, 03, 04] Function 'can.
  • Page 17: Module 'Mqtt

    Lua API Function and Module Reference 15 (22) Function 'can.set_crossbar_switch' can.set_crossbar_switch(rx_port, tx_port, turn_on) Turns the device internal message stream on or off. Message streams are specified by the CAN ports (receive and transmit can port). The uni-directional message flow between these ports can be turned on and off with the crossbar switch.
  • Page 18 Lua API Function and Module Reference 16 (22) Function 'sys.get_ms_time' sys.get_ms_time() Returns the system time (32 bit value) in milliseconds. Function 'sys.get_us_time' sys.get_us_time() Returns the system time (32 bit value) in microseconds. Function 'sys.call_after' sys.call_after(ticks, func, arg) Calls the Lua function func after ticks system ticks (resolution is 1 ms). arg can be used as parameter for func and should be a numeric value.
  • Page 19: Module 'Json

    Lua API Function and Module Reference 17 (22) Function 'sys.logging' sys.logging(severity, message) Writes a test message into the LOG/ERR file, e.g. sys.logging("E", "my log message"). • severity: possible values: e'X'ception, 'E'rror, 'W'arning, or 'L'ogging • message: text string 5.2.5 Module 'json' The module json is optional and has to be loaded via json= sys.dofile('json.lua').
  • Page 20 Lua API Function and Module Reference 18 (22) Function 'array.insert' a = array.insert(a, [pos,] value) Inserts element value at position pos in a, shifting up the elements a[pos] ···, a[#a]. The default value for pos is #a+1, so that a call array.insert(a, x) inserts x at the end of array a.
  • Page 21 Lua API Function and Module Reference 19 (22) References to additional function parameters are also possible: -- copy 2 byte variables and 2 bytes from the source array to the destination array format = array.compile("@1,@2,#3,#4") dest_array = array.repack(format, src_array, var1, var2) -- this corresponds to dest_array[1] = var1 dest_array[2] = var2...
  • Page 22 This page intentionally left blank...
  • Page 23: A Lua License

    Appendix A: Lua License 21 (22) Lua License Copyright © 1994–2019 Lua.org, PUC-Rio. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:...
  • Page 24 last page © 2020 HMS Industrial Networks Box 4126 300 04 Halmstad, Sweden info@hms.se 4.02.0332.20002 1.2 en-US / 2020-11-26 / 20851...

This manual is also suitable for:

Ixxat canbridge nt

Table of Contents