feat: 导入 NMEA-0183 GPS 协议解析库(node-nmea)
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)
This commit is contained in:
27
test/MWVtest.js
Normal file
27
test/MWVtest.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var should = require('should');
|
||||
|
||||
describe('MWV parsing', function () {
|
||||
it('parses ok', function () {
|
||||
var msg = require("../nmea.js").parse("$IIMWV,017,R,02.91,N,A*2F");
|
||||
msg.should.have.property('sentence', 'MWV');
|
||||
msg.should.have.property('type', 'wind');
|
||||
msg.should.have.property('angle', 17);
|
||||
msg.should.have.property('reference', 'R');
|
||||
msg.should.have.property('speed', 2.91);
|
||||
msg.should.have.property('units', 'N');
|
||||
msg.should.have.property('status', 'A');
|
||||
});
|
||||
});
|
||||
|
||||
describe('MWV encoding', function () {
|
||||
it('parses ok', function () {
|
||||
var nmeaMsg = require("../nmea.js").encode('XX', {
|
||||
type: 'wind',
|
||||
angle: 17,
|
||||
reference: 'R',
|
||||
speed: 2.91,
|
||||
units: 'N',
|
||||
status: 'A'});
|
||||
nmeaMsg.should.equal("$XXMWV,017.00,R,2.91,N,A*31");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user