Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/MessageDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class MessageDecoder {
this.registerPlugin(new Plugins.Label_16_N_Space(this));
this.registerPlugin(new Plugins.Label_16_POSA1(this));
this.registerPlugin(new Plugins.Label_16_TOD(this));
this.registerPlugin(new Plugins.Label_1J_2J_FTX(this));
this.registerPlugin(new Plugins.Label_1L_3Line(this));
this.registerPlugin(new Plugins.Label_1L_070(this));
this.registerPlugin(new Plugins.Label_1L_660(this));
Expand All @@ -44,7 +43,6 @@ export class MessageDecoder {
this.registerPlugin(new Plugins.Label_2P_FM3(this));
this.registerPlugin(new Plugins.Label_2P_FM4(this));
this.registerPlugin(new Plugins.Label_2P_FM5(this));
this.registerPlugin(new Plugins.Label_2P_POS(this));
this.registerPlugin(new Plugins.Label_30_Slash_EA(this));
this.registerPlugin(new Plugins.Label_44_ETA(this));
this.registerPlugin(new Plugins.Label_44_IN(this));
Expand All @@ -57,7 +55,6 @@ export class MessageDecoder {
this.registerPlugin(new Plugins.Label_4A_DIS(this));
this.registerPlugin(new Plugins.Label_4A_DOOR(this));
this.registerPlugin(new Plugins.Label_4A_Slash_01(this));
this.registerPlugin(new Plugins.Label_4J_POS(this));
this.registerPlugin(new Plugins.Label_4N(this));
this.registerPlugin(new Plugins.Label_4T_AGFSR(this));
this.registerPlugin(new Plugins.Label_4T_ETA(this));
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/Label_1J_2J_FTX.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { MessageDecoder } from '../MessageDecoder';
import { Label_1J_2J_FTX } from './Label_1J_2J_FTX';
import { Label_H1 } from './Label_H1';

describe('Label 1J/2J FTX', () => {
let plugin: Label_1J_2J_FTX;
let plugin: Label_H1;
let message = { label: '1J', text: '' };

beforeEach(() => {
const decoder = new MessageDecoder();
plugin = new Label_1J_2J_FTX(decoder);
plugin = new Label_H1(decoder);
});

test('decodes Label 1J', () => {
Expand Down
48 changes: 0 additions & 48 deletions lib/plugins/Label_1J_2J_FTX.ts

This file was deleted.

6 changes: 3 additions & 3 deletions lib/plugins/Label_2P_POS.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { MessageDecoder } from '../MessageDecoder';
import { Label_2P_POS } from './Label_2P_POS';
import { Label_H1 } from './Label_H1';

describe('Label_2P Preamble POS', () => {
let plugin: Label_2P_POS;
let plugin: Label_H1;
const message = { label: '2P', text: '' };

beforeEach(() => {
const decoder = new MessageDecoder();
plugin = new Label_2P_POS(decoder);
plugin = new Label_H1(decoder);
});

test('variant 1', () => {
Expand Down
49 changes: 0 additions & 49 deletions lib/plugins/Label_2P_POS.ts

This file was deleted.

16 changes: 3 additions & 13 deletions lib/plugins/Label_4J_POS.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import { MessageDecoder } from '../MessageDecoder';
import { Label_4J_POS } from './Label_4J_POS';
import { Label_H1 } from './Label_H1';

describe('Label 4J POS', () => {
let plugin: Label_4J_POS;
let plugin: Label_H1;
const message = { label: '4J', text: '' };

beforeEach(() => {
const decoder = new MessageDecoder();
plugin = new Label_4J_POS(decoder);
});

test('matches qualifiers', () => {
expect(plugin.decode).toBeDefined();
expect(plugin.name).toBe('label-4j-pos');
expect(plugin.qualifiers).toBeDefined();
expect(plugin.qualifiers()).toEqual({
labels: ['4J'],
preambles: ['POS/'],
});
plugin = new Label_H1(decoder);
});

test('decodes inmarsat', () => {
Expand Down
40 changes: 0 additions & 40 deletions lib/plugins/Label_4J_POS.ts

This file was deleted.

10 changes: 10 additions & 0 deletions lib/plugins/Label_80.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ describe('Label 80', () => {
expect(decodeResult.remaining.text).toBe('3701 INRANG//ERT');
});

test('does not decode INR variant 1', () => {
// decoded by another parser
message.text =
'INR/ID91511S,,/DC04032026,143534/MR19,/NR,,,,,,,,950,0/ET041505/FB983/VR32BF4C';
const decodeResult = plugin.decode(message);

expect(decodeResult.decoded).toBe(false);
expect(decodeResult.decoder.decodeLevel).toBe('none');
});

test('does not decode invalid messages', () => {
message.text = '3N01 POSRPT Bogus message';
const decodeResult = plugin.decode(message);
Expand Down
3 changes: 3 additions & 0 deletions lib/plugins/Label_80.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ export class Label_80 extends DecoderPlugin {
}
private parseCsvFormat(text: string, results: DecodeResult) {
const csvParts = text.split(',');
if(csvParts.length !== 9) {
return;
}
const header = csvParts[0].trim().split(/\s+/);
ResultFormatter.unknown(results, header[0], ' ');
ResultFormatter.unknown(results, header[1], ' ');
Expand Down
32 changes: 32 additions & 0 deletions lib/plugins/Label_80_INR.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { decode } from 'node:punycode';
import { MessageDecoder } from '../MessageDecoder';
import { Label_H1 } from './Label_H1';

describe('Label 80 Preamble INR', () => {
let plugin: Label_H1;
const message = { label: '80', text: '' };

beforeEach(() => {
const decoder = new MessageDecoder();
plugin = new Label_H1(decoder);
});

test('decodes variant 1', () => {
message.text =
'INR/ID91511S,,/DC04032026,143534/MR19,/NR,,,,,,,,950,0/ET041505/FB983/VR32BF4C';
const decodeResult = plugin.decode(message);

expect(decodeResult.decoded).toBe(true);
expect(decodeResult.decoder.decodeLevel).toBe('partial');
expect(decodeResult.raw.tail).toBe('91511S');
expect(decodeResult.raw.message_timestamp).toBe(1772634934);
expect(decodeResult.raw.day).toBe(4);
expect(decodeResult.raw.eta_time).toBe(54300);
expect(decodeResult.raw.fuel_on_board).toBe(983);
expect(decodeResult.raw.version).toBe(3.2);
expect(decodeResult.raw.checksum).toBe(0xbf4c);
expect(decodeResult.formatted.description).toBe('In-Range Report');
expect(decodeResult.formatted.items.length).toBe(6);
expect(decodeResult.remaining.text).toBe('MR19,/NR,,,,,,,,950,0');
});
});
4 changes: 2 additions & 2 deletions lib/plugins/Label_H1.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MessageDecoder } from '../MessageDecoder';
import { Label_H1 } from './Label_H1';

describe('Label_H1 INI', () => {
describe('Label_H1', () => {
let plugin: Label_H1;

beforeEach(() => {
Expand All @@ -14,7 +14,7 @@ describe('Label_H1 INI', () => {
expect(plugin.name).toBe('label-h1');
expect(plugin.qualifiers).toBeDefined();
expect(plugin.qualifiers()).toEqual({
labels: ['H1'],
labels: ['1J', '2J', '2P', '4J', '80', 'H1'],
});
});
});
Loading