pub fn encode_frame(
prefix: char,
talker: &str,
sentence_type: &str,
fields: &[&str],
) -> Result<String, EncodeError>Expand description
Encode fields into a valid NMEA 0183 sentence string.
Computes the XOR checksum and appends *XX\r\n.
Returns an EncodeError when the prefix is not $/!,
the talker or sentence type is not ASCII, the sentence type is empty, or a field
contains ,, *, \r, \n, or a non-ASCII character.
ยงExamples
use nmea_kit::encode_frame;
let sentence = encode_frame('$', "WI", "MWD", &["270.0", "T", "268.5", "M", "12.4", "N", "6.4", "M"]).expect("valid");
assert!(sentence.starts_with("$WIMWD,"));
assert!(sentence.ends_with("\r\n"));