Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: clarify backslash espace #191

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ $ echo '$SDDBT,17.0,f,5.1,M,2.8,F*3E' | nmea0183-signalk
## NMEA0183v4 tag blocks

This parser has (limited) support of [NMEA0183v4 tag blocks](http://www.nmea.org/Assets/may%2009%20rtcm%200183_v400.pdf) (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:

Expand All @@ -87,6 +85,7 @@ const Parser = require('@signalk/nmea0183-signalk')
const parser = new Parser()

try {
// backslash starts an escape sequence in JavaScript code, so they need to be double in string literals
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)}`)
Expand Down