NMEA-0183 语句解析器,含 21 个语句类型 codec 与配套单元测试。 - codecs/:APB/BWC/DBT/GGA/GLL/GRMT/GSA/GSV/HDG/HDM/HDT/MWV/RDID/ RMB/RMC/ROT/RSA/TXT/VTG/VWR/ZDA - test/:各 codec 对应的 mocha 用例 - .github/workflows/:node与 npm-publish 流水线 许可证:MIT(原作者 James Penn)
34 lines
792 B
JavaScript
34 lines
792 B
JavaScript
var helpers = require("../helpers.js")
|
|
/*
|
|
=== HDT - Heading - True ===
|
|
|
|
------------------------------------------------------------------------------
|
|
1 2 3
|
|
| | |
|
|
$--HDT,x.x,T*hh
|
|
------------------------------------------------------------------------------
|
|
|
|
Field Number:
|
|
|
|
1) Heading Degrees, true
|
|
2) T = True
|
|
3) Checksum
|
|
*/
|
|
exports.TYPE = 'heading-info';
|
|
exports.ID = 'HDT';
|
|
|
|
exports.decode = function (fields) {
|
|
return {
|
|
sentence: exports.ID,
|
|
type: 'heading-info',
|
|
heading: +fields[1]
|
|
}
|
|
};
|
|
|
|
exports.encode = function (talker, msg) {
|
|
var result = ['$' + talker + exports.ID];
|
|
result.push(helpers.encodeFixed(msg.heading, 1));
|
|
result.push('T');
|
|
var resultMsg = result.join(',');
|
|
return resultMsg + helpers.computeChecksum(resultMsg);
|
|
}; |