-
-
Notifications
You must be signed in to change notification settings - Fork 15
Additional H1 Decoding #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
makrsmark
merged 1 commit into
airframesio:master
from
makrsmark:feature/h1-ldi-inmarsat
Feb 21, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import { MessageDecoder } from '../MessageDecoder'; | ||
| import { Label_H1 } from './Label_H1'; | ||
|
|
||
| describe('Label H1 LDI', () => { | ||
| let plugin: Label_H1; | ||
| const message = { label: 'H1', text: '' }; | ||
|
|
||
| beforeEach(() => { | ||
| const decoder = new MessageDecoder(); | ||
| plugin = new Label_H1(decoder); | ||
| }); | ||
|
|
||
| test('decodes variant 2', () => { | ||
| message.text = | ||
| 'LDI/RW27R,,,,,M160,1676,,,,202003,2,,,,P8,137147150,0,,M160,,146149150,P48,2,2.27L,,,,,M160,1676,,,,202003,2,,,,P8,137147150,0,,M160,,147150151,P52,2,2.35O,,,,,M160,1676,,,,202003,2,,,,P8,127133138,0,,,,,,3:KPHL,H1007,1036,1036,1036/CG225/SN69EAE8'; | ||
| const decodeResult = plugin.decode(message); | ||
|
|
||
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('partial'); | ||
| expect(decodeResult.raw.departure_icao).toBe('KPHL'); | ||
| expect(decodeResult.raw.departure_runway).toBe('27R'); | ||
| expect(decodeResult.raw.center_of_gravity).toBe(22.5); | ||
| expect(decodeResult.raw.checksum).toBe(0xeae8); | ||
| expect(decodeResult.formatted.description).toBe( | ||
| 'Load Distribution Information', | ||
| ); | ||
| expect(decodeResult.formatted.items.length).toBe(4); | ||
| expect(decodeResult.remaining.text).toBe( | ||
| ',,,,M160,1676,,,,202003,2,,,,P8,137147150,0,,M160,,146149150,P48,2,2.27L,,,,,M160,1676,,,,202003,2,,,,P8,137147150,0,,M160,,147150151,P52,2,2.35O,,,,,M160,1676,,,,202003,2,,,,P8,127133138,0,,,,,,3,H1007,1036,1036,1036', | ||
| ); | ||
| }); | ||
|
|
||
| test('decodes variant 1', () => { | ||
| message.text = | ||
| 'LDI/RW16L,,,,,,1552,,P4,D7,164008,1,1,0,,P60,155159161:,,800,800,800/CG2356485'; | ||
| const decodeResult = plugin.decode(message); | ||
|
|
||
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('partial'); | ||
| expect(decodeResult.raw.departure_runway).toBe('16L'); | ||
| expect(decodeResult.raw.center_of_gravity).toBe(23.5); | ||
| expect(decodeResult.raw.checksum).toBe(0x6485); | ||
| expect(decodeResult.formatted.description).toBe( | ||
| 'Load Distribution Information', | ||
| ); | ||
| expect(decodeResult.formatted.items.length).toBe(4); | ||
| expect(decodeResult.remaining.text).toBe( | ||
| ',,,,,1552,,P4,D7,164008,1,1,0,,P60,155159161.,,800,800,800', | ||
| ); | ||
| }); | ||
|
|
||
| test('decodes response', () => { | ||
| message.text = 'RESLDI/AK,7151B9'; | ||
| const decodeResult = plugin.decode(message); | ||
|
|
||
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('partial'); | ||
| expect(decodeResult.raw.checksum).toBe(0x51b9); | ||
| expect(decodeResult.formatted.description).toBe( | ||
| 'Response for Load Distribution Information', | ||
| ); | ||
| expect(decodeResult.formatted.items.length).toBe(1); | ||
| expect(decodeResult.remaining.text).toBe('AK,71'); | ||
| }); | ||
|
|
||
| test('decodes request', () => { | ||
| message.text = '#MDREQLDI57CC'; | ||
| const decodeResult = plugin.decode(message); | ||
|
|
||
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('full'); | ||
| expect(decodeResult.raw.checksum).toBe(0x57cc); | ||
| expect(decodeResult.formatted.description).toBe( | ||
| 'Request for Load Distribution Information', | ||
| ); | ||
| expect(decodeResult.formatted.items.length).toBe(1); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 105
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 723
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 62
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1329
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 744
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 4285
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 9786
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 2431
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 62
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 62
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 4289
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 4625
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 593
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 110
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1532
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 879
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1064
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1502
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 484
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 841
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 190
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1853
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 729
Remove the redundant
parts[0] === '- 'condition that introduces a latent offset bug.For all currently tested
'-#MD...'messages, the second character is'D'(non-numeric), soisNaN(parseInt('D'))already returnstrueand produces the correctoffset = 3. The newparts[0] === '- 'clause adds no value for known cases.However, it creates a latent bug: if a
'-#M1B...'or'-#T1B...'message is ever encountered, the condition forcesoffset = 3(incorrect) instead of the proper4. For example, with'-#M1BFTX/...', slicing at2 + 3 = 5yields'BFTX/...'(includes trailingB), while correct offset of 4 would yield'FTX/...'.The inline comment already acknowledges this approach is fragile. Remove the redundant clause:
♻️ Suggested simplification
📝 Committable suggestion
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the suggestion does not work for the example that is
- #M1FPN...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 404
🏁 Script executed:
Length of output: 404
🏁 Script executed:
Length of output: 3158
🏁 Script executed:
Length of output: 27333
@makrsmark, you're absolutely right—thank you for the correction! My analysis was incorrect.For a message like
'-#M1FPN/...':parts[0] = '- 'andparts[1][1] = '1'(numeric)parts[0] === '- 'returnstrue→offset = 3→msg.slice(2+3)skips'-#M1'→ correctly decodes'FPN/...'isNaN(parseInt('1'))returnsfalse→offset = 4→msg.slice(2+4)skips'-#M1F'→ incorrectly decodes'PN/...'The current logic is correct: when the prefix is
'- ', the offset should always be3(to skip the 3 characters after#), regardless of whetherparts[1][1]is numeric. My suggestion would break this case.I apologize for the confusion! The
parts[0] === '- 'condition is necessary, not redundant.🧬 Code Graph Analysis Results
File: lib/utils/result_formatter.ts
static flightNumber(decodeResult: DecodeResult, value: string) {
if (value.length === 0) {
return;
}
decodeResult.raw.flight_number = value;
decodeResult.formatted.items.push({
type: 'flight_number',
code: 'FLIGHT',
label: 'Flight Number',
value: decodeResult.raw.flight_number,
});
}
File: lib/utils/h1_helper.ts
Class: H1Helper
File: lib/DecoderPluginInterface.ts
export interface Message {
label: string;
sublabel?: string;
text: string;
}
export interface Options {
debug?: boolean;
}
export interface DecodeResult {
decoded: boolean;
decoder: {
name: string;
type: 'pattern-match' | 'none';
decodeLevel: 'none' | 'partial' | 'full';
};
error?: string;
formatted: {
description: string;
items: {
type: string;
code: string;
label: string;
value: string;
}[];
};
message?: Message;
raw: any; // eslint-disable-line
@typescript-eslint/no-explicit-anyremaining: {
text?: string;
};
}
File: lib/DecoderPluginInterface.ts
#M1FPN..." might not be parsed as expected.✏️ Learnings added
🧠 Learnings used