Assemble OPC UA for BAS, Mako and Xedge
To add OPC UA to a Barracuda App Server (BAS) build, compile the native module and package the Lua resources from the same release and profile. The native module exposes the compiled standard address space (namespace 0) to Lua. The Lua files implement the client, server and services. Choose minimal or full, then follow the row for your host.
1. Choose the host build
Host |
Native build |
Resources to deploy |
|---|---|---|
Mako Server |
Mako executable, full by default when OPC UA is included |
Matching |
Standalone Xedge |
Xedge executable or firmware, minimal by default when OPC UA is included |
Standalone |
Xedge hosted by Mako |
Mako supplies the native module |
Mako supplies the OPC UA resources. Select the profile when building Mako. |
Custom BAS host |
Build BAS with the chosen selector and register the module in the host’s Lua state |
Put the matching Lua modules in the resource filesystem used by the host’s Lua loader |
The BAS SDK Mako and standalone Xedge makefiles propagate
BA_ENABLE_LUA_OPCUA to both builds. The generic BAS header defaults to
0 when no host build selects a value.
Selector |
C build |
Resource build |
|---|---|---|
|
Packed reader and full namespace 0 |
All OPC UA Lua files |
|
Packed reader and minimal namespace 0 |
Minimal Lua file set listed below |
|
Disable OPC UA registration |
Omit OPC UA Lua files |
|
Host registers an application-supplied native module |
Application supplies the Lua files |
For example, with BAROOT pointing to a configured BAS SDK, these POSIX
builds select the profile for both the executable and its resources:
# Build a minimal Mako executable and mako.zip.
make -C "$BAROOT/examples/MakoServer/make" plat=posix BA_ENABLE_LUA_OPCUA=3 exe
# Build standalone Xedge with full OPC UA and embedded resources.
make -C "$BAROOT/examples/xedge/make" plat=posix io=ezip BA_ENABLE_LUA_OPCUA=1 exe
Keep the normal compiler, platform and linker settings for your SDK. If the SDK already contains the OPC UA release, the makefiles handle the file selection. Continue at 4. Verify the installed pair after building.
2. Assemble the native module
When importing a release, the native files come from the OPC-UA repository
root. In a BAS SDK source tree they live under BAS/xrc/lua/opcua/.
Keep both model sources in the SDK so the build can select either profile.
File |
Role |
|---|---|
|
Compile for both profiles. Implements the reader and the Lua module |
|
Shared headers for the reader, registration entry point and compiled model data. |
|
Compile exactly one. Both define |
BAS amalgamated builds select and include the implementation when compiling BAS with value 1 or 3. In a project that compiles the individual OPC UA sources itself, add the reader and selected model once and make the shared headers and the host’s Lua headers available to the compiler.
Mako and standalone Xedge call luaopen_opcua_ns0_static(L) during Lua
startup for every enabled mode. In a custom host call this entry point
on the initialized lua_State *L before loading the OPC UA application.
With value 2, the application must link the implementation that supplies
that symbol.
3. Assemble the Lua resource archive
The source is lua/opcua/ in the stack checkout and BAS-Resources/src/opcua/
in the BAS resource tree. Preserve paths relative to lua/ under
.lua/ in the archive. For example, lua/opcua/api.lua becomes
.lua/opcua/api.lua so the application can load opcua.api.
Full includes lua/opcua/**/*.lua recursively, including Lua files
directly in lua/opcua/. Minimal selects only the following four
rows. Each * matches within one directory.
Include mask |
Filenames to exclude in that directory |
|---|---|
|
|
|
|
|
None |
|
|
The BAS-Resources builders apply these rules from build/opcua-min.txt.
For a custom build, create the archive from a fresh staging directory so a
switch to minimal also removes full-only modules. When packaging separately,
give the compiler and resource builder the same numeric selector. From
BAS-Resources/build on Linux, for example:
# Package full Lua resources for a standalone Xedge compiled with value 1.
BA_ENABLE_LUA_OPCUA=1 bash Xedge.sh
On Windows, set the environment variable before running Xedge.cmd or
mako.cmd. Deploy the resource archive with the matching executable.
For embedded Xedge resources, rebuild and deploy the image containing the
generated XedgeZip.c.
4. Verify the installed pair
Download check_profile.lua. With the new Mako executable and its matching ZIP installed together, run:
mako check_profile.lua
On standalone Xedge, use a small test application:
Save the same check_profile.lua as
.preloadat the top level of the application ZIP, alongside its.config.Deploy the ZIP in the Xedge IDE and start the application. If its
.configsetsautostartto true, deployment starts it automatically.Read the Xedge trace. Expect
OPC UA profile: minimalfor selector3andOPC UA profile: fullfor selector1.
On either host, the script checks for the Root node and compares a full-only
standard type with the installed subscription service.
A missing opcua_ns0 points to native linkage or registration. A missing
opcua.api points to the resource path or archive. A mismatch means the
selected native model and Lua services disagree.
Finally use Read your first OPC UA variable to check the listener and a client session on Mako. For a device endpoint, How to Connect Third-Party Clients shows how to browse and read from a separate machine.
Using a separate OPC UA source checkout
The OPC-UA Makefile and a Mako development build using OPCUA_ROOT use
the string selector OPCUA_PROFILE. Its accepted values are min and
full, with full as the default. From the OPC-UA checkout:
# Build the minimal native module and stage the selected sources.
make OPCUA_PROFILE=min
# Build a sibling Mako source checkout with that same profile.
make -C ../mako OPCUA_ROOT="$PWD" OPCUA_PROFILE=min mako
In this workflow the Mako shell resource builder leaves OPC UA packaging to
the development build identified by OPCUA_ROOT. The ESP32 development
target in the OPC-UA checkout also accepts OPCUA_PROFILE when OPC UA is
enabled. For a prebuilt Xedge32 image, check the profile supplied by that
firmware.