signalk-nmea2000-emitter-cannon
v1.2.4
Published
Signal K server plugin to convert Signal K to NMEA2000 with Garmin PGN specification alignment and canboatjs framework compatibility
Maintainers
Readme
Signal K NMEA2000 Emitter Cannon
A modern TypeScript Signal K server plugin that converts Signal K data to NMEA 2000 format with enhanced Garmin compatibility.
Built on the foundation of signalk-to-nmea2000
This plugin is a modernized and enhanced version of the original signalk-to-nmea2000 plugin by Scott Bender and the Signal K community. Full credit to the original authors for the excellent foundation and protocol implementation.
Features
- Modern TypeScript: Fully converted to TypeScript 5.9+ with strict type safety
- Broad PGN Coverage: 45 conversion modules supporting 58 NMEA 2000 Parameter Group Numbers
- Signal K Native: Seamless integration with Signal K server ecosystem using official
@signalk/server-api - Garmin Compatibility: Aligned with Garmin PGN specifications and canboatjs framework
- Reactive Processing: Built on RxJS 7.8 for efficient real-time data processing
- High Performance: Modern build system with esbuild for fast compilation (~207kb bundle)
- Fully Tested: Comprehensive test suite with Vitest and CanboatJS validation
- Modern Dependencies: es-toolkit, RxJS 7.8, pure ESM modules
- Latest Tooling: Biome for linting/formatting, zero errors and warnings
- CI/CD Ready: GitHub Actions workflow with multi-version Node.js testing
- Developer Experience: Pre-commit hooks with husky + lint-staged
Installation
Prerequisites
- Node.js 20 or higher
- Signal K server
- A supported NMEA 2000 gateway (e.g., Actisense NGT-1, Yacht Devices YDNR-02) connected to Signal K for messages to reach the NMEA 2000 bus
- npm or compatible package manager
Install via Signal K AppStore
- Open Signal K server admin interface
- Navigate to AppStore
- Search for "signalk-nmea2000-emitter-cannon"
- Click Install
Manual Installation
Option 1: From npm registry
cd ~/.signalk
npm install signalk-nmea2000-emitter-cannonOption 2: Link for development
# Build and link from the source directory
npm run build
cd ~/.signalk
npm link /path/to/signalk-nmea2000-emitter-cannonConfiguration
- Navigate to Server → Plugin Config in Signal K admin interface
- Find "Signal K NMEA2000 Emitter Cannon" in the plugin list
- Enable the plugin
- Configure individual PGN conversions as needed
Configuration Options
Each conversion can be individually enabled and configured:
- Enabled: Toggle individual PGN conversions on/off
- Global Resend Interval (seconds, top-level): How often every enabled conversion re-emits its last value when the source hasn't changed. Many NMEA 2000 displays expect periodic updates.
- Resend (seconds, per-conversion): Overrides the global interval for this conversion when non-zero. Set to 0 to use the global default.
- Source filter: When multiple Signal K sources provide the same data path (e.g., two GPS receivers), enter a source label (e.g.
gps1) to match any$sourcethat starts with that label. Leave blank to accept any source.
Some conversions require instance mapping to match your NMEA 2000 network:
- Battery: Map each Signal K battery ID to an NMEA 2000 battery instance ID
- Engine: Map each Signal K engine ID to an NMEA 2000 engine instance ID
- Tank: Map each Signal K tank path to an NMEA 2000 tank instance ID
- Solar: Map each Signal K solar charger ID to an NMEA 2000 battery instance ID
Supported PGNs (58 PGNs across 45 modules)
All PGNs are aligned with Garmin specifications (corrected priorities, SID fields, field names).
Navigation & Positioning
| PGN | Description | Module |
|--------|-------------|--------|
| 127245 | Rudder Position | rudder.ts |
| 127250 | Vessel Heading / True Heading | heading.ts, trueheading.ts |
| 127251 | Rate of Turn | rateOfTurn.ts |
| 127252 | Heave | heave.ts |
| 127257 | Attitude (pitch, roll, yaw) | attitude.ts |
| 127258 | Magnetic Variance | magneticVariance.ts |
| 128000 | Leeway | leeway.ts |
| 128259 | Speed (water/ground) | speed.ts |
| 128267 | Water Depth | depth.ts |
| 128275 | Distance Log | speed.ts |
| 129025 | Position (lat/lon) | gps.ts |
| 129026 | COG & SOG Rapid Update | cogSOG.ts |
| 129029 | GNSS Position Data | gps.ts |
| 129033 | System Time (Date & Time) | systemTime.ts |
| 129283 | Cross Track Error | navigationData.ts |
| 129284 | Navigation Data (waypoint) | navigationData.ts |
| 129285 | Route/Waypoint Information | routeWaypoint.ts |
| 129291 | Set & Drift | setdrift.ts |
| 129301 | Time to/from Mark | timeToMark.ts |
| 129302 | Bearing & Distance Between Marks | bearingDistanceBetweenMarks.ts |
| 129539 | GNSS DOPs | gnssData.ts |
| 129540 | GNSS Satellites in View | gnssData.ts |
| 130074 | Route WP List | routeWpList.ts |
| 130577 | Direction Data | directionData.ts |
AIS
| PGN | Description | Module |
|--------|-------------|--------|
| 129038 | Class A Position Report | ais.ts |
| 129039 | Class B Position Report | aisExtended.ts |
| 129040 | Class B Extended Position Report | aisExtended.ts |
| 129041 | AtoN (Aids to Navigation) | ais.ts |
| 129794 | Static & Voyage Data | ais.ts |
| 129798 | SAR Aircraft Position | aisExtended.ts |
| 129802 | Safety Related Broadcast | aisExtended.ts |
Engine & Propulsion
| PGN | Description | Module |
|--------|-------------|--------|
| 127488 | Engine Parameters Rapid Update | engineParameters.ts |
| 127489 | Engine Parameters Dynamic | engineParameters.ts |
| 127493 | Transmission Parameters | transmissionParameters.ts |
| 127498 | Engine Configuration/Static | engineStatic.ts |
| 130576 | Small Craft Status | smallCraftStatus.ts |
Environmental
| PGN | Description | Module |
|--------|-------------|--------|
| 130306 | Wind Data (apparent, true ground, true water) | wind.ts, windTrueGround.ts, windTrueWater.ts |
| 130310 | Sea/Air Temperature | seaTemp.ts |
| 130311 | Atmospheric Pressure | pressure.ts |
| 130312 | Temperature (exhaust + general-purpose sources) | engineParameters.ts, temperature.ts |
| 130313 | Humidity (inside/outside) | humidity.ts |
| 130314 | Actual Pressure | pressure.ts |
| 130316 | Temperature, Extended Range | temperature.ts |
Electrical Systems
| PGN | Description | Module |
|--------|-------------|--------|
| 127505 | Fluid/Tank Level | tanks.ts |
| 127506 | DC Detailed Status (state of charge) | battery.ts, solar.ts |
| 127508 | Battery Status (voltage/current) | battery.ts, solar.ts |
Safety & Communications
| PGN | Description | Module |
|--------|-------------|--------|
| 126464 | PGN List (transmit/receive) | pgnList.ts |
| 126983 | Alert Response | notifications.ts |
| 126985 | Alert Text | notifications.ts |
| 126992 | System Time | systemTime.ts |
| 126996 | Product Information | productInfo.ts |
| 129799 | Radio Frequency/Mode/Power | radioFrequency.ts |
| 129808 | DSC Call Information | dscCalls.ts |
Vendor-Specific
| PGN | Description | Module |
|--------|-------------|--------|
| 65288 | Raymarine (Seatalk) Alarms | raymarineAlarms.ts |
| 126720 | Raymarine Display Brightness | raymarineBrightness.ts |
ISO (in PGN list announcement only)
| PGN | Description | |--------|-------------| | 59392 | ISO Acknowledgement | | 59904 | ISO Request | | 60928 | ISO Address Claim |
Development
Prerequisites
- Node.js 20+
- TypeScript 5.9+
- Modern package manager (npm recommended)
Setup
git clone https://github.com/NearlCrews/signalk-nmea2000-emitter-cannon.git
cd signalk-nmea2000-emitter-cannon
npm installBuild Commands
# Development build with watch mode
npm run build:watch
# Production build
npm run build
# Run tests
npm test
# Type checking
npm run typecheck
# Linting
npm run lint
# Format code
npm run formatProject Structure
src/
├── index.ts # Main plugin entry point
├── plugin-manager.ts # Core plugin lifecycle management
├── schema.ts # Configuration schema for Signal K admin UI
├── constants.ts # NMEA 2000 default values (priority, dst, SID)
├── types/ # TypeScript type definitions
│ ├── signalk.ts # Signal K server types (extends @signalk/server-api)
│ ├── nmea2000.ts # NMEA 2000 message types
│ ├── plugin.ts # Plugin-specific types
│ └── index.ts # Type re-exports
├── utils/ # Utility functions
│ ├── pathUtils.ts # Signal K path manipulation
│ ├── messageUtils.ts # NMEA 2000 message utilities
│ ├── dateUtils.ts # Date/time conversions for N2K
│ ├── validation.ts # Input validation (NaN/Infinity checks)
│ └── smoothing.ts # Exponential smoothing for sensor data
├── conversions/ # PGN conversion modules (45 modules)
│ ├── index.ts # Module loader
│ ├── wind.ts # Wind data conversion
│ ├── depth.ts # Depth conversion
│ ├── battery.ts # Battery status conversion
│ └── ... # Additional conversions
└── test/ # Test suites
└── index.test.ts # Main test file
.github/
└── workflows/
└── ci.yml # GitHub Actions CI pipelineAdding New Conversions
- Create
src/conversions/yourConversion.tsusing the factory pattern below - Import and register in
src/conversions/index.ts(add to imports andconversionFactoriesarray) - Add a configuration entry in
src/schema.tswithenabledandresendproperties - Include embedded test cases in the module's
testsarray - Run
npm testandnpm run typecheck
Example conversion module:
import { N2K_BROADCAST_DST, N2K_DEFAULT_PRIORITY } from "../constants.js";
import type { ConversionCallback, ConversionModule, SignalKApp } from "../types/index.js";
export default function createMyConversion(
app: SignalKApp
): ConversionModule<[number | null]> {
return {
title: "My Conversion (12345)",
optionKey: "MY_CONVERSION",
keys: ["path.to.signalk.data"],
callback: ((value: number | null) => {
if (value === null) return [];
return [{
prio: N2K_DEFAULT_PRIORITY,
pgn: 12345,
dst: N2K_BROADCAST_DST,
fields: {
myField: value,
},
}];
}) as ConversionCallback<[number | null]>,
tests: [
{
input: [42],
expected: [{
prio: 2,
pgn: 12345,
dst: 255,
fields: { myField: 42 },
}],
},
],
};
}Technical Details
Architecture
The plugin subscribes to Signal K data paths via RxJS streams. When values change, conversion callbacks transform them into CanboatJS-format N2K messages ({ prio, pgn, dst, fields }) which are emitted to the NMEA 2000 bus. Each conversion module is self-contained with its own Signal K path mappings, conversion logic, and embedded test cases. The plugin manager handles subscription lifecycle, debouncing, data freshness timeouts, and periodic resend timers.
NMEA 2000 Compliance
All output messages follow the exact CanboatJS format requirements:
- Required metadata:
prio,pgn,dst - All data fields nested under
fieldsobject - Field names use camelCase convention
- Proper handling of null/undefined values
Signal K Integration
- Supports all Signal K subscription types
- Handles multiple data sources with source filtering
- Comprehensive timeout handling for data freshness
- Delta message processing for real-time updates
Testing
The plugin includes comprehensive test coverage:
# Run all tests
npm test
# Run tests with UI
npm run test:ui
# Run tests with coverage
npm run test:coverageAll conversion modules include embedded test cases that validate:
- Correct PGN message format
- CanboatJS encoding/decoding compatibility
- Signal K data path mapping
- Edge case handling
Troubleshooting
PGN not appearing on the NMEA 2000 bus
- Check the Signal K server log for plugin errors.
- Confirm the relevant conversion is enabled in the admin UI.
- Confirm Signal K is publishing the source path you expect (verify with the Signal K data browser).
Configuration changes don't take effect
Signal K reloads plugin configuration when you save it, but some changes (for example, schema additions or new conversion modules) require a full Signal K server restart before they appear.
Plugin won't start
- Check the Signal K log for
Signal K NMEA2000 Emitter Cannonerrors. - A common cause is the NMEA 2000 output channel not being initialized — the plugin waits for the
nmea2000OutAvailableevent before emitting messages, so confirm your NMEA 2000 gateway is connected and Signal K has registered an output provider.
AIS appears to not filter own vessel
The plugin uses app.selfId (the Signal K server's self identifier) to filter own-vessel AIS deltas. If selfId isn't set on your Signal K server, AIS conversions are skipped entirely. Verify the server has a self identifier configured (usually the vessel's MMSI in urn form).
No yellow delta-rate bar next to this plugin in the Signal K dashboard
Expected. The yellow bar in the Signal K admin dashboard's Plugins activity section visualizes a plugin's deltaRate — the rate of Signal K deltas it produces into the server via app.handleMessage(pluginId, delta). This plugin is an outbound emitter: it consumes Signal K data and writes NMEA 2000 messages out to the bus. Its activity is correctly reported through a different API (app.reportOutputMessages) and appears as the plain "X msg/s" number to the right of the plugin name. That's the right metric for a plugin of this type; the bar will always be absent unless the NOTIFICATIONS conversion is enabled and actively injecting alerts back into Signal K.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes with proper TypeScript types
- Add tests for new functionality
- Ensure all tests pass and code passes linting
- Submit a pull request
Compatibility
- Signal K Server: 2.20.0+
- Node.js: 20.0.0+
- CanboatJS: 3.13.0+
- @signalk/server-api: 2.10.2+
License
Apache 2.0 License - see LICENSE file for details.
Author
- Nearl Crews - Author, maintainer, and TypeScript conversion
Acknowledgments
This plugin builds upon the excellent foundation of the signalk-to-nmea2000 project:
- Original Author: Scott Bender and the Signal K community
- Original Implementation: signalk-to-nmea2000 - NMEA 2000 conversion framework and PGN implementations
Additional Thanks:
- Signal K Project for the excellent marine data standard
- Canboat Project for NMEA 2000 protocol implementation
- The Signal K community for feedback, testing, and contributions
