mogenson opened a new pull request #5815:
URL: https://github.com/apache/incubator-nuttx/pull/5815


   ## Summary
   
   Add defconfigs for `sim:lua` and `teensy-4.x:lua-4.1` to use the newly added 
[Lua interpreter](https://github.com/apache/incubator-nuttx-apps/pull/1075).
   
   ## Impact
   
   Used to verify the Lua interpreter build in CI.
   
   ## Testing
   
   The `sim:lua` config can be used to verify the example Lua C module:
   
   ```
   NuttShell (NSH) NuttX-10.2.0
   nsh> lua
   Lua 5.4.0  Copyright (C) 1994-2020 Lua.org, PUC-Rio
   > hello.say_hello()
   Hello World!
   nsh>
   ```
   
   The `teensy-4.x:lua-4.1` can be used to run a Lua script from the board's 
microsd card. The following Lua script blinks the onboard LED using the userled 
driver:
   
   ```lua
   -- concatenate strings and print to NSH console
   print("hello from " .. _VERSION)
   
   -- open device driver, file is closed when leds is garbage collected
   leds = io.open("/dev/userleds", "wb")
   
   -- from 1 to 10, inclusive
   for i = 1, 10 do  -- lua convention is to start at 1
       -- pack value into uint32_t and write to file
       leds:write(string.pack("I", i % 2))
       leds:flush()
   
       -- run sleep command from NSH
       os.execute("sleep 1")
   end
   ```
   
   ```
   NuttShell (NSH) NuttX-10.2.0
   nsh> mount -t vfat /dev/mmcsd0 /mnt
   nsh> lua /mnt/main.lua
   hello from Lua 5.4
   nsh> 
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to