The LspNetIo and LspDiskIo Examples

LspNetIo (for RTOS without a file system)

Lua Network IO

The LspNetIo example is designed for rapid "first-time" deployment of an LSP development environment for embedded systems. The file system used by this example is our proprietary Network File System (NetIo for short). The NetIo is typically configured such that it connects back to your host computer (PC) during development. You use the Web File Server running on your PC as the file server for the NetIo client running in your device. A pre-compiled Web File Server can be found in BAROOT/bin/wfs.

Instructions:
  1. Import the source code into your build process:
    1. Include BAROOT/amalgamation/BAS.c in your build. See the readme file in the amalgamation directory for details.
  2. The "LspNetIo/lsp" sub-directory contains a few Lua and LSP example scripts. The embedded system will fetch this code via the NetIo so this code must be made easily available to the embedded system. We suggest that you do the following:
  3. Start the pre-compiled Web File Server on your PC or host Linux system (BAROOT/bin/wfs).
  4. Start a browser, preferably Chrome, and navigate to http://pc-ip-address. Do not use 'localhost'; use the IP address of your PC. You should see the WFS integrated default page.
  5. Enter the URL http://pc-ip-address/fs/ to get to the WFS's integrated Web File Manager.
  6. Use the Web File Manager presented in your browser and navigate to the directory where you have the Lua and LSP resources from (1) above. Make sure you see the ".config" file and the "www" subdirectory in the Web File Manager.
  7. Copy the URL to this directory from your browser to the computer's clipboard.
  8. Open src/LspNetIo.c in an editor and locate the NETIO_URL macro. Replace the default value with the URL in your computer's clipboard. This URL is used by the NetIo client when connecting via the WFS server to the Lua and LSP resource directory on your PC.
  9. Set the required macros for BAROOT/amalgamation/BAS.c and adjust it for your platform. The source code in BAS.c includes all C code from the Barracuda Application Server C source code library so you do not need to compile and link with the standard libraries when using the LspNetIo example.
  10. Add the two C source code files src/LspNetIo.c and BAROOT/amalgamation/BAS.c to your IDE.
  11. Create an RTOS thread and have this thread call function "void barracuda(void)" in src/LspNetIo.c. This function does not return. The function sets up the web server environment and enters the Barracuda Server socket dispatcher SoDisp.
  12. Add the following paths to your build env: BAROOT/inc and BAROOT/inc/arch/xxx, where xxx is one or several directories. You can find these directories by searching for /inc/ in the Target.mk platform makefile for your target environment. See the BAROOT/builds/ directory for more information.
  13. The src/LspNetIo.c code prints status information to the trace, thus you must enable the Barracuda trace and redirect the trace to a console. You must also install an error handler. See examples/misc/standalone/HostInit.c for example code.
  14. Compile and link the code.
  15. Start your embedded device and look for trace printouts in the console (12 above).
  16. Use a browser and enter the url http://your-device-ip-address.

LspNetIo Options

The code can be compiled with the below options (using compiler macros). See the source code LspNetIo.c for details on how the macros are used for configuring the server.

Development or release mode:

Include resource files (optionally enable one of the following):

Note: the .config script (in the lsp directory) is designed to detect the WEBRSR_RTL mode and to configure the server accordingly. See the .config script for details. WEBRSR_EH and WEBRSR_RTL include the ZIP files as embedded ZIP files (BAIO_EZIP). You must modify the example code if you want to use external ZIP files. Please note that LspNetIo is an example and should only be used as a template for designing your own startup code.

LspDiskIo (for RTOS with file system)

The LspDiskIo, also designed for rapid development, uses the DiskIo instead of the NetIo; thus a file system is required in the device and a DiskIo implementation must be used for your file system. See the BAROOT/xrc/DiskIo/ directory if a DiskIo implementation is available for your file system. Note that the LspDiskIo example does not provide the options found in LspNetIo such as the develop/release modes. The LspDiskIo is designed for development mode only and does not include the optional resource files found in the LspDiskIo example.

Rapid development in the LspDiskIo is facilitated by enabling you to map/mount your device as a network drive from your host computer. The LspDiskIo example includes a WebDAV network drive that makes it possible to directly edit LSP files stored on the embedded file system in the device. The video to the right shows how to map a WebDAV network drive from Windows and how to mount a drive from Mac OS X. Note: the included WebDAV network drive is configured for rapid setup and it does not include authentication. Anyone with access to your network can mount the file system in the embedded device.

Instructions:
  1. Set the required macros for BAROOT/amalgamation/BAS.c and adjust it for your platform. The source code in BAS.c includes all C code from the Barracuda Application Server C source code library so you do not need to compile and link with the standard libraries when using the LspDiskIo example.
  2. Add the two C source code files src/LspDiskIo.c and BAROOT/amalgamation/BAS.c to your IDE.
  3. Add the DiskIo implementation for your file system to your IDE. The DiskIo implementations can be found in the directory BAROOT/xrc/DiskIo/.
  4. Create an RTOS thread and have this thread call function "void barracuda(void)" in src/LspDiskIo.c. This function does not return. The function sets up the web server environment and enters the Barracuda Server socket dispatcher SoDisp.
  5. Add the following paths to your build env: BAROOT/inc and BAROOT/inc/arch/xxx, where xxx is one or several directories. You can find these directories by searching for /inc/ in the Target.mk platform makefile for your target environment. See the BAROOT/builds/ directory for more information.
  6. The src/LspDiskIo.c code prints status information to the trace, thus you must enable the Barracuda trace and redirect the trace to a console. You must also install an error handler. See examples/misc/standalone/HostInit.c for example code.
  7. Compile and link the code.
  8. Start your embedded device and look for trace printouts in the console (6 above).
  9. Map/mount the following WebDAV URL: http://your-device-ip-address/fs/
  10. Copy the files including the sub-directory from the LspNetIo 'lsp' directory to the mapped network drive.
  11. Restart your embedded device (this is necessary since we need to execute the Lua code in the .config file we copied to the file system on the embedded device).
  12. Use a browser and enter the url http://your-device-ip-address. You should see the content of the index.lsp page.
  13. You can now use any editor and directly edit/create LSP files in the 'www' directory on the mounted network drive.