To answer my own question: The panel.cfg entry for
htmlgaugeXX = WasmInstrument/WasmInstrument.html?wasm_module=&...
uses a slightly counter-intuitive path for the wasm module. IF the filepath is
a simple filename, then that wasm file can be placed in the same folder as the
panel.cfg (i.e. the aircraft panel folder), i.e. there seems to be a basic
concept of ‘local directory’ being the panel folder and relative paths would
be from that but this is misleading. Otherwise the path to the wasm file will
be evaluated from the root of your package. Because my WASM gauge is actually
adding small additional function to a larger and more complex html/js gauge
(supporting reading aircraft files in the SimObjects folders) it makes sense
for me to co-locate the .html, .css, .js and .wasm components of the gauge,
necessarily in the html_ui branch of the package tree as the html/js requires
that. So this entry works for me in the panel.cfg:
htmlgauge06 = WasmInstrument/WasmInstrument.html?wasm_module=html_ui/Pages/VCockpit/Instruments/AS-33/b21_soaring_engine/b21_soaring_engine.wasm&wasm;_gauge=fcheck,0,0,1,1
Bonus answer: If you’re reading aircraft files with WASM it seems ‘relative’
file access isn’t possible and you access files from the root of the package
tree. This means to find e.g. the aircraft.cfg you need to specify a
SimObjects path with your unique aircraft reference embedded in the filepath.
If this is hardcoded into the WASM then that gauge will not be portable to
other aircraft. Here’s the C++ function I use to automatically generate the
path to the current aircraft folder:
#include
char simobjects_path[1000]; // Aircraft name used in package SimObjects folder
void get_package_refs() {
strcpy(simobjects_path, "\\SimObjects\\Airplanes\\");
struct dirent* entry;
DIR* dir = opendir(simobjects_path);
if (dir == NULL) {
fprintf(stderr, "B21 fcheck Airplanes folder not found");
return;
}
while ((entry = readdir(dir)) != NULL) {
fprintf(stderr, "B21 fcheck Airplanes\\%s\n", entry->d_name);
if (entry->d_name[0] != '.') {
strcat(simobjects_path, entry->d_name);
strcat(simobjects_path, "\\");
break;
}
}
closedir(dir);
fprintf(stderr, "B21 fcheck SimObjects path is '%s'", simobjects_path);
}
For my aircraft this function “get_package_refs” will return with:
simobjects_path = "\SimObjects\Airplanes\AS-33\";
So I can easily create a path to e.g. the “aircraft.cfg” file and my wasm code
is portable. In my real code I also calculate the similar path into the
html_ui Instruments tree. The function assumes both the “Airplanes” and the
“Instruments” directories only contain one entry.