Home > HMS NETWORKS > HMS NETWORKS CANbridge NT Lua ADK Bridge Router User Guide

HMS NETWORKS CANbridge NT Lua ADK Bridge Router User Guide

CAN@net NT/CANbridge NT Lua ADK  
Creang Lua Scripts  
4. Creang Lua Scripts  
4.1. How does the Lua ADK Event System Work?  
Understanding how the system executes the code can help you to structure the code beer and to improve both  
performance and memory usage.  
• Ixxat Lua ADK uses the tree kinds of callback uncons initialize, on_..., and loop.  
initializeis called once while the system is inializing. It is used to register further events and to set  
CAN message lers.  
loopis called cyclically every 100 ms afer the inializaon phase, when the device is up and running. It is  
used to trigger cyclically recurring tasks.  
on_canand on_mqttuncons are used to handle events from CAN and MQTT.  
• Keep the uncon execuon mes as short as praccal so that the overall system can work smoothly and  
responsively. The general recommendaon is to keep the callbacks under 5 ms in duraon. If exceeded  
inermienproblems because of mailbox overruns of the Lua task might occur.  
• The Lua libraries provide a set of uncons for declaring applicaon uncons (wrien in Lua) as callbacks  
to associate applicaon tasks with specic hardware and mer events. These are also non-preempve  
at an applicaons level. The Lua libraries work in consort with the ADK to queue pending events and  
invoke any registered Lua callback rounes, which then run to compleon uninterrupted. For example  
Luasys.call_after(time, callback, arg)calls a uncon in the syslibrary which registers a  
Lua uncon for this mer alarm. When this alarm is triggered, it will call the Lua callback.  
• Lua uncons iniaed by mer or network events and other callbacks run non-preempvely to compleon  
before the next task can run. This includes all Lua ADK uncons.  
Observe that you are using the wrong approach,  
• if you are not using mers and other callbacks.  
• if you are using poll loops.  
• if you are execung more than a few hundred lines of Lua per callback.  
4.2. Example Applicaons  
Various example applicaons can be found afer insallaon of the CAN-Gateway Conguraor download package  
in folder C:\Users\Public\Documents\HMS\Ixxat CAN-Gateway Confguraor\\Examples\Lua.  
Example applicaon Descripon  
\can_demo.lua  
\canfd_demo.lua  
\coroune.lua  
Shows how to handle (send and receive) CAN messages via Lua.  
Shows how to handle (send and receive) CAN FD messages via Lua.  
Implements a task and delay uncon and show how more than one task can be executed  
simultaneously.  
\hello_world.lua  
\iso15765.lua  
Read and output ADK and device inormaon, addionally blink with the user LED.  
Segmenaon of large CAN FD messages into classic CAN messages using the ISO 15765-2 transport  
protocol  
\mqt.lua  
Shows how to subscribe and publish MQTT messages.  
\mqt_json.lua  
\repack.lua  
Subscribes MQTT JSON messages and sends the messages on CAN and vice versa.  
Repack the data bytes of a receive CAN messages from CAN1 and send on CAN2  
Page 8 of 20  
4.02.0332.20002 Version 1.5  
GeneralDetails
NameHMS NETWORKS CANbridge NT Lua ADK Bridge Router User Guide
MakeHMS NETWORKS
LanguageEnglish
FiletypePDF (Download)
File size MB
Download PDF
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

If you have any questions regarding HMS NETWORKS CANbridge NT Lua ADK Bridge Router User Guide, please ask here and describe the problem in detail.

Leave a Reply

Your email address will not be published. Required fields are marked *

11 + eleven =

HMS NETWORKS CANbridge NT Lua ADK Bridge Router User Guide