A node.js/JavaScript parser of NMEA0183 sentences. Sentences are parsed to Signal K delta format.
- ALK - Seatalk
- APB - Autopilot Sentence "B"
- BOD - Bearing Origin to Destination
- BWC - Bearing & distance - great circle
- BWR - Bearing & distance - rhumbline
- BVE - CruzPro Proprietary Sentence (currently only OP30/60 supported)
- DBT - Depth Below Transducer
- DBS - Depth Below Surface
- DBK - Depth Below Keel
- DPT - Depth of Water
- DSC - Digital Selective Calling Class-D Radios
- GGA - Global Positioning System Fix Data
- GLL - Geographic Position - Latitude/Longitude
- HDG - Heading - Deviation & Variation
- HDM - Heading - Magnetic
- HDT - Heading - True
- HSC - Heading Steering Command
- KEP - NKE Performance data
- MDA - Meteorological Composite
- MTA - Mean Temperature of Air
- MTW - Mean Temperature of Water
- MWD - Wind Speed and Direction
- MWV - Wind Speed and Angle
- RMB - Recommended Minimum Navigation Information
- RMC - Recommended Minimum Navigation Information
- ROT - Rate of Turn
- RPM - Revolutions
- RSA - Rudder Sensor Angle
- VDM - AIS Other Vessel Data
- VDO - AIS Own Vessel Data
- VDR - Set and Drift
- VHW - Water Speed and Heading
- VLW - Distance Traveled through Water
- VPW - Speed - Measured Parallel to Wind
- VTG - Track Made Good and Ground Speed
- VWR - Relative Wind Speed and Angle
- VWT - True Wind Angle and Speed
- ZDA - UTC day, month, and year, and local time zone offset
- XTE - Cross-track Error
- ZDA - UTC day, month, and year, and local time zone offset
Note: at this time, unknown sentences will be silently discarded.
const Parser = require('@signalk/nmea0183-signalk')
const parser = new Parser()
try {
const delta = parser.parse('$SDDBT,17.0,f,5.1,M,2.8,F*3E')
if (delta !== null) {
console.log(`[delta] ${JSON.stringify(delta, null, 2)}`)
}
}
catch (e) {
console.error(`[error] ${e.message}`)
}
In addition to usage in your code, the parser can be used on the command-line if installed globally (npm install --global
). This allows you to pipe data from one program into the parser directly, without using a Signal K server. The parser holds no Signal K tree in memory (a big change vs. 1.x), so the output will be stringified Signal K delta messages.
$ echo '$SDDBT,17.0,f,5.1,M,2.8,F*3E' | nmea0183-signalk
This parser has (limited) support of NMEA0183v4 tag blocks (e.g. \s:airmar dst800,c:1438489697*13\$SDDBT,17.0,f,5.1,M,2.8,F*3E
).
Keep in mind that, since NMEA uses the backslash \
as the start and end character of the tag block, you need to escape these characters before parsing them.
This is necessary because javascript treats the backslash as the escape character causing it not to be included in the resulting string (unless escaped).
Example:
const Parser = require('@signalk/nmea0183-signalk')
const parser = new Parser()
try {
const delta = parser.parse('\\s:airmar dst800,c:1438489697*13\\$SDDBT,17.0,f,5.1,M,2.8,F*3E')
if (delta !== null) {
console.log(`[delta] ${JSON.stringify(delta, null, 2)}`)
}
}
catch (e) {
console.error(`[error] ${e.message}`)
}
Output:
[delta] {
"updates": [
{
"source": {
"sentence": "DBT",
"talker": "airmar dst800",
"type": "NMEA0183"
},
"timestamp": "2015-08-02T04:28:17.000Z",
"values": [
{
"path": "environment.depth.belowTransducer",
"value": 5.1
}
]
}
]
}
Note: at this time, the checksum of the tag block (c:1438489697*13
) is not validated.
Copyright 2016/2017 Signal K and Fabian Tollenaar <fabian@signalk.org>.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.