NMEA 值可以包含“*”吗? (星号)?

发布于 2024-10-07 10:25:31 字数 384 浏览 7 评论 0原文

我正在尝试创建与 NMEA 兼容的专有句子,其中可能包含任意字符串。

带校验和的 NMEA 语句的常用格式为:

$GPxxx,val1,val2,...,valn*ck<cr><lf>

其中 * 标记 2 位校验和的开始。

我的问题是:任何值字段本身都可以包含 * 字符吗?

解析器似乎有可能等待最终的,然后回头查看前 3 个字符以查找校验和(如果存在)(而不是仅仅等待句子中的第一个 *)。但我不知道标准是否允许。

还有其他字符可能会导致问题吗?

I am trying to create NMEA-compatible proprietary sentences, which may contain arbitrary strings.

The usual format for an NMEA sentence with checksum is:

$GPxxx,val1,val2,...,valn*ck<cr><lf>

where * marks the start of a 2-digit checksum.

My question is: Can any of the value fields contain a * character themselves?

It would seem possible for a parser to wait for the final <cr><lf>, then to look back at the previous 3 characters to find the checksum if present (rather than just waiting for the first * in the sentence). However I don't know if the standard allows it.

Are there other characters which may cause problems?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏末染殇 2024-10-14 10:25:31

需要注意的两个 ASCII 字符是 $(必须位于开头)和 *(位于校验和之前)。其他任何解析您的自定义 NMEA 的人都不会期望在其他地方找到这些字符中的任何一个。一些解析器在遇到 $ 时认为新行已经开始。在串行端口通信中,有时字符会在传输过程中丢失,这就是为什么句子标记以 $ 开头。

如果您要创建自己的 NMEA 命令,通常以 P 开头,后跟 3 个字符的代码,指示创建专有消息的制造商或公司,因此您可以使用 $PSQU。请注意,尽管建议 NMEA 命令的长度为 5 个字符,但各种硬件和软件制造商也提供了长度从 4 个字符到 7 个字符不等的专有消息。

显然,如果您正在编写自己的解析器,您可以做您喜欢的事情。

这个网站相当有用:

http://www.gpsinformation.org/dale/nmea.htm

The two ASCII characters to be careful with are $, which has to be at the start, and * which precedes the checksum. Anyone else parsing your custom NMEA wouldn't expect to find either of those characters anywhere else. Some parsers, when they hit a $ assume that a new line has started. With serial port communication sometimes characters get lost in transit, and that's why there's a $ start of sentence marker.

If you're going to make your own NMEA commands it is customary to start them with P followed by a 3 character code indicating the manufacturer or company creating the proprietary message, so you could use $PSQU. Note that although it is recommended that NMEA commands are 5 characters long, there are proprietary messages out there by various hardware and software manufacturers that are anywhere from 4 characters to 7 characters long.

Obviously if you're writing your own parser you can do what you like.

This website is rather useful:

http://www.gpsinformation.org/dale/nmea.htm

樱娆 2024-10-14 10:25:31

如果您自己扩展协议(基于“专有”)-那么当然,您可以添加任何您喜欢的内容。我会坚持使用 ASCII,但在这些范围内会变得疯狂。 (显然,您需要提出自己的 $GPxxx,以免与现有消息冲突。也许是一个新标头 $SQUEL,...)

根据定义,专有消息将不与 NMEA 兼容。

监听 NMEA 流的标准解析器应该忽略任何与它认为的“好”数据不匹配的内容。这意味着校验和错误,或者任何大规模损坏的消息,例如它会认为您的新消息中添加了一些随机 * 。

如果您只是编写现有消息,那么 * 没有意义,应该被忽略,但是,如果校验和正确并且解析器无法理解有效负载,则您将面临出现重大问题的风险。

If you're extending the protocol yourself (based on "proprietary") - then sure, you can put in anything you like. I would stick to ASCII, but go wild within those bounds. (Obviously, you need to come up with your own $GPxxx so as not to clash with existing messages. Perhaps a new header $SQUEL, ...)

By definition, a proprietary message will not be NMEA-compatible.

A standard parser listening to an NMEA stream should ignore anything that doesn't match what it thinks is 'good' data. That means a checksum error, or any massively corrupted message like it would think your new message is with some random *s thrown in.

If you are merely writing an existing message, then a * doesn't make sense, and should be ignored, but you run the risk of major issues if the checksum is correct, and the parser doesn't understand the payload.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文