@canboat/canboatjs 3.5.3 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.mocharc.js CHANGED
@@ -1,7 +1,6 @@
1
1
  module.exports = {
2
- require: ['ts-node/register'],
3
- extensions: ['ts', 'tsx', 'js'],
4
- timeout: 20000,
2
+ extensions: ['ts', 'js'],
3
+ timeout: 2000,
5
4
  exit: true,
6
5
  recursive: true
7
6
  }
package/README.md CHANGED
@@ -1,52 +1,635 @@
1
- # Canboatjs
1
+ # @canboat/canboatjs
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@canboat/canboatjs.svg)](https://www.npmjs.com/@canboat/canboatjs)
4
4
  [![Node.js CI & Test](https://github.com/canboat/canboatjs/actions/workflows/test.yml/badge.svg)](https://github.com/canboat/canboatjs/actions/workflows/test.yml)
5
5
  [![Test Canboat json Changes](https://github.com/canboat/canboatjs/actions/workflows/test_canboat_changes.yml/badge.svg)](https://github.com/canboat/canboatjs/actions/workflows/test_canboat_changes.yml)
6
6
  [![Test canboatjs dependents](https://github.com/canboat/canboatjs/actions/workflows/test_canboatjs_dependencies.yml/badge.svg)](https://github.com/canboat/canboatjs/actions/workflows/test_canboatjs_dependencies.yml)
7
7
 
8
- Pure javascript NMEA 2000 decoder and encoder
8
+ A TypeScript library for parsing, encoding, and interfacing with NMEA 2000 marine electronics networks. It used the PGN definition database from [canboat](https://github.com/canboat/canboat) with extensive device support, multiple data format compatibility, and PGN output.
9
9
 
10
- Canboatjs is a port of the canboat project (https://github.com/canboat/canboat) to javascript
10
+ ## Table of Contents
11
11
 
12
- # Features
12
+ - [Features](#features)
13
+ - [Architecture](#architecture)
14
+ - [Installation](#installation)
15
+ - [Quick Start](#quick-start)
16
+ - [Supported Devices](#supported-devices)
17
+ - [Command Line Tools](#command-line-tools)
18
+ - [API Reference](#api-reference)
19
+ - [Usage Examples](#usage-examples)
20
+ - [Device Integration](#device-integration)
21
+ - [Data Formats](#data-formats)
22
+ - [Contributing](#contributing)
23
+ - [License](#license)
13
24
 
14
- - Reads directly from CAN bus devices and NMEA 2000 gateways including:
15
- - Actisense NGT-1 and W2K-1
16
- - Digital Yacht iKonvert
17
- - Yacht Devices YDWG-02 and YDEN-02
18
- - Shipmodul MiniPlex-3-N2K
19
- - socketcan based devices
20
- - Parses input in canboat analyzer json format
21
- - Converts and outputs binary N2K format to supported devices
25
+ ## Features
22
26
 
23
- # PGN Descriptions
27
+ - **🔌 Multi-Device Support**: Direct interface with popular NMEA 2000 gateways and CAN bus devices
28
+ - **📡 Multiple Data Formats**: Parse and generate various N2K data formats (Actisense, iKonvert, YDWG, etc.)
29
+ - **🔄 Bidirectional**: Both decode incoming N2K messages and encode/transmit outgoing messages
30
+ - **🛠️ Command Line Tools**: Ready-to-use CLI utilities for data conversion and analysis
31
+ - **🎯 Type Safety**: Built with TypeScript and includes type definitions
32
+ - **📊 JSON Output**: Standardized JSON format compatible with Signal K and other marine data systems
24
33
 
25
- The details about the PGNs recognized by Canboatjs come from the canboat project in [canboat.json](https://github.com/canboat/canboat/blob/master/docs/canboat.json). If you want to add or update PGN details, please make changes to the [pgn.h file](https://github.com/canboat/canboat/blob/master/analyzer/pgn.h) in canboat and submit a pull request there. Include sample data and raise an issue here so that I can include your changes in Canboatjs.
34
+ ## Architecture
26
35
 
27
- # Command Line Programs
36
+ For an overview of how canboatjs integrates with signalk-server to create a complete marine data processing pipeline, see the [Architecture Diagram](./architecture-diagram.md).
28
37
 
29
- ## analyzerjs
38
+ The diagram illustrates:
39
+ - **Data Flow**: From NMEA 2000 hardware through parsing and conversion to Signal K format
40
+ - **Device Support**: Various hardware interfaces and data formats
41
+ - **Bidirectional Processing**: Both incoming data parsing and outgoing data generation
42
+ - **Integration Points**: How canboatjs works with other components in the marine data ecosystem
30
43
 
31
- This program is similar to the canboat `analyzer` command-line. It takes input in the actisense serial format and outputs canboat json for mat.
44
+ ## Installation
45
+
46
+ ### For Command Line Usage
47
+
48
+ ```bash
49
+ sudo npm install -g @canboat/canboatjs
50
+ ```
51
+
52
+ ### For Node.js Projects
53
+
54
+ ```bash
55
+ npm install @canboat/canboatjs
56
+ ```
57
+
58
+ ### Requirements
59
+
60
+ - **Node.js**: Version 20 or higher
61
+ - **Optional Dependencies**:
62
+ - `serialport`: For serial device communication
63
+ - `socketcan`: For direct CAN bus access on Linux
64
+
65
+ ## Quick Start
66
+
67
+ ### Basic Message Parsing
68
+
69
+ ```javascript
70
+ const { FromPgn } = require('@canboat/canboatjs')
71
+
72
+ // Create parser instance
73
+ const parser = new FromPgn()
74
+
75
+ // Handle warnings
76
+ parser.on('warning', (pgn, warning) => {
77
+ console.log(`[WARNING] PGN ${pgn.pgn}: ${warning}`)
78
+ })
79
+
80
+ // Parse an Actisense format message
81
+ const message = "2017-03-13T01:00:00.146Z,2,127245,204,255,8,fc,f8,ff,7f,ff,7f,ff,ff"
82
+ const json = parser.parseString(message)
83
+
84
+ if (json) {
85
+ console.log('Parsed PGN:', JSON.stringify(json, null, 2))
86
+ }
87
+ ```
88
+
89
+ ### Generate N2K Messages
90
+
91
+ ```javascript
92
+ const { pgnToActisenseSerialFormat } = require('@canboat/canboatjs')
93
+
94
+ // Create a rudder position message
95
+ const message = {
96
+ pgn: 127245,
97
+ prio: 2,
98
+ src: 204,
99
+ dst: 255,
100
+ fields: {
101
+ 'Instance': 252,
102
+ 'Direction Order': 0,
103
+ 'Reserved1': '62'
104
+ }
105
+ }
106
+
107
+ const actisenseString = pgnToActisenseSerialFormat(message)
108
+ console.log('Generated:', actisenseString)
109
+ ```
110
+
111
+ ## Supported Devices
112
+
113
+ ### NMEA 2000 Gateways
114
+ - **Actisense NGT-1** & **W2K-1** - USB and WiFi NMEA 2000 gateways
115
+ - **Digital Yacht iKonvert** - Serial to NMEA 2000 converter
116
+ - **Yacht Devices YDWG-02** & **YDEN-02** - WiFi and Ethernet gateways
117
+ - **Shipmodul MiniPlex-3-N2K** - Multi-protocol marine data multiplexer
118
+
119
+ ### CAN Bus Interfaces
120
+ - **SocketCAN devices** - Direct Linux CAN bus interface
121
+ - **Various CAN adapters** - Hardware CAN interfaces compatible with SocketCAN
122
+
123
+ ### Supported Data Formats
124
+ - **Actisense Serial Format** - Standard Actisense ASCII format
125
+ - **iKonvert Format** - Digital Yacht proprietary format
126
+ - **YDWG Raw Format** - Yacht Devices raw binary format
127
+ - **PCDIN Format** - Chetco Digital Instruments format
128
+ - **MXPGN Format** - MiniPlex-3 format
129
+ - **SocketCAN** - Linux CAN bus native format
130
+
131
+ ## Command Line Tools
132
+
133
+ Canboatjs includes several powerful command-line utilities:
134
+
135
+ ### `analyzerjs` - Message Analysis
136
+ Convert various N2K formats to standardized JSON:
137
+
138
+ ```bash
139
+ # From Actisense NGT-1
140
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs
141
+
142
+ # From iKonvert
143
+ ikonvert-serial /dev/ttyUSB0 | analyzerjs
144
+
145
+ # From YDWG-02 over network
146
+ nc ydgw-ip 1475 | analyzerjs
147
+
148
+ # From W2K-1 WiFi gateway
149
+ nc w2k-1-ip 60002 | analyzerjs
150
+
151
+ # From SocketCAN
152
+ candumpjs can0
153
+
154
+ # Filter by specific PGN numbers
155
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 # Position updates only
156
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 127245 # Rudder data only
157
+
158
+ # Filter by multiple PGNs
159
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 --pgn 127245 --pgn 129029
160
+
161
+ # Filter by source address (device that sent the message)
162
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --src 15 # From device address 15
163
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --src 127 # From device address 127
164
+
165
+ # Filter by destination address
166
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --dst 255 # Broadcast messages only
167
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --dst 204 # Messages to device 204
168
+
169
+ # Filter by manufacturer
170
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --manufacturer "Garmin"
171
+
172
+ # Combine multiple filters
173
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 --src 15 --dst 255
174
+
175
+ # Filter using a JavaScript expression
176
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 --filter "pgn.fields.proprietaryId === 'Pilot Configuration'"
177
+
178
+ # Pretty print JSON output
179
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 --pretty
180
+
181
+ # Pretty print using JavaScript output with colors
182
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 --js-colors
183
+
184
+ # Process log files with filtering
185
+ analyzerjs --file my_log.txt --pgn 129025 --pgn 127245 --src 15
186
+ ```
187
+
188
+ ### `to-pgn` - Message Generation
189
+ Convert JSON to various N2K formats:
190
+
191
+ ```bash
192
+ echo '{"pgn":127245,"fields":{"Instance":0}}' | to-pgn --format=actisense
193
+ ```
194
+
195
+ ### `candumpjs` - Direct CAN Access
196
+ Read from SocketCAN without installing can-utils:
197
+
198
+ ```bash
199
+ # Basic CAN bus monitoring
200
+ candumpjs can0
201
+
202
+ # Filter by specific PGN numbers
203
+ candumpjs can0 --pgn 129025 # Position updates only
204
+ candumpjs can0 --pgn 127245 # Rudder data only
205
+
206
+ # Filter by multiple PGNs
207
+ candumpjs can0 --pgn 129025 --pgn 127245 --pgn 129029
208
+
209
+ # Filter by source address (device that sent the message)
210
+ candumpjs can0 --src 15 # From device address 15
211
+ candumpjs can0 --src 127 # From device address 127
212
+
213
+ # Filter by destination address
214
+ candumpjs can0 --dst 255 # Broadcast messages only
215
+ candumpjs can0 --dst 204 # Messages to device 204
216
+
217
+ # Filter by manufacturer
218
+ candumpjs can0 --manufacturer "Garmin"
219
+
220
+ # Combine multiple filters
221
+ candumpjs can0 --pgn 129025 --src 15 --dst 255
222
+
223
+ # Output in Actisense format instead of JSON
224
+ candumpjs can0 --format actisense
225
+
226
+ # Pretty print JSON with filtering
227
+ candumpjs can0 --pgn 129025 --pretty
228
+
229
+ # Common PGN filters for navigation data
230
+ candumpjs can0 --pgn 129025 --pgn 129026 --pgn 129029 # GPS position data
231
+ candumpjs can0 --pgn 127245 --pgn 127250 # Rudder and heading
232
+ candumpjs can0 --pgn 128267 --pgn 128259 # Depth and speed
233
+ ```
234
+
235
+ ### `ydvr-file` - YDVR File Processing
236
+ Process Yacht Devices recorder files:
237
+
238
+ ```bash
239
+ ydvr-file recording.ydvr | analyzerjs
240
+ ```
241
+
242
+ ### Additional Tools
243
+ - `actisense-file` - Process Actisense log files
244
+ - `actisense-n2k-tcp` - TCP server for Actisense data
245
+ - `cansend` - Send CAN messages
246
+ - `ikonvert-serial` - iKonvert serial interface
247
+
248
+ ### Message Filtering
249
+
250
+ Both `analyzerjs` and `candumpjs` support powerful filtering options to focus on specific data:
251
+
252
+ #### PGN Filtering
253
+ Filter by Parameter Group Number to see only specific message types:
254
+
255
+ ```bash
256
+ # Navigation data
257
+ --pgn 129025 # Position, Rapid Update
258
+ --pgn 129026 # COG & SOG, Rapid Update
259
+ --pgn 129029 # GNSS Position Data
260
+ --pgn 127250 # Vessel Heading
261
+
262
+ # Engine data
263
+ --pgn 127488 # Engine Parameters, Rapid Update
264
+ --pgn 127489 # Engine Parameters, Dynamic
265
+
266
+ # Environmental data
267
+ --pgn 128267 # Water Depth
268
+ --pgn 128259 # Speed
269
+ --pgn 130311 # Environmental Parameters
270
+
271
+ # Multiple PGNs
272
+ --pgn 129025 --pgn 129026 --pgn 127250
273
+ ```
274
+
275
+ #### Source and Destination Filtering
276
+ Filter by device addresses to monitor specific devices or message types:
277
+
278
+ ```bash
279
+ # Source address filtering (device that sent the message)
280
+ --src 15 # Messages from device address 15 (often a chartplotter)
281
+ --src 127 # Messages from device address 127 (often a GPS)
282
+ --src 204 # Messages from device address 204 (often an autopilot)
283
+
284
+ # Destination address filtering
285
+ --dst 255 # Broadcast messages (most common)
286
+ --dst 204 # Directed messages to device 204
287
+ --dst 15 # Directed messages to device 15
288
+
289
+ # Multiple source/destination addresses
290
+ --src 15 --src 127 --dst 255
291
+ ```
292
+
293
+ #### Manufacturer Filtering
294
+ Filter by device manufacturer:
295
+
296
+ ```bash
297
+ --manufacturer "Garmin"
298
+ --manufacturer "Raymarine"
299
+ --manufacturer "Simrad"
300
+ --manufacturer "Furuno"
301
+ ```
302
+
303
+ #### Practical Examples
304
+
305
+ ```bash
306
+ # Monitor only GPS position data from all devices
307
+ candumpjs can0 --pgn 129025 --pgn 129029
308
+
309
+ # Watch rudder and autopilot commands
310
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 127245 --pgn 127237
311
+
312
+ # Filter Garmin devices only
313
+ nc chartplotter-ip 1475 | analyzerjs --manufacturer "Garmin"
314
+
315
+ # Monitor messages from chartplotter (address 15) to autopilot (address 204)
316
+ candumpjs can0 --src 15 --dst 204
317
+
318
+ # Watch GPS data from specific device
319
+ actisense-serialjs /dev/ttyUSB0 | analyzerjs --pgn 129025 --src 127
320
+
321
+ # Monitor all broadcast navigation messages
322
+ candumpjs can0 --pgn 129025 --pgn 129026 --pgn 127250 --dst 255
323
+
324
+ # Combine filters for specific Garmin GPS data
325
+ candumpjs can0 --pgn 129025 --manufacturer "Garmin" --pretty
326
+
327
+ # Debug communication between specific devices
328
+ analyzerjs --file network_log.txt --src 15 --dst 204 --pretty
329
+ ```
330
+
331
+ #### Common PGN Reference
332
+
333
+ | PGN | Description | Use Case |
334
+ |-----|-------------|----------|
335
+ | **129025** | Position, Rapid Update | GPS lat/lon monitoring |
336
+ | **129026** | COG & SOG, Rapid Update | Course and speed tracking |
337
+ | **129029** | GNSS Position Data | Detailed GPS information |
338
+ | **127250** | Vessel Heading | Compass/heading data |
339
+ | **127245** | Rudder | Steering position |
340
+ | **127237** | Heading/Track Control | Autopilot commands |
341
+ | **128267** | Water Depth | Depth sounder data |
342
+ | **128259** | Speed | Speed through water |
343
+ | **127488** | Engine Parameters, Rapid | RPM, temperature |
344
+ | **130311** | Environmental Parameters | Air/water temperature |
345
+
346
+ #### Understanding Source and Destination
347
+
348
+ NMEA 2000 messages include source (src) and destination (dst) address fields:
349
+
350
+ - **Source (src)**: Address of the device sending the message (0-251)
351
+ - **Destination (dst)**: Target device address, or 255 for broadcast
352
+
353
+ Both `analyzerjs` and `candumpjs` support filtering by these address fields using `--src` and `--dst` options. Common device addresses:
354
+
355
+ - **15**: Often a chartplotter/display
356
+ - **127**: Often a GPS receiver
357
+ - **204**: Often an autopilot
358
+ - **255**: Broadcast to all devices (most common for dst)
32
359
 
33
360
  Examples:
361
+ ```bash
362
+ # Filter messages from GPS receiver
363
+ analyzerjs --src 127
364
+
365
+ # Filter only broadcast messages
366
+ candumpjs can0 --dst 255
367
+
368
+ # Monitor autopilot commands (directed messages to address 204)
369
+ analyzerjs --dst 204 --pgn 127237
370
+ ```
371
+
372
+ ## API Reference
373
+
374
+ ### Core Classes
375
+
376
+ #### `FromPgn` - Message Parser
377
+ ```javascript
378
+ const parser = new FromPgn(options)
379
+ parser.parseString(message) // Parse single message
380
+ parser.parse(buffer) // Parse binary data
381
+ ```
382
+
383
+ #### `canbus` - CAN Bus Interface
384
+ ```javascript
385
+ const canbus = new canbus(options)
386
+ canbus.sendPGN(message) // Send N2K message
387
+ ```
388
+
389
+ #### Device-Specific Streams
390
+ - `Ydwg02` - Yacht Devices YDWG-02 interface
391
+ - `W2k01` - Actisense W2K-1 interface
392
+ - `iKonvert` - Digital Yacht iKonvert interface
393
+ - `Venus` - Victron Venus OS interface
394
+ - `serial` - Actisense NGT-1 serial interface
395
+
396
+ ### Utility Functions
397
+
398
+ ```javascript
399
+ const {
400
+ parseN2kString, // Parse N2K string formats
401
+ isN2KString, // Detect N2K string format
402
+ toActisenseSerialFormat, // Convert to Actisense format
403
+ pgnToActisenseSerialFormat,
404
+ pgnToiKonvertSerialFormat,
405
+ pgnToYdgwRawFormat,
406
+ lookupEnumerationValue, // Get enumeration values
407
+ lookupEnumerationName, // Get enumeration names
408
+ discover // Network device discovery
409
+ } = require('@canboat/canboatjs')
410
+ ```
411
+
412
+ ## Usage Examples
413
+
414
+ ### Data Streaming
415
+
416
+ ```javascript
417
+ const { FromPgn, serial } = require('@canboat/canboatjs')
418
+
419
+ // Connect to Actisense NGT-1
420
+ const actisense = new serial({
421
+ device: '/dev/ttyUSB0',
422
+ baudrate: 115200
423
+ })
424
+
425
+ const parser = new FromPgn()
426
+
427
+ actisense.pipe(parser)
428
+
429
+ parser.on('pgn', (pgn) => {
430
+ if (pgn.pgn === 129025) { // Position Rapid Update
431
+ console.log(`Lat: ${pgn.fields.Latitude}, Lon: ${pgn.fields.Longitude}`)
432
+ }
433
+ })
434
+ ```
435
+
436
+ ### Device Discovery
437
+
438
+ ```javascript
439
+ const { discover } = require('@canboat/canboatjs')
440
+
441
+ // Discover NMEA 2000 devices on network
442
+ discover((device) => {
443
+ console.log(`Found device: ${device.name} at ${device.address}:${device.port}`)
444
+ })
445
+ ```
446
+
447
+ ### Working with Multiple Formats
448
+
449
+ ```javascript
450
+ const { FromPgn } = require('@canboat/canboatjs')
451
+ const parser = new FromPgn()
452
+
453
+ // Actisense format
454
+ const actisense = "2017-03-13T01:00:00.146Z,2,127245,204,255,8,fc,f8,ff,7f,ff,7f,ff,ff"
455
+
456
+ // YDWG-02 format
457
+ const ydwg = "16:29:27.082 R 09F8017F 50 C3 B8 13 47 D8 2B C6"
458
+
459
+ // MiniPlex-3 format
460
+ const miniplex = "$MXPGN,01F801,2801,C1308AC40C5DE343*19"
461
+
462
+ // All parse to same JSON structure
463
+ [actisense, ydwg, miniplex].forEach(message => {
464
+ const json = parser.parseString(message)
465
+ if (json) {
466
+ console.log(`PGN ${json.pgn}: ${json.description}`)
467
+ }
468
+ })
469
+ ```
470
+
471
+ ### Custom Device Integration
472
+
473
+ ```javascript
474
+ const { SimpleCan } = require('@canboat/canboatjs')
475
+
476
+ // Create virtual N2K device
477
+ const device = new SimpleCan({
478
+ canDevice: 'can0',
479
+ preferredAddress: 35,
480
+ addressClaim: {
481
+ "Unique Number": 139725,
482
+ "Manufacturer Code": 'My Company',
483
+ "Device Function": 130,
484
+ "Device Class": 'Navigation',
485
+ "Device Instance Lower": 0,
486
+ "Device Instance Upper": 0,
487
+ "System Instance": 0,
488
+ "Industry Group": 'Marine'
489
+ },
490
+ productInfo: {
491
+ "NMEA 2000 Version": 1300,
492
+ "Product Code": 667,
493
+ "Model ID": "MyDevice-1000",
494
+ "Software Version Code": "1.0",
495
+ "Model Version": "1.0",
496
+ "Model Serial Code": "123456"
497
+ }
498
+ }, (message) => {
499
+ // Handle incoming messages
500
+ console.log('Received:', message)
501
+ })
502
+
503
+ device.start()
504
+ ```
505
+
506
+ ## Data Formats
507
+
508
+ ### Input Format Support
509
+
510
+ | Format | Description | Example |
511
+ |--------|-------------|---------|
512
+ | **Actisense** | Standard timestamped CSV | `2017-03-13T01:00:00.146Z,2,127245,204,255,8,fc,f8,ff,7f,ff,7f,ff,ff` |
513
+ | **Actisense N2K ASCII** | Actisense ASCII format | `A764027.880 CCF52 1F10D FC10FF7FFF7FFFFF` |
514
+ | **YDWG Raw** | Yacht Devices binary | `16:29:27.082 R 09F8017F 50 C3 B8 13 47 D8 2B C6` |
515
+ | **iKonvert** | Digital Yacht base64 | `!PDGY,127245,255,/Pj/f/9///8=` |
516
+ | **PCDIN** | Chetco Digital | `$PCDIN,01F119,00000000,0F,2AAF00D1067414FF*59` |
517
+ | **MXPGN** | MiniPlex-3 | `$MXPGN,01F801,2801,C1308AC40C5DE343*19` |
518
+ | **candump1** | Linux CAN utils (Angstrom) | `<0x18eeff01> [8] 05 a0 be 1c 00 a0 a0 c0` |
519
+ | **candump2** | Linux CAN utils (Debian) | `can0 09F8027F [8] 00 FC FF FF 00 00 FF FF` |
520
+ | **candump3** | Linux CAN utils (log) | `(1502979132.106111) slcan0 09F50374#000A00FFFF00FFFF` |
521
+
522
+ ### Output Format Support
523
+
524
+ Generate data in any supported format from JSON:
525
+
526
+ ```javascript
527
+ const message = { pgn: 127245, fields: { Instance: 0 } }
528
+
529
+ // Convert to different formats
530
+ const actisense = pgnToActisenseSerialFormat(message)
531
+ const ikonvert = pgnToiKonvertSerialFormat(message)
532
+ const ydwg = pgnToYdgwRawFormat(message)
533
+ const pcdin = pgnToPCDIN(message)
534
+ const mxpgn = pgnToMXPGN(message)
535
+ ```
536
+
537
+ ## Building from Source
538
+
539
+ ```bash
540
+ # Clone repository
541
+ git clone https://github.com/canboat/canboatjs.git
542
+ cd canboatjs
543
+
544
+ # Install dependencies
545
+ npm install
546
+
547
+ # Build TypeScript
548
+ npm run build
549
+
550
+ # Run tests
551
+ npm test
552
+
553
+ # Run with coverage
554
+ npm run code-coverage
555
+
556
+ # Lint and format
557
+ npm run format
558
+ ```
559
+
560
+ ## Testing
561
+
562
+ ```bash
563
+ # Run all tests
564
+ npm test
565
+
566
+ # Run with file watching
567
+ npm run dev-test
568
+
569
+ # Generate coverage report
570
+ npm run code-coverage
571
+ ```
572
+
573
+ ## PGN Definitions
574
+
575
+ The PGN (Parameter Group Number) definitions used by canboatjs come from the [canboat project](https://github.com/canboat/canboat) via [canboat.json](https://github.com/canboat/canboat/blob/master/docs/canboat.json).
576
+
577
+ ### Adding New PGNs
578
+
579
+ To add or update PGN definitions:
580
+
581
+ 1. **Submit changes to canboat**: Modify [pgn.h](https://github.com/canboat/canboat/blob/master/analyzer/pgn.h) in the upstream canboat project
582
+ 2. **Include sample data**: Provide real-world message examples
583
+ 3. **Create issue here**: Let us know about the changes so we can update canboatjs
584
+
585
+ This ensures consistency across the entire canboat ecosystem.
586
+
587
+ ## Contributing
588
+
589
+ We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
590
+
591
+ ### Development Workflow
592
+
593
+ 1. Fork the repository
594
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
595
+ 3. Make your changes with tests
596
+ 4. Run the test suite: `npm test`
597
+ 5. Run formating and linting: `npm run format`
598
+ 6. Commit following [Angular conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits)
599
+ 7. Submit a Pull Request
600
+
601
+ ### Commit Message Format
602
+
603
+ Use the format: `<type>: <description>`
604
+
605
+ - **feat**: New feature
606
+ - **fix**: Bug fix
607
+ - **docs**: Documentation changes
608
+ - **style**: Code formatting
609
+ - **refactor**: Code restructuring
610
+ - **test**: Adding tests
611
+ - **chore**: Maintenance tasks
612
+
613
+ ## License
614
+
615
+ Licensed under the Apache License, Version 2.0. See [LICENSE.md](LICENSE.md) for details.
34
616
 
35
- - `actisense-serialjs /dev/ttyUSB0 | analyzerjs`
36
- - `ikonvert-serial /dev/ttyUSB0 | analyzerjs`
37
- - `nc ydgw 1475 | analyzerjs`
38
- - `nc w2k-1 6002 | analyzerjs` // port should be N2K ACSCII format server on a w2k-1
39
- - `candump can0 | analyzerjs`
617
+ ## Related Projects
40
618
 
41
- ## to-pgn
619
+ - **[@canboat/ts-pgns](https://github.com/canboat/ts-pgns)** - TypeScript PGN definitions
620
+ - **[canboat](https://github.com/canboat/canboat)** - Original C implementation
621
+ - **[Signal K](https://signalk.org/)** - Modern marine data standard
622
+ - **[Signal K Server](https://github.com/SignalK/signalk-server-node)** - Signal K server implementation
42
623
 
43
- This program takes input in the canboat json format and outputs actisense serial format.
624
+ ## Support
44
625
 
45
- ## candumpjs
626
+ - **Issues**: [GitHub Issues](https://github.com/canboat/canboatjs/issues)
627
+ - **Discussions**: [GitHub Discussions](https://github.com/canboat/canboatjs/discussions)
628
+ - **Signal K Community**: [Community](https://signalk.org/community/)
46
629
 
47
- Read directly from a socketcan device without the need to install can-utils
630
+ ---
48
631
 
49
- Example: `candumpjs can0`
632
+ Made with ⚓ by the Canboat project contributors
50
633
 
51
634
  ## ydvr-file
52
635