Author Topic: LUA interpreter : how to autostart a lua program  (Read 3377 times)

0 Members and 1 Guest are viewing this topic.

Offline free_electronTopic starter

  • Super Contributor
  • ***
  • Posts: 9056
  • Country: us
    • SiliconValleyGarage
LUA interpreter : how to autostart a lua program
« on: July 06, 2016, 10:18:18 pm »
anyone using eLUA on Cortex ?
i want to know how i can run a lua program automatically on startup. google is broken ...

basically : is there an autoexec.bat ?
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline bson

  • Supporter
  • ****
  • Posts: 2821
  • Country: us
 

Offline joseph nicholas

  • Frequent Contributor
  • **
  • Posts: 408
  • Country: mx
Re: LUA interpreter : how to autostart a lua program
« Reply #2 on: July 06, 2016, 11:45:41 pm »
The default for that is init.lua.  It runs automatically on start up.

 

Offline free_electronTopic starter

  • Super Contributor
  • ***
  • Posts: 9056
  • Country: us
    • SiliconValleyGarage
Re: LUA interpreter : how to autostart a lua program
« Reply #3 on: July 07, 2016, 05:16:30 pm »
so if i add an init.lua to the rom filesystem that one will run ?

i want to make a small self starting lua script that checks for the presence of a flash memory on spi or i2c. if the memory is found and it contains a specific signature it will create a new file in the write once filesystem and copy the data from the eeprom over. this then becomes a new lua program that is called and launched.

Think of it as a small LUA bootloader.
lua starts and then launches my loader. this loader checks for the existence of an eeprom. if it exists : read signature. then : check eif app.lua exists in internal worm. if it does : compare signatures. if they match  :run app.lua. if they dont match : cope eeprom contents in new app.lua and then launch app.lua

the idea is to have the control program for a sensor reside in the sensor. if i plug it into the system (lua based) this will detect the sensor and automatically install the driver for it.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline chipah

  • Newbie
  • Posts: 4
  • Country: us
Re: LUA interpreter : how to autostart a lua program
« Reply #4 on: July 12, 2016, 12:36:04 am »
I work with the open source Apache Mynewt OS that has a lua interpreter:
https://mynewt.apache.org/latest/os/modules/elua/elua/

There is a sample app on github (app called "latest") that currently initializes lua via shell (so you can manually run the lua script at the prompt).
https://github.com/apache/incubator-mynewt-core/blob/master/apps/luatest/src/main.c

The shell command calls the lua_main(argc, argv) as shown in
https://github.com/apache/incubator-mynewt-core/blob/master/libs/elua/elua_base/src/lmynewt.c

You could write an app that calls lua_main() to start automatically on some trigger or periodically.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->