Difference between revisions of "Lua development"

From ArmadeusWiki
Jump to: navigation, search
(Links)
m
 
(19 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
==Installation==
 
==Installation==
 
Lua interpreter is not installed in the default rootfs.  
 
Lua interpreter is not installed in the default rootfs.  
'''Lua''' version installed by Buildroot is '''x.x'''.<br>
+
'''Lua''' version installed by Buildroot is '''5.1.2'''.<br>
  
 
* Launch Buildroot's menuconfig:
 
* Launch Buildroot's menuconfig:
 
  armadeus$ make menuconfig
 
  armadeus$ make menuconfig
 
* In  
 
* In  
[[Image:Menuconfig_package.png]] <br> choose <br> [[Image:Menuconfig_package_python.png]] <br>
+
[[Image:Menuconfig_package.png]] <br> choose <br> [[Image:Menuconfig_package_scripting.png]] <br> and <br> [[Image:Menuconfig_package_lua.png]]
 
* choosing ''Lua'' package automatically selects ''readline'' and ''ncurses'' one
 
* choosing ''Lua'' package automatically selects ''readline'' and ''ncurses'' one
 
* then save your configuration and build your system:
 
* then save your configuration and build your system:
 
  armadeus$ make
 
  armadeus$ make
* copy generated rootfs to your NFS directory or on your MMC/SD. If you already have an existing rootfs then just make a:
+
* reflash your rootfs or [[Network_Configuration#Boot_from_NFS | copy it to your NFS directory]] or [[MultiMediaCard#Booting_from_MMC.2FSD |  or on your MMC/SD]].
armadeus$ cp -r buildroot/build_arm_nofpu/root/usr/ /local/export/
+
Here ''/local/export/'' is my NFS directory.
+
  
 
==Source code==
 
==Source code==
 
First take your favorite editor/IDE and create the following script:
 
First take your favorite editor/IDE and create the following script:
  
blah blah blah
+
<source lang="lua">
+
print "Hello from APF ! Today it's:"
blah blah blah
+
print(os.date())
blah blah blah
+
</source>
  
Save it as ????
+
Save it as ''example.lua''
  
 
==Compilation==
 
==Compilation==
Not needed. Transforming Lua script in executables hasn't been tested yet.
+
Not needed. Transforming Lua scripts in "executables" with Luac hasn't been tested yet.
  
 
==Running==
 
==Running==
* Copy your ''xxxxxx'' script on your NFS export directory or on your MMC/SD
+
* Copy your ''example.lua'' script to your APF9328 board through your NFS export directory or your MMC/SD
 
* then on your APF console, launch it:
 
* then on your APF console, launch it:
  # lua xxxxx
+
<pre class=apf>
  APF9328 says: Hello World ! ;-)
+
  # lua example.lua
 +
  Hello from APF ! Today it's:
 +
Thu Jun  6 21:57:17 2007
 
  #
 
  #
 
+
</pre>
Now it's up to you ! ;-)  
+
Now it's up to you ! ;-)
  
 
==Links==
 
==Links==
 
* [http://www.lua.org/ Lua Homepage]
 
* [http://www.lua.org/ Lua Homepage]
 
* [http://www.lua.org/notes/ltn002.html Optimizing Lua for embedded systems]
 
* [http://www.lua.org/notes/ltn002.html Optimizing Lua for embedded systems]
 +
* [http://lua-users.org/wiki/LuaVersusPython Lua compared to Python]
 +
* [http://www.devmaster.net/articles/lua/lua1.php Lua scripting: basics]
 +
 +
[[Category:Software]]
 +
[[Category:Programming language]]

Latest revision as of 20:51, 1 August 2010

On this page you will learn how to create your first Lua script for your Armadeus board. Lua.png

Installation

Lua interpreter is not installed in the default rootfs. Lua version installed by Buildroot is 5.1.2.

  • Launch Buildroot's menuconfig:
armadeus$ make menuconfig
  • In

Menuconfig package.png
choose
Menuconfig package scripting.png
and
Menuconfig package lua.png

  • choosing Lua package automatically selects readline and ncurses one
  • then save your configuration and build your system:
armadeus$ make

Source code

First take your favorite editor/IDE and create the following script:

print "Hello from APF ! Today it's:"
print(os.date())

Save it as example.lua

Compilation

Not needed. Transforming Lua scripts in "executables" with Luac hasn't been tested yet.

Running

  • Copy your example.lua script to your APF9328 board through your NFS export directory or your MMC/SD
  • then on your APF console, launch it:
 # lua example.lua
 Hello from APF ! Today it's:
 Thu Jun  6 21:57:17 2007
 #

Now it's up to you ! ;-)

Links