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:
24
test/VTGtest.js
Normal file
24
test/VTGtest.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var should = require('should');
|
||||
|
||||
describe('VTG parsing', function () {
|
||||
it('parses ok', function () {
|
||||
var msg = require("../nmea.js").parse("$IIVTG,210.43,T,210.43,M,5.65,N,,,A*67");
|
||||
msg.should.have.property('sentence', 'VTG');
|
||||
msg.should.have.property('type', 'track-info');
|
||||
msg.should.have.property('trackTrue', 210.43);
|
||||
msg.should.have.property('trackMagnetic', 210.43);
|
||||
msg.should.have.property('speedKnots', 5.65);
|
||||
});
|
||||
});
|
||||
|
||||
describe('VTG encoding', function () {
|
||||
it('encodes ok', function () {
|
||||
var nmeaMsg = require("../nmea.js").encode('XX', {
|
||||
type: 'track-info',
|
||||
trackTrue: 210.43,
|
||||
trackMagnetic: 209.43,
|
||||
speedKnots: 2.91
|
||||
});
|
||||
nmeaMsg.should.equal("$XXVTG,210.43,T,209.43,M,2.91,N,,,A*63");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user