nmeasim::core::nmea0183¶
namespace nmeasim::core::nmea0183 · Library API
NMEA 0183 sentences: framing and checksums, field formatting, the sentence catalogue, the encoders, the decoder and TAG blocks.
Part of the core library. It follows NMEA 0183 (IEC 61162-1) for sentences and IEC 61162-450 for TAG blocks. SentenceRegistry lists every sentence the simulator can emit with the encoder that writes it from a model::VesselState through SentenceBuilder; parse_sentence and apply_sentence read sentences back into a state, for example while a log is replayed.
Types¶
| Type | Description |
|---|---|
CoordinateField |
A latitude or longitude formatted for two consecutive NMEA 0183 fields: the value and the hemisphere letter. |
DateParts |
The UTC calendar date split into its components, as sent in ZDA. |
EncoderContext |
Everything an encoder needs to produce its sentences for one emission. |
EncoderOptions |
Options that change how an encoder formats its fields. |
ParsedSentence |
A sentence split into its start delimiter, address and data fields. |
SentenceBuilder |
Builder for one sentence: the address, then fields appended in order and separated by commas. |
SentenceDescriptor |
Static description of one sentence: its identity, its defaults and the encoder that produces it. |
SentenceRegistry |
Immutable list of sentence descriptors; the only instance is standard. |
SentenceTime |
A UTC time carried by a sentence, with the date when the sentence carries one. |
TagBlockOptions |
What the TAG block in front of each sentence of an output contains. |
Summary¶
Type aliases
| Name | Description |
|---|---|
Encoder |
Pointer to an encoder function, the signature every encoder shares; stored in SentenceDescriptor::encoder. |
Enumerations
| Name | Description |
|---|---|
SentenceGroup |
Functional group a sentence belongs to. |
Functions
| Name | Description |
|---|---|
compute_checksum() |
Computes the NMEA 0183 checksum of body: the XOR of all its bytes. |
format_checksum() |
Formats a checksum as exactly two upper-case hexadecimal digits. |
append_checksum() |
Appends *hh to a sentence that has no checksum yet. |
verify_checksum() |
Checks the framing and the checksum of a received sentence. |
parse_sentence() |
Splits a sentence into its start delimiter, address and data fields. |
sentence_time() |
Returns the UTC time a sentence carries, when it carries a valid one. |
apply_sentence() |
Applies the values carried by a parametric sentence to a vessel state. |
apply_sentence() |
Parses a sentence and applies it to a vessel state in one call. |
parse_coordinate() |
Parses a latitude or longitude field with its hemisphere letter into decimal degrees. |
parse_time_of_day() |
Parses a UTC time of day in the form hhmmss or hhmmss.s... into milliseconds since midnight. |
parse_date() |
Parses a ddmmyy date field, as sent in RMC. |
parse_number_field() |
Parses a decimal field independently of the process locale. |
encode_rmc() |
Encodes RMC, the recommended minimum navigation data. |
encode_gga() |
Encodes GGA, the GNSS fix data. |
encode_gll() |
Encodes GLL, the geographic position. |
encode_gsa() |
Encodes GSA, the active satellites and dilution of precision. |
encode_gsv() |
Encodes GSV, the satellites in view, four per sentence. |
encode_vtg() |
Encodes VTG, the course over ground and ground speed. |
encode_zda() |
Encodes ZDA, the UTC time and date. |
encode_hdg() |
Encodes HDG, the magnetic sensor heading with deviation and variation. |
encode_hdm() |
Encodes HDM, the heading referenced to magnetic north. |
encode_hdt() |
Encodes HDT, the heading referenced to true north. |
encode_vhw() |
Encodes VHW, the water speed and heading. |
encode_vbw() |
Encodes VBW, the dual ground and water speed along and across the hull. |
encode_rot() |
Encodes ROT, the rate of turn. |
encode_dpt() |
Encodes DPT, the depth below the transducer with the transducer offset. |
encode_dbt() |
Encodes DBT, the depth below the transducer in three units. |
encode_mtw() |
Encodes MTW, the water temperature. |
encode_mwv_apparent() |
Encodes MWV with reference R: the apparent wind. |
encode_mwv_true() |
Encodes MWV with reference T: the true wind relative to the bow. |
encode_mwd() |
Encodes MWD, the true wind direction and speed. |
encode_rsa() |
Encodes RSA, the rudder angle. |
encode_apb() |
Encodes APB, autopilot sentence B. |
encode_rmb() |
Encodes RMB, the recommended minimum navigation information to the destination. |
encode_xte() |
Encodes XTE, the cross-track error. |
encode_rpm() |
Encodes RPM, the revolutions of each engine. |
encode_xdr() |
Encodes XDR, the transducer measurements of each engine. |
encode_vdo_position() |
Encodes the own vessel's AIS position report as VDO. |
encode_vdo_static() |
Encodes the own vessel's AIS static and voyage data report (message type 5) as VDO. |
encode_vdm_position() |
Encodes the own vessel's AIS position report as VDM, as another station would receive it. |
encode_vdm_static() |
Encodes the own vessel's AIS static and voyage data report as VDM, as another station would receive it. |
sanitize_waypoint_name() |
Restricts a waypoint name to the characters an NMEA 0183 field may carry. |
mode_indicator() |
Returns the mode indicator letter sent by RMC, GLL, VTG, APB, RMB and XTE. |
status_indicator() |
Returns the status letter sent by RMC and GLL. |
format_fixed() |
Formats a number with a fixed number of decimals, rounded to the nearest last digit. |
format_padded() |
Formats an integer, zero-padded to a minimum width. |
format_latitude() |
Formats a latitude as ddmm.mmmm and its hemisphere letter. |
format_longitude() |
Formats a longitude as dddmm.mmmm and its hemisphere letter. |
format_time() |
Formats the UTC time of day as hhmmss.ss. |
format_date() |
Formats the UTC date as ddmmyy, with a two-digit year. |
date_parts() |
Splits the UTC date of an instant into year, month and day. |
east_west() |
Returns the hemisphere letter for a signed east or west quantity such as magnetic variation or deviation. |
to_string() |
Returns the display name of a sentence group. |
encode_within_limit() |
Runs the encoder of a sentence, lowering the position precision until every sentence fits the NMEA 0183 length limit. |
is_text_field_character() |
Tells whether a character may appear in a sentence field. |
fits_limit() |
Tells whether a framed sentence fits the NMEA 0183 length limit. |
format_tag_block() |
Formats the TAG block for a sentence sent at a given time. |
prepend_tag_block() |
Returns a sentence with a TAG block in front. |
sanitize_tag_source() |
Returns a source identifier as it is sent in the s: parameter. |
Variables
| Name | Description |
|---|---|
kMaxSentenceLength |
Maximum length of a sentence in bytes, from NMEA 0183: 82, counting the start delimiter and the terminating CR LF. |
kStartDelimiter |
Start delimiter of parametric sentences, $. |
kEncapsulationDelimiter |
Start delimiter of encapsulated sentences, !, used by the AIS sentences VDM and VDO. |
kChecksumDelimiter |
Separator between the sentence body and its checksum, *. |
kMaxSentenceLengthWithoutTerminator |
Maximum length of a sentence in bytes without the terminating CR LF: 80, that is kMaxSentenceLength less the two terminator bytes. |
Type aliases¶
Encoder¶
using Encoder = std::vector<std::string>(*)(const EncoderContext& )
Pointer to an encoder function, the signature every encoder shares; stored in SentenceDescriptor::encoder.
The function returns the framed sentences for one emission, in transmission order, and possibly none.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:63
Enumerations¶
SentenceGroup¶
enum class SentenceGroup
Functional group a sentence belongs to.
A whole group can be enabled or disabled at once (simulation::SentenceScheduler::set_group_enabled), and the interface and the command-line tool show the group of each sentence by its display name from to_string.
| Enumerator | Value | Description |
|---|---|---|
Gnss |
GNSS receiver: RMC, GGA, GLL, GSA, GSV and VTG; displayed as "GNSS". | |
Time |
Time and date: ZDA; displayed as "Time". | |
Heading |
Heading and rate of turn: HDG, HDM, HDT and ROT; displayed as "Heading". | |
Speed |
Speed log: VHW and VBW; displayed as "Speed". | |
Depth |
Echo sounder: DPT, DBT and water temperature MTW; displayed as "Depth". | |
Wind |
Wind instrument: MWV (apparent and true) and MWD; displayed as "Wind". | |
Steering |
Rudder angle: RSA; displayed as "Steering". | |
Autopilot |
Navigation to the destination: APB, RMB and XTE; displayed as "Autopilot". | |
Propulsion |
Engines: RPM and XDR; displayed as "Propulsion". | |
Ais |
Own-vessel AIS: VDO and VDM; displayed as "AIS". |
Declared in src/core/include/nmeasim/core/nmea0183/registry.hpp:37
Functions¶
compute_checksum()¶
std::uint8_t compute_checksum(std::string_view body) noexcept
Computes the NMEA 0183 checksum of body: the XOR of all its bytes.
Parameters
| Name | Type | Description |
|---|---|---|
body |
std::string_view |
The text the checksum covers: everything after the start delimiter and before the *, without either. The same rule covers the text of a TAG block between its backslashes. |
Returns std::uint8_t: The XOR of every byte of body; 0 for an empty body.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:45 · defined in src/core/src/nmea0183/checksum.cpp:55
format_checksum()¶
std::string format_checksum(std::uint8_t checksum)
Formats a checksum as exactly two upper-case hexadecimal digits.
Parameters
| Name | Type | Description |
|---|---|---|
checksum |
std::uint8_t |
The checksum, as returned by compute_checksum. |
Returns std::string: Two characters, for example "0A" for 10 and "FF" for 255.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:51 · defined in src/core/src/nmea0183/checksum.cpp:63
append_checksum()¶
std::string append_checksum(std::string_view sentence)
Appends *hh to a sentence that has no checksum yet.
The checksum covers every character after the first, so the first character must be the start delimiter ($ or !); the function does not check it. The result has no line terminator; the caller adds CR LF when transmitting.
Parameters
| Name | Type | Description |
|---|---|---|
sentence |
std::string_view |
The sentence from its start delimiter to its last field, without *hh and without CR LF. An empty sentence has an empty body and gives *00. |
Returns std::string: sentence followed by * and the two checksum digits.
Note
A sentence that already contains a * gets a second checksum computed over the first one, which is not a valid sentence.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:64 · defined in src/core/src/nmea0183/checksum.cpp:68
verify_checksum()¶
bool verify_checksum(std::string_view sentence) noexcept
Checks the framing and the checksum of a received sentence.
Any trailing CR and LF characters are ignored. The sentence must then start with $ or !, have a non-empty body, and end with * followed by exactly two hexadecimal digits, which may be upper or lower case. A sentence without checksum, or with a TAG block in front, is rejected.
Parameters
| Name | Type | Description |
|---|---|---|
sentence |
std::string_view |
The sentence to check, with or without its line terminator. |
Returns bool: true when the framing is valid and the digits after the first * match the checksum of the body; false otherwise.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:76 · defined in src/core/src/nmea0183/checksum.cpp:77
parse_sentence()¶
std::optional<ParsedSentence> parse_sentence(std::string_view line)
Splits a sentence into its start delimiter, address and data fields.
Surrounding whitespace, including the CR LF line terminator, is ignored. A checksum is optional; when a * is present the checksum must match. The talker is P for an address starting with P and two characters otherwise; the formatter is the rest of the address. Field contents are not checked.
Parameters
| Name | Type | Description |
|---|---|---|
line |
std::string_view |
One sentence, with or without checksum and line terminator. |
Returns std::optional<ParsedSentence>: The parsed sentence, or std::nullopt when the line does not start with $ or !, when its address is shorter than three characters or has no formatter after the talker, or when it carries a checksum that does not match.
See also
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:73 · defined in src/core/src/nmea0183/decoder.cpp:756
sentence_time()¶
std::optional<SentenceTime> sentence_time(const ParsedSentence& sentence)
Returns the UTC time a sentence carries, when it carries a valid one.
The time of day is read from field 0 of RMC, GGA, ZDA, GNS, GST, GBS and GRS, and from field 4 of GLL. The date comes from the ddmmyy field 8 of RMC, or from the day, month and four-digit year in fields 1 to 3 of ZDA when they form a date that exists; otherwise the time is returned without a date.
Parameters
| Name | Type | Description |
|---|---|---|
sentence |
const ParsedSentence& |
A parsed sentence of any formatter; the talker is ignored. |
Returns std::optional<SentenceTime>: The time, or std::nullopt for other formatters and when the time field is empty or malformed.
See also
- NMEA 0183, sentences RMC, GGA, GLL, ZDA, GNS, GST, GBS and GRS.
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:100 · defined in src/core/src/nmea0183/decoder.cpp:914
apply_sentence()¶
bool apply_sentence(const ParsedSentence& sentence, model::VesselState& state)
Applies the values carried by a parametric sentence to a vessel state.
Recognised formatters, whatever the talker: RMC, GGA, GLL, GNS, GSA, GSV, VTG, ZDA, HDT, HDG, HDM, ROT, VHW, VBW, DPT, DBT, MTW, MWV, MWD, RSA, RMB, RPM and XDR; GST, GBS and GRS, of which only the time is applied; and APB and XTE, which are recognised but change nothing because RMB carries the same destination with its position. Every sentence that sentence_time() reads a time from is thus applied. Only the quantities a sentence carries are updated, and a field that is empty or malformed leaves its value unchanged, so a state can be built up from a mixed stream.
A time field updates state.time_utc: RMC and ZDA with a valid date set date and time; GGA, GLL, GNS, GST, GBS, GRS, and RMC or ZDA without a valid date, set the time of day and keep the date of the current state.time_utc. When keeping the date would move the time back by more than 12 hours, the time of day has wrapped past midnight and the date advances by one day, so a GGA just after midnight lands on the new date before the next RMC or ZDA arrives.
Parameters
| Name | Type | Description |
|---|---|---|
sentence |
const ParsedSentence& |
The parsed sentence to apply. |
state (inout) |
model::VesselState& |
The state to update; values the sentence does not carry are kept. |
Returns bool: True when the formatter is recognised, even if no field could be used; false for an unknown formatter or an encapsulated (!) sentence, in which case state is unchanged.
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:123 · defined in src/core/src/nmea0183/decoder.cpp:937
apply_sentence()¶
bool apply_sentence(std::string_view line, model::VesselState& state)
Parses a sentence and applies it to a vessel state in one call.
Parameters
| Name | Type | Description |
|---|---|---|
line |
std::string_view |
One sentence as accepted by parse_sentence(). |
state (inout) |
model::VesselState& |
The state to update, as for the overload taking a ParsedSentence. |
Returns bool: True when the line parsed and its formatter is recognised; false for a malformed line, an unknown formatter or an encapsulated sentence, in which case state is unchanged.
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:132 · defined in src/core/src/nmea0183/decoder.cpp:1020
parse_coordinate()¶
std::optional<double> parse_coordinate(std::string_view value, std::string_view hemisphere)
Parses a latitude or longitude field with its hemisphere letter into decimal degrees.
The value is ddmm.mmmm for a latitude or dddmm.mmmm for a longitude: the digits before the last two integer digits are degrees, the rest are minutes. Any number of fractional digits is accepted, and leading zeros of the degrees may be left out. The hemisphere letter decides the sign, the valid range and the largest number of degree digits: two for N and S, three for E and W.
Parameters
| Name | Type | Description |
|---|---|---|
value |
std::string_view |
The coordinate field, unsigned digits with at most one full stop; surrounding whitespace is ignored. |
hemisphere |
std::string_view |
Exactly one of N, S, E or W. |
Returns std::optional<double>: Decimal degrees, positive north or east and negative south or west; or std::nullopt when either field is empty or malformed, when the value has a sign or more degree digits than the hemisphere allows, when the minutes are 60 or more, or when the result exceeds 90 degrees for N and S or 180 degrees for E and W.
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:149 · defined in src/core/src/nmea0183/decoder.cpp:832
parse_time_of_day()¶
std::optional<std::chrono::milliseconds> parse_time_of_day(std::string_view value)
Parses a UTC time of day in the form hhmmss or hhmmss.s... into milliseconds since midnight.
Fractional seconds may have any number of digits; digits beyond the third are ignored (truncated, not rounded).
Parameters
| Name | Type | Description |
|---|---|---|
value |
std::string_view |
The time field; surrounding whitespace is ignored. |
Returns std::optional<std::chrono::milliseconds>: The time since midnight, or std::nullopt when the field is not six digits optionally followed by a full stop and at least one digit, or when the hours exceed 23, the minutes 59 or the seconds 60 (60 is accepted for a leap second).
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:162 · defined in src/core/src/nmea0183/decoder.cpp:871
parse_date()¶
std::optional<DateParts> parse_date(std::string_view value)
Parses a ddmmyy date field, as sent in RMC.
Two-digit years below 80 belong to the 21st century (25 is 2025), years from 80 to 99 to the 20th (99 is 1999), which covers every date an NMEA 0183 recording can carry.
Parameters
| Name | Type | Description |
|---|---|---|
value |
std::string_view |
The date field; surrounding whitespace is ignored. |
Returns std::optional<DateParts>: The date with a four-digit year, or std::nullopt when the field is not exactly six digits or the date does not exist: the month outside [1, 12], or the day outside the days of that month, with 29 February only in a leap year.
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:173 · defined in src/core/src/nmea0183/decoder.cpp:899
parse_number_field()¶
std::optional<double> parse_number_field(std::string_view value)
Parses a decimal field independently of the process locale.
Accepts an optional + or - sign, digits and at most one full stop as the decimal separator, with at least one digit in total (.5 and 5. are valid, - and . are not). No exponent, thousands separator or decimal comma is accepted.
Parameters
| Name | Type | Description |
|---|---|---|
value |
std::string_view |
The field; surrounding whitespace is ignored. |
Returns std::optional<double>: The value, or std::nullopt when the field is empty or not a plain decimal number.
Declared in src/core/include/nmeasim/core/nmea0183/decoder.hpp:184 · defined in src/core/src/nmea0183/decoder.cpp:798
encode_rmc()¶
std::vector<std::string> encode_rmc(const EncoderContext& context)
Encodes RMC, the recommended minimum navigation data.
Fields: UTC time hhmmss.ss, status (status_indicator()), latitude and longitude, speed over ground in knots and course over ground in degrees true with one decimal, date ddmmyy, magnetic variation with one decimal and its E or W letter (E for zero), and the mode indicator (mode_indicator()). Without a fix the position, speed and course fields are empty.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state, talker and position precision to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence RMC.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:78 · defined in src/core/src/nmea0183/encoders.cpp:204
encode_gga()¶
std::vector<std::string> encode_gga(const EncoderContext& context)
Encodes GGA, the GNSS fix data.
Fields: UTC time, latitude and longitude, the fix quality code of model::FixQuality, satellites in use clamped to [0, 12] as two digits, HDOP, altitude above mean sea level in metres, M, geoid separation in metres, M, and two empty fields for the age of differential data and the differential station. Without a fix the sentence reports quality 0, satellites 00 and empty position, HDOP, altitude and geoid separation.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state, talker and position precision to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence GGA.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:91 · defined in src/core/src/nmea0183/encoders.cpp:223
encode_gll()¶
std::vector<std::string> encode_gll(const EncoderContext& context)
Encodes GLL, the geographic position.
Fields: latitude and longitude (empty without a fix), UTC time, status (status_indicator()) and mode indicator (mode_indicator()).
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state, talker and position precision to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence GLL.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:101 · defined in src/core/src/nmea0183/encoders.cpp:243
encode_gsa()¶
std::vector<std::string> encode_gsa(const EncoderContext& context)
Encodes GSA, the active satellites and dilution of precision.
Fields: selection mode A (automatic), fix type 3 (3D) with a fix and 1 (none) without, twelve PRN slots of which the first satellites_in_use (clamped to [0, 12]) hold the PRNs of the fixed simulated constellation (02, 05, 07, 09, ...) and the rest are empty, then PDOP, HDOP and VDOP with one decimal. Without a fix all PRN and DOP fields are empty.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence GSA.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:113 · defined in src/core/src/nmea0183/encoders.cpp:253
encode_gsv()¶
std::vector<std::string> encode_gsv(const EncoderContext& context)
Encodes GSV, the satellites in view, four per sentence.
The number in view is the larger of satellites_in_view and satellites_in_use, each clamped to [0, 12], and 0 without a fix. Every sentence carries the total number of sentences, its own number from 1 and the number in view, followed by up to four satellites, each as PRN, elevation in degrees, azimuth in degrees and SNR in dB. The elevation, azimuth and SNR are synthetic but fixed per PRN, so the output is deterministic. With no satellites in view a single sentence 1,1,00 without satellite blocks is sent.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One to three sentences, in order.
See also
- NMEA 0183, sentence GSV.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:128 · defined in src/core/src/nmea0183/encoders.cpp:273
encode_vtg()¶
std::vector<std::string> encode_vtg(const EncoderContext& context)
Encodes VTG, the course over ground and ground speed.
Fields: course over ground in degrees true, T, course over ground in degrees magnetic (true course minus variation), M, speed over ground in knots, N, the same speed in km/h, K, and the mode indicator (mode_indicator()). Without a fix the four values are empty and their unit letters are kept.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence VTG.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:140 · defined in src/core/src/nmea0183/encoders.cpp:304
encode_zda()¶
std::vector<std::string> encode_zda(const EncoderContext& context)
Encodes ZDA, the UTC time and date.
Fields: UTC time, day and month as two digits, the four-digit year, and local zone hours and minutes, both always 00. The time and date are sent whether or not there is a fix.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence ZDA.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:150 · defined in src/core/src/nmea0183/encoders.cpp:324
encode_hdg()¶
std::vector<std::string> encode_hdg(const EncoderContext& context)
Encodes HDG, the magnetic sensor heading with deviation and variation.
Fields: the compass heading model::Navigation::heading_compass_deg() (true heading minus variation and deviation), the magnitude of the deviation with its E or W letter and the magnitude of the variation with its letter, each with one decimal; a zero value is sent as E.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence HDG.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:164 · defined in src/core/src/nmea0183/encoders.cpp:340
encode_hdm()¶
std::vector<std::string> encode_hdm(const EncoderContext& context)
Encodes HDM, the heading referenced to magnetic north.
Fields: model::Navigation::heading_magnetic_deg() (true heading minus variation) with one decimal, then M. The compass deviation does not apply; HDG carries it.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence HDM.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:174 · defined in src/core/src/nmea0183/encoders.cpp:351
encode_hdt()¶
std::vector<std::string> encode_hdt(const EncoderContext& context)
Encodes HDT, the heading referenced to true north.
Fields: heading_true_deg with one decimal, then T.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence HDT.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:183 · defined in src/core/src/nmea0183/encoders.cpp:357
encode_vhw()¶
std::vector<std::string> encode_vhw(const EncoderContext& context)
Encodes VHW, the water speed and heading.
Fields: heading in degrees true, T, heading from model::Navigation::heading_magnetic_deg() (without deviation, as in encode_hdm()), M, speed through the water in knots, N, and the same speed in km/h, K, each with one decimal.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence VHW.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:195 · defined in src/core/src/nmea0183/encoders.cpp:363
encode_vbw()¶
std::vector<std::string> encode_vbw(const EncoderContext& context)
Encodes VBW, the dual ground and water speed along and across the hull.
The longitudinal water speed is the speed through the water and the transverse water speed is 0.0, because the model has no leeway. The speed over ground is resolved onto the hull through the drift angle between course over ground and true heading: the longitudinal component is positive ahead, the transverse component positive to starboard. The stern transverse speeds are 0.0. All speeds are in knots with one decimal and every status field is A, also without a fix.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence VBW.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:209 · defined in src/core/src/nmea0183/encoders.cpp:377
encode_rot()¶
std::vector<std::string> encode_rot(const EncoderContext& context)
Encodes ROT, the rate of turn.
Fields: the rate of turn in degrees per minute with one decimal, negative to port, and status A.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence ROT.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:219 · defined in src/core/src/nmea0183/encoders.cpp:400
encode_dpt()¶
std::vector<std::string> encode_dpt(const EncoderContext& context)
Encodes DPT, the depth below the transducer with the transducer offset.
Fields: depth below the transducer in metres, the transducer offset in metres (positive to the water line, negative to the keel), each with one decimal, and an empty maximum range scale.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence DPT.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:232 · defined in src/core/src/nmea0183/encoders.cpp:409
encode_dbt()¶
std::vector<std::string> encode_dbt(const EncoderContext& context)
Encodes DBT, the depth below the transducer in three units.
Fields: depth in feet, f, in metres, M, and in fathoms, F, each with one decimal.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence DBT.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:241 · defined in src/core/src/nmea0183/encoders.cpp:416
encode_mtw()¶
std::vector<std::string> encode_mtw(const EncoderContext& context)
Encodes MTW, the water temperature.
Fields: the temperature in degrees Celsius with one decimal, then C.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence MTW.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:250 · defined in src/core/src/nmea0183/encoders.cpp:428
encode_mwv_apparent()¶
std::vector<std::string> encode_mwv_apparent(const EncoderContext& context)
Encodes MWV with reference R: the apparent wind.
Fields: apparent wind angle relative to the bow, clockwise in [0, 360), R, apparent wind speed in knots, N, and status A.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence MWV.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:262 · defined in src/core/src/nmea0183/encoders.cpp:437
encode_mwv_true()¶
std::vector<std::string> encode_mwv_true(const EncoderContext& context)
Encodes MWV with reference T: the true wind relative to the bow.
Fields: the true wind direction minus the true heading, clockwise in [0, 360) (model::Wind::true_angle_relative_deg()), T, true wind speed in knots, N, and status A.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence MWV.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:273 · defined in src/core/src/nmea0183/encoders.cpp:448
encode_mwd()¶
std::vector<std::string> encode_mwd(const EncoderContext& context)
Encodes MWD, the true wind direction and speed.
Fields: the direction the true wind blows from in degrees true, T, the same direction in degrees magnetic (true minus variation, without deviation), M, the speed in knots, N, and in metres per second, M, each with one decimal.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence MWD.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:284 · defined in src/core/src/nmea0183/encoders.cpp:459
encode_rsa()¶
std::vector<std::string> encode_rsa(const EncoderContext& context)
Encodes RSA, the rudder angle.
Fields: the rudder angle in degrees with one decimal, positive to starboard, in the starboard (or single) rudder field with status A, then an empty port rudder field with status V (not fitted).
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- NMEA 0183, sentence RSA.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:297 · defined in src/core/src/nmea0183/encoders.cpp:478
encode_apb()¶
std::vector<std::string> encode_apb(const EncoderContext& context)
Encodes APB, autopilot sentence B.
Fields: statuses A and A, cross-track error magnitude in nautical miles with two decimals, direction to steer (L when the vessel is to the right of the leg, R otherwise), N, arrival circle entered (A within arrival_radius_m of the destination, V otherwise), perpendicular passed (A once the vessel is level with or beyond the destination along the leg), bearing from origin to destination, T, the waypoint name (sanitize_waypoint_name()), bearing from the vessel to the destination, T, the same bearing as heading to steer, T, and the mode indicator. Bearings are in degrees true with one decimal.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence, or none when context.state.destination is empty.
See also
- NMEA 0183, sentence APB.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:316 · defined in src/core/src/nmea0183/encoders.cpp:500
encode_rmb()¶
std::vector<std::string> encode_rmb(const EncoderContext& context)
Encodes RMB, the recommended minimum navigation information to the destination.
Fields: status A, cross-track error magnitude in nautical miles with two decimals, direction to steer as in encode_apb(), an empty origin waypoint name, the destination waypoint name (sanitize_waypoint_name()), the destination latitude and longitude with options.position_decimals, the range to the destination in nautical miles capped at 999.9, the true bearing to the destination, the closing velocity in knots (the component of the speed over ground towards the destination, negative when moving away), the arrival status (A within arrival_radius_m, V otherwise) and the mode indicator.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state, talker and position precision to encode with. |
Returns std::vector<std::string>: One sentence, or none when context.state.destination is empty.
See also
- NMEA 0183, sentence RMB.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:331 · defined in src/core/src/nmea0183/encoders.cpp:525
encode_xte()¶
std::vector<std::string> encode_xte(const EncoderContext& context)
Encodes XTE, the cross-track error.
Fields: statuses A and A, cross-track error magnitude in nautical miles with two decimals, direction to steer as in encode_apb(), N, and the mode indicator.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence, or none when context.state.destination is empty.
See also
- NMEA 0183, sentence XTE.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:341 · defined in src/core/src/nmea0183/encoders.cpp:558
encode_rpm()¶
std::vector<std::string> encode_rpm(const EncoderContext& context)
Encodes RPM, the revolutions of each engine.
Fields per engine: source E (engine), the engine number counted from 1 in VesselState::engines order, revolutions per minute with one decimal (0.0 while the engine is not running), an empty propeller pitch and status A.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence per engine in profile order; none when the vessel has no engines.
See also
- NMEA 0183, sentence RPM.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:354 · defined in src/core/src/nmea0183/encoders.cpp:577
encode_xdr()¶
std::vector<std::string> encode_xdr(const EncoderContext& context)
Encodes XDR, the transducer measurements of each engine.
Each sentence carries two transducers named ENGINE#n, with n counted from 0 in VesselState::engines order as Signal K and common gateways expect: a temperature transducer (C, coolant temperature, C for degrees Celsius) and a tachometer (T, revolutions per minute, R), both with one decimal. A stopped engine reports 0.0 revolutions.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence per engine in profile order; none when the vessel has no engines.
See also
- NMEA 0183, sentence XDR.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:367 · defined in src/core/src/nmea0183/encoders.cpp:594
encode_vdo_position()¶
std::vector<std::string> encode_vdo_position(const EncoderContext& context)
Encodes the own vessel's AIS position report as VDO.
The message type is AisStatic::position_report_type when it is 1, 2 or 3, and 1 otherwise. The payload of 168 bits fits one sentence, sent on channel A with an empty sequential message id.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- ITU-R M.1371-5, Annex 8, messages 1, 2 and 3.
- NMEA 0183, sentence VDO.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:383 · defined in src/core/src/nmea0183/encoders.cpp:617
encode_vdo_static()¶
std::vector<std::string> encode_vdo_static(const EncoderContext& context)
Encodes the own vessel's AIS static and voyage data report (message type 5) as VDO.
The payload of 424 bits needs two sentences, sent on channel A, which share a sequential message id derived from the simulated clock: the UTC seconds modulo 10.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: Two sentences, in order.
See also
- ITU-R M.1371-5, Annex 8, message 5.
- NMEA 0183, sentence VDO.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:394 · defined in src/core/src/nmea0183/encoders.cpp:621
encode_vdm_position()¶
std::vector<std::string> encode_vdm_position(const EncoderContext& context)
Encodes the own vessel's AIS position report as VDM, as another station would receive it.
The payload and framing are those of encode_vdo_position(); only the formatter differs, for consumers that ignore VDO.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: One sentence.
See also
- ITU-R M.1371-5, Annex 8, messages 1, 2 and 3.
- NMEA 0183, sentence VDM.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:405 · defined in src/core/src/nmea0183/encoders.cpp:625
encode_vdm_static()¶
std::vector<std::string> encode_vdm_static(const EncoderContext& context)
Encodes the own vessel's AIS static and voyage data report as VDM, as another station would receive it.
The payload and framing are those of encode_vdo_static(); only the formatter differs.
Parameters
| Name | Type | Description |
|---|---|---|
context |
const EncoderContext& |
The state and talker to encode with. |
Returns std::vector<std::string>: Two sentences, in order.
See also
- ITU-R M.1371-5, Annex 8, message 5.
- NMEA 0183, sentence VDM.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:416 · defined in src/core/src/nmea0183/encoders.cpp:629
sanitize_waypoint_name()¶
std::string sanitize_waypoint_name(std::string_view name)
Restricts a waypoint name to the characters an NMEA 0183 field may carry.
Keeps the characters is_text_field_character() allows except space: the printable ASCII characters other than those NMEA 0183 reserves (,, *, $, !, \\endiskip, ^ and ~); spaces, control characters and bytes outside ASCII are dropped. The result is truncated to model::kMaxWaypointNameLength characters.
Parameters
| Name | Type | Description |
|---|---|---|
name |
std::string_view |
The configured waypoint name, of any length. |
Returns std::string: The sanitised name, or WPT when no character is left.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:427 · defined in src/core/src/nmea0183/encoders.cpp:487
mode_indicator()¶
char mode_indicator(const model::GnssFix& fix) noexcept
Returns the mode indicator letter sent by RMC, GLL, VTG, APB, RMB and XTE.
Parameters
| Name | Type | Description |
|---|---|---|
fix |
const model::GnssFix& |
The GNSS receiver state. |
Returns char: N (no fix) when fix.has_fix is false, otherwise D (differential) when the quality is model::FixQuality::Differential and A (autonomous) for any other quality.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:434 · defined in src/core/src/nmea0183/encoders.cpp:190
status_indicator()¶
char status_indicator(const model::GnssFix& fix) noexcept
Returns the status letter sent by RMC and GLL.
Parameters
| Name | Type | Description |
|---|---|---|
fix |
const model::GnssFix& |
The GNSS receiver state. |
Returns char: A (data valid) when fix.has_fix is true, V (receiver warning) otherwise.
Declared in src/core/include/nmeasim/core/nmea0183/encoders.hpp:440 · defined in src/core/src/nmea0183/encoders.cpp:197
format_fixed()¶
std::string format_fixed(double value, int decimals)
Formats a number with a fixed number of decimals, rounded to the nearest last digit.
A result that would read as negative zero, such as -0.0 for -0.04 with one decimal, is rendered without the sign.
Parameters
| Name | Type | Description |
|---|---|---|
value |
double |
The number to format. |
decimals |
int |
Digits after the decimal point, 0 or more; 0 gives no decimal point. |
Returns std::string: The formatted number, for example "6.5" for 6.5 with one decimal.
Throws
| Exception | Condition |
|---|---|
std::format_error |
if decimals is negative. |
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:29 · defined in src/core/src/nmea0183/fields.cpp:64
format_padded()¶
std::string format_padded(int value, int width)
Formats an integer, zero-padded to a minimum width.
Parameters
| Name | Type | Description |
|---|---|---|
value |
int |
The integer to format. |
width |
int |
Minimum number of characters, reached by adding zeros after the sign of a negative number; 0 or a negative value means no padding. A longer number is not truncated. |
Returns std::string: The formatted integer, for example "08" for 8 with a width of 2.
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:38 · defined in src/core/src/nmea0183/fields.cpp:75
format_latitude()¶
CoordinateField format_latitude(double latitude_deg, int decimals)
Formats a latitude as ddmm.mmmm and its hemisphere letter.
The minutes are rounded to the last digit with integer arithmetic, so a rounding carry goes into the degrees and the minutes never read 60.
Parameters
| Name | Type | Description |
|---|---|---|
latitude_deg |
double |
Latitude in decimal degrees, positive north, in [-90, 90]; values outside the range are not checked. |
decimals |
int |
Digits of fractional minutes; the profile allows [2, 8], 4 digits resolve about 0.19 m. 0 gives whole minutes without a decimal point, and a negative value is treated as 0. |
Returns CoordinateField: The formatted latitude, for example "3759.0280" and N for 37.9838 with four decimals; S for a negative latitude and N otherwise.
See also
- NMEA 0183, sentence GLL.
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:63 · defined in src/core/src/nmea0183/fields.cpp:82
format_longitude()¶
CoordinateField format_longitude(double longitude_deg, int decimals)
Formats a longitude as dddmm.mmmm and its hemisphere letter.
The minutes are rounded to the last digit with integer arithmetic, so a rounding carry goes into the degrees and the minutes never read 60.
Parameters
| Name | Type | Description |
|---|---|---|
longitude_deg |
double |
Longitude in decimal degrees, positive east, in [-180, 180]; values outside the range are not checked. |
decimals |
int |
Digits of fractional minutes; the profile allows [2, 8]. 0 gives whole minutes without a decimal point, and a negative value is treated as 0. |
Returns CoordinateField: The formatted longitude, for example "02343.6500" and E for 23.7275 with four decimals; W for a negative longitude and E otherwise.
See also
- NMEA 0183, sentence GLL.
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:77 · defined in src/core/src/nmea0183/fields.cpp:86
format_time()¶
std::string format_time(std::chrono::system_clock::time_point time_utc)
Formats the UTC time of day as hhmmss.ss.
Fractions of a second are truncated to hundredths, not rounded, so 23:59:59.999 is sent as 235959.99 and never rolls over into the next day.
Parameters
| Name | Type | Description |
|---|---|---|
time_utc |
std::chrono::system_clock::time_point |
The instant to format. |
Returns std::string: The time of day, for example "123456.78".
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:86 · defined in src/core/src/nmea0183/fields.cpp:90
format_date()¶
std::string format_date(std::chrono::system_clock::time_point time_utc)
Formats the UTC date as ddmmyy, with a two-digit year.
Parameters
| Name | Type | Description |
|---|---|---|
time_utc |
std::chrono::system_clock::time_point |
The instant to format. |
Returns std::string: The date, for example "220926" for 22 September 2026.
See also
- NMEA 0183, sentence RMC.
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:93 · defined in src/core/src/nmea0183/fields.cpp:107
date_parts()¶
DateParts date_parts(std::chrono::system_clock::time_point time_utc)
Splits the UTC date of an instant into year, month and day.
Parameters
| Name | Type | Description |
|---|---|---|
time_utc |
std::chrono::system_clock::time_point |
The instant whose date is wanted. |
Returns DateParts: The calendar date of time_utc in UTC.
See also
- NMEA 0183, sentence ZDA.
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:110 · defined in src/core/src/nmea0183/fields.cpp:100
east_west()¶
char east_west(double value) noexcept
Returns the hemisphere letter for a signed east or west quantity such as magnetic variation or deviation.
Parameters
| Name | Type | Description |
|---|---|---|
value |
double |
The quantity in degrees, positive east. |
Returns char: W when value is negative, E otherwise, including for zero.
Declared in src/core/include/nmeasim/core/nmea0183/fields.hpp:117
to_string()¶
std::string_view to_string(SentenceGroup group) noexcept
Returns the display name of a sentence group.
Parameters
| Name | Type | Description |
|---|---|---|
group |
SentenceGroup |
The group to name. |
Returns std::string_view: The name, for example "GNSS" or "AIS", or "Unknown" for a value that is not an enumerator. The view refers to a string literal and stays valid for the whole program.
Declared in src/core/include/nmeasim/core/nmea0183/registry.hpp:56 · defined in src/core/src/nmea0183/registry.cpp:18
encode_within_limit()¶
std::vector<std::string> encode_within_limit(
const SentenceDescriptor& descriptor,
const model::VesselState& state,
std::string_view talker,
EncoderOptions options)
Runs the encoder of a sentence, lowering the position precision until every sentence fits the NMEA 0183 length limit.
The encoder is first run with options.position_decimals, raised to 2 when it is lower. While any resulting sentence is longer than kMaxSentenceLengthWithoutTerminator, it is run again with one decimal fewer, down to two decimals; the result of the last attempt is returned even if it is still too long, so a sentence is never dropped for its length.
Parameters
| Name | Type | Description |
|---|---|---|
descriptor |
const SentenceDescriptor& |
The sentence to encode. |
state |
const model::VesselState& |
The vessel state to encode; it is only used during the call. |
talker |
std::string_view |
Two-character talker identifier to send, already resolved from the profile. |
options |
EncoderOptions |
Formatting options; options.position_decimals is the preferred number of fractional minute digits, of which at least 2 are used. |
Returns std::vector<std::string>: The sentences of one emission, framed with checksums and without line terminator. Empty only when the encoder has nothing to report, for example APB without a destination.
Declared in src/core/include/nmeasim/core/nmea0183/registry.hpp:140 · defined in src/core/src/nmea0183/registry.cpp:119
is_text_field_character()¶
bool is_text_field_character(char c) noexcept
Tells whether a character may appear in a sentence field.
NMEA 0183 allows the printable ASCII characters, space included, in a field, except those it reserves for framing and encoding: , (field delimiter), * (checksum delimiter), $ and ! (start delimiters), \\endiskip (TAG block delimiter), ^ (code delimiter of the hexadecimal escapes) and ~ (reserved). CR, LF, the other control characters, DEL and bytes outside ASCII are never allowed.
Parameters
| Name | Type | Description |
|---|---|---|
c |
char |
The character to check. |
Returns bool: true for a printable ASCII character that NMEA 0183 does not reserve.
See also
- NMEA 0183 (IEC 61162-1), reserved and valid characters.
Declared in src/core/include/nmeasim/core/nmea0183/sentence_builder.hpp:41 · defined in src/core/src/nmea0183/sentence_builder.cpp:13
fits_limit()¶
bool fits_limit(std::string_view sentence) noexcept
Tells whether a framed sentence fits the NMEA 0183 length limit.
Parameters
| Name | Type | Description |
|---|---|---|
sentence |
std::string_view |
The sentence from its start delimiter to its checksum, without line terminator (which the limit already allows for) and without TAG block. |
Returns bool: true when sentence has at most kMaxSentenceLengthWithoutTerminator characters.
Declared in src/core/include/nmeasim/core/nmea0183/sentence_builder.hpp:130 · defined in src/core/src/nmea0183/sentence_builder.cpp:75
format_tag_block()¶
std::string format_tag_block(
const TagBlockOptions& options,
std::chrono::system_clock::time_point time)
Formats the TAG block for a sentence sent at a given time.
The block reads \s:<source>,c:<time>*hh\\endiskip, without the c: parameter when options.include_time is false. The time is the number of whole seconds, or whole milliseconds, since the Unix epoch, truncated rather than rounded.
Parameters
| Name | Type | Description |
|---|---|---|
options |
const TagBlockOptions& |
The source and time parameters to send; the source is passed through sanitize_tag_source. |
time |
std::chrono::system_clock::time_point |
The time of the sentence, normally the simulated UTC time. |
Returns std::string: The block, including both backslashes, for example \s:GP0001,c:1790080496*26\\endiskip.
See also
- IEC 61162-450, TAG block parameter "c".
Declared in src/core/include/nmeasim/core/nmea0183/tag_block.hpp:51 · defined in src/core/src/nmea0183/tag_block.cpp:44
prepend_tag_block()¶
std::string prepend_tag_block(
std::string_view sentence,
const TagBlockOptions& options,
std::chrono::system_clock::time_point time)
Returns a sentence with a TAG block in front.
Parameters
| Name | Type | Description |
|---|---|---|
sentence |
std::string_view |
The framed sentence, with or without line terminator; it is copied unchanged after the block. |
options |
const TagBlockOptions& |
The source and time parameters to send. |
time |
std::chrono::system_clock::time_point |
The time of the sentence, normally the simulated UTC time. |
Returns std::string: The block from format_tag_block followed by sentence.
Declared in src/core/include/nmeasim/core/nmea0183/tag_block.hpp:61 · defined in src/core/src/nmea0183/tag_block.cpp:59
sanitize_tag_source()¶
std::string sanitize_tag_source(std::string_view source)
Returns a source identifier as it is sent in the s: parameter.
Only printable ASCII characters other than the space and the reserved characters ,, *, \\endiskip, ! and $ are kept, and at most the first 15 of them.
Parameters
| Name | Type | Description |
|---|---|---|
source |
std::string_view |
The configured source identifier. |
Returns std::string: The kept characters, or "SIM" when none are left.
Declared in src/core/include/nmeasim/core/nmea0183/tag_block.hpp:72 · defined in src/core/src/nmea0183/tag_block.cpp:26
Variables¶
kMaxSentenceLength¶
std::size_t kMaxSentenceLength{82}
Maximum length of a sentence in bytes, from NMEA 0183: 82, counting the start delimiter and the terminating CR LF.
The only definition of the limit: the checks derive their bound from it.
See also
kMaxSentenceLengthWithoutTerminatorfor the same limit without CR LF.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:28
kStartDelimiter¶
char kStartDelimiter{'$'}
Start delimiter of parametric sentences, $.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:31
kEncapsulationDelimiter¶
char kEncapsulationDelimiter{'!'}
Start delimiter of encapsulated sentences, !, used by the AIS sentences VDM and VDO.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:34
kChecksumDelimiter¶
char kChecksumDelimiter{'*'}
Separator between the sentence body and its checksum, *.
Declared in src/core/include/nmeasim/core/nmea0183/checksum.hpp:37
kMaxSentenceLengthWithoutTerminator¶
std::size_t kMaxSentenceLengthWithoutTerminator{kMaxSentenceLength - 2}
Maximum length of a sentence in bytes without the terminating CR LF: 80, that is kMaxSentenceLength less the two terminator bytes.
Derived from kMaxSentenceLength, the single definition of the NMEA 0183 limit; every length check (fits_limit, encode_within_limit(), the custom sentence validation) uses this value.
Declared in src/core/include/nmeasim/core/nmea0183/sentence_builder.hpp:28