-
-
Notifications
You must be signed in to change notification settings - Fork 15
Additional Label H1 decoding #309
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
Changes from all commits
15b91f6
32f3de5
3b37ca2
70bd680
8e1d16f
a7d544f
8937fbc
3d477d8
c1401bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,21 @@ export class Label_H1 extends DecoderPlugin { | |||||||||||||||||
| decodeResult.message = message; | ||||||||||||||||||
|
|
||||||||||||||||||
| const msg = message.text.replace(/\n|\r/g, ""); | ||||||||||||||||||
| const decoded = H1Helper.decodeH1Message(decodeResult, msg); | ||||||||||||||||||
| const parts = msg.split('#'); | ||||||||||||||||||
| let decoded = false; | ||||||||||||||||||
| if(parts.length === 1) { | ||||||||||||||||||
| decoded = H1Helper.decodeH1Message(decodeResult, msg); | ||||||||||||||||||
| } else if (parts.length == 2) { | ||||||||||||||||||
| const offset = isNaN(parseInt(parts[1][1])) ? 3: 4; | ||||||||||||||||||
| decoded = H1Helper.decodeH1Message(decodeResult, msg.slice(parts[0].length + offset)); // skip up to # and then a little more | ||||||||||||||||||
| if (decoded && parts[0].length > 0) { | ||||||||||||||||||
| // ResultFormatter.unknown(decodeResult, parts[0].substring(0, 4)); | ||||||||||||||||||
|
||||||||||||||||||
| // ResultFormatter.unknown(decodeResult, parts[0].substring(0, 4)); | |
| // TODO: Previously treated the first 4 characters as an unknown field; kept commented out in favor of using flightNumber below. |
Copilot
AI
Jan 30, 2026
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.
Commented-out code should either be removed or explained with a TODO comment if it's temporarily disabled for a specific reason.
| if (decoded && parts[0].length > 0) { | |
| // ResultFormatter.unknown(decodeResult, parts[0].substring(0, 4)); | |
| ResultFormatter.flightNumber(decodeResult, parts[0].substring(4)); | |
| if (decoded && parts[0].length > 0) { | |
| // TODO: Legacy handling of the prefix as an unknown field; kept for reference in case H1 prefix parsing needs to be restored. | |
| // ResultFormatter.unknown(decodeResult, parts[0].substring(0, 4)); | |
| ResultFormatter.flightNumber(decodeResult, parts[0].substring(4)); | |
| // TODO: Legacy handling of the segment after '#' as an unknown field; kept for reference while current parsing relies on remaining.text. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,30 +233,21 @@ describe('Label_H1 FPN', () => { | |
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('partial'); | ||
| expect(decodeResult.raw.message_timestamp).toBe(1708730408); | ||
| expect(decodeResult.raw.flight_number).toBe('KL0767'); | ||
| expect(decodeResult.raw.route_status).toBe('RP'); | ||
| expect(decodeResult.raw.departure_icao).toBe('TNCA'); | ||
| expect(decodeResult.raw.arrival_icao).toBe('TNCB'); | ||
| expect(decodeResult.raw.departure_runway).toBe('11O'); | ||
| expect(decodeResult.raw.procedures.length).toBe(2); | ||
| expect(decodeResult.raw.procedures[0].type).toBe('departure'); | ||
| expect(decodeResult.raw.procedures[0].route.name).toBe('ADRI1F'); | ||
| expect(decodeResult.raw.procedures[1].type).toBe('approach'); | ||
| expect(decodeResult.raw.procedures[1].route.name).toBe('RNV10(10O)'); | ||
| expect(decodeResult.raw.fuel_on_board).toBe(119); | ||
| expect(decodeResult.raw.eta_time).toBe(85448); | ||
| expect(decodeResult.raw.checksum).toBe(0x47c0); | ||
| expect(decodeResult.formatted.description).toBe('Flight Plan'); | ||
| expect(decodeResult.formatted.items.length).toBe(11); | ||
| expect(decodeResult.formatted.items[0].label).toBe('Flight Number'); | ||
| expect(decodeResult.formatted.items[0].value).toBe('KL0767'); | ||
| expect(decodeResult.formatted.items[1].label).toBe('Route Status'); | ||
| expect(decodeResult.formatted.items[1].value).toBe('Route Planned'); | ||
| expect(decodeResult.formatted.items[2].label).toBe('Origin'); | ||
| expect(decodeResult.formatted.items[2].value).toBe('TNCA'); | ||
| expect(decodeResult.formatted.items[3].label).toBe('Destination'); | ||
| expect(decodeResult.formatted.items[3].value).toBe('TNCB'); | ||
| expect(decodeResult.formatted.items[4].label).toBe('Departure Runway'); | ||
| expect(decodeResult.formatted.items[4].value).toBe('11O'); | ||
| expect(decodeResult.formatted.items[5].label).toBe('Departure Procedure'); | ||
| expect(decodeResult.formatted.items[5].value).toBe('ADRI1F: >> IRLEP > A574 >> PJG'); | ||
| expect(decodeResult.formatted.items[6].label).toBe('Approach Procedure'); | ||
| expect(decodeResult.formatted.items[6].value).toBe('RNV10(10O)'); | ||
| expect(decodeResult.formatted.items[7].label).toBe('Arrival Runway'); | ||
| expect(decodeResult.formatted.items[7].value).toBe('10O'); | ||
| expect(decodeResult.formatted.items[8].label).toBe('Fuel On Board'); | ||
| expect(decodeResult.formatted.items[8].value).toBe('119'); | ||
| expect(decodeResult.formatted.items[9].label).toBe('Estimated Time of Arrival'); | ||
| expect(decodeResult.formatted.items[9].value).toBe('23:44:08'); | ||
| expect(decodeResult.formatted.items[10].label).toBe('Message Checksum'); | ||
| expect(decodeResult.formatted.items[10].value).toBe('0x47c0'); | ||
| expect(decodeResult.remaining.text).toBe('F37A#M1B/PR,,110,,183,7,13,,M7,25,,,P30,M40,36090,13,3455,300'); | ||
| }); | ||
|
|
||
|
|
@@ -266,7 +257,37 @@ describe('Label_H1 FPN', () => { | |
|
|
||
| expect(decodeResult.decoded).toBe(false); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('none'); | ||
| expect(decodeResult.formatted.description).toBe('Unknown'); | ||
| expect(decodeResult.message.text).toBe(text); | ||
| }); | ||
|
|
||
| test('decode RM', () => { // TODO: enable | ||
| const text = 'FPN/ID88194A,RCH857,PMZM107QP021/MR2,/RM:AA:FJDG:F:DOH.N300..NOLSU.P307..SETSI.P307..PARAR..N20000E063000..RIGLO.L516..ELKEL.L516..BUMMR/WP,,,,E3E9'; | ||
|
Comment on lines
+264
to
+265
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve the stale TODO on the RM decode test. If you want, I can draft a skip + issue-link pattern here. 🤖 Prompt for AI Agents |
||
| const decodeResult = plugin.decode({ text: text }); | ||
|
|
||
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('partial'); | ||
| expect(decodeResult.raw.tail).toBe('88194A'); | ||
| expect(decodeResult.raw.flight_number).toBe('RCH857'); | ||
| expect(decodeResult.raw.mission_number).toBe('PMZM107QP021'); | ||
| expect(decodeResult.raw.route_status).toBe('RM'); | ||
| expect(decodeResult.raw.arrival_icao).toBe('FJDG'); | ||
| expect(decodeResult.raw.route.waypoints.length).toBe(20); | ||
| expect(decodeResult.raw.route.waypoints[0].name).toBe('DOH'); | ||
| expect(decodeResult.raw.route.waypoints[19].name).toBe('BUMMR'); | ||
| expect(decodeResult.raw.checksum).toBe(0xe3e9); | ||
| expect(decodeResult.formatted.description).toBe('Flight Plan'); | ||
| expect(decodeResult.formatted.items.length).toBe(6); | ||
| expect(decodeResult.message.text).toBe(text); | ||
| }); | ||
|
|
||
| test('Decodes Empty Message', () => { | ||
| const text = 'FPNEEE6'; | ||
| const decodeResult = plugin.decode({ text: text }); | ||
|
|
||
| expect(decodeResult.decoded).toBe(true); | ||
| expect(decodeResult.decoder.decodeLevel).toBe('full'); | ||
| expect(decodeResult.raw.checksum).toBe(0xeee6); | ||
| expect(decodeResult.formatted.items.length).toBe(1); | ||
| }); | ||
| }); | ||
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: 115
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1624
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 50392
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 183
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 15669
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 1580
🏁 Script executed:
Repository: airframesio/acars-decoder-typescript
Length of output: 967
Initialize
remaining.textto an empty string indefaultResult()to avoid concatenating undefined.The
defaultResult()method initializesremainingas an empty object without settingremaining.text. SincedecodeH1Message()does not guaranteeremaining.textis set (especially when checksum validation fails), concatenating it on line 25 will result in"M80/undefined". Either initializeremaining.text = ""indefaultResult()or ensuredecodeH1Message()always sets it.🤖 Prompt for AI Agents