NATIVE WINDOWS X64 NMEA2000 DLL - 2026-11-06

WHAT CHANGED

Designer now loads nmea2000/yc_n2k.dll through JNI and communicates directly
with the Actisense USB serial gateway inside the Java process. The old 2011
ActisenseComms.dll is not used. The DLL contains native AMD64 machine code;
it does not start a .NET runtime or Yachtcontrol.NmeaBridge.exe. It is built
with the static MSVC runtime, so no separate VC++ redistributable is required.
Windows system DLLs and the adapter's USB driver are still required.

This is a replacement with a new API, not an ABI-compatible recompile of the
2011 wrapper. Install the matching yc_designer.jar and DLL from this update.
Do not copy it into the old navigation program expecting its JNI API to match.

CONNECTION

COM access is exclusive. The native worker probes 115200/230400 baud, accepts
known NGT-1/NGT-OEM/NGX-1 model IDs, requires an acknowledged switch to Transfer
Receive All, and attempts to restore the original mode on disconnect/shutdown.
RX supports BST93 and D0; TX supports BST94 with a maximum 223-byte payload.
Transmit enable acknowledgements are required per PGN. No explicit flash commit
is sent. A SENT count means serial-driver acceptance, not bus-level delivery.

All native worker queues/frame buffers are bounded. Queue losses are included
in Designer's queue-drop count. The worker never calls back into the JVM; Java
polls the event queue. Native I/O uses finite timeouts. Shutdown waits for the
worker and closes its Windows handle; no native thread is forcibly terminated.
An application crash/forced kill or USB fault can prevent mode restoration.

SELECTING A BACKEND

The default is native when the matching DLL loads. A missing/unloadable DLL
falls back to the existing helper, with a diagnostic on stderr. An actual port
or gateway connection failure does not trigger a second connection attempt via
the fallback. The settings connection status identifies the active backend.

Java VM options (place before -jar, or in your launcher's JVM options):
  -Dyc.nmea2000.backend=native    Require the native DLL; fail if unavailable.
  -Dyc.nmea2000.backend=helper    Use the existing colleague-tested helper.
  -Dyc.nmea2000.backend=auto      Default: native, helper if DLL cannot load.

The complete package retains the helper and managed DLL for rollback. Only the
fallback needs .NET Framework 4.8. A native-only deployment needs yc_designer.jar
plus nmea2000/yc_n2k.dll and the usual Designer resources/dependencies.
When launching with Java's -cp option, add --enable-native-access=ALL-UNNAMED.
The packaged executable JAR declares Enable-Native-Access in its manifest.

TESTING WITH A REAL ADAPTER

1. Connect NGT-1. Confirm the status says native x64 DLL, PGN count increases,
   and heading/depth/etc. match the known working helper/demo.
2. Close Designer. Confirm no Yachtcontrol.NmeaBridge.exe was started in native
   mode. Use NMEA Reader to check original mode restoration after disconnect.
3. Put NGX-1 in Convert, close NMEA Reader, connect Designer. Confirm automatic
   Transfer Receive All and real incoming values; disconnect and verify Convert
   is restored. Repeat when already in Transfer Receive All.
4. Try connecting while NMEA Reader owns the COM port; expect a clear busy-port
   error. Close Reader and reconnect. Test unplug/replug and repeated reconnects.
5. Verify a harmless device-info request, then any intended device commands on
   your test network. Compare total process memory and 15-30 minute stability.

LOCAL VERIFICATION

Native protocol/C-ABI tests, full Java compilation, JNI integration with
simulated NGT/NGX gateways, encrypted PGN decoding into the heading data model,
outgoing discovery routing, reconnects, native port enumeration, nonexistent
COM errors, helper fallback integration and settings rendering. Java tests use
-Xcheck:jni. No physical gateway was available for native DLL testing.
Obfuscated packaging has a JNI keep rule but was not executed locally.

BUILD

powershell.exe -NoProfile -ExecutionPolicy Bypass -File tools/nmea2000-native/build.ps1
  Builds/tests just the native DLL into base/nmea2000/yc_n2k.dll.

powershell.exe -NoProfile -ExecutionPolicy Bypass -File tools/nmea2000-bridge/build-designer.ps1
  Builds/tests DLL, fallback and Designer; creates the shareable update ZIP.

Requires Visual Studio 2022 Build Tools, C++ workload/Windows SDK, and the JDK
headers at ../jdk-25/include. Public C ABI is documented in yc_n2k.h; command
and event lines follow the existing bridge contract. DLL API version is 1.
