Skip to content

Adding label 16 AUTPOS decoding#340

Open
makrsmark wants to merge 3 commits intoairframesio:masterfrom
makrsmark:feature/label-16-autpos
Open

Adding label 16 AUTPOS decoding#340
makrsmark wants to merge 3 commits intoairframesio:masterfrom
makrsmark:feature/label-16-autpos

Conversation

@makrsmark
Copy link
Collaborator

@makrsmark makrsmark commented Feb 28, 2026

Summary by CodeRabbit

  • New Features

    • Support for decoding AUTPOS position reports: flight number, coordinates, altitude, wind, temperature, airspeed, and fuel status; includes full and redacted message handling.
  • Improvements

    • Enhanced formatting for total air temperature and message timestamps.
  • Tests

    • Added test coverage for AUTPOS parsing, redacted/full-message decoding, qualifiers, and non-matching input handling.

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

Warning

Rate limit exceeded

@makrsmark has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bf1bbef and fb4b810.

📒 Files selected for processing (1)
  • lib/plugins/Label_16_AUTPOS.ts

Walkthrough

Adds a new Label_16 AUTPOS decoder plugin and test suite, plus two ResultFormatter helpers (totalAirTemp and timestamp) to parse and format AUTPOS position reports, coordinates, timestamps, temperatures, wind, airspeed, and fuel fields.

Changes

Cohort / File(s) Summary
Label 16 AUTPOS Plugin
lib/plugins/Label_16_AUTPOS.ts, lib/plugins/Label_16_AUTPOS.test.ts
New Label_16_AUTPOS decoder implementing qualifiers() and decode(), parsing AUTPOS messages (DMS→decimal coords, altitude, wind, total air temperature, airspeed, Mach, fuel, DAT/TIM→timestamp). Test suite covers qualifiers, redacted/full messages, and non-matching input.
Result Formatter Enhancements
lib/utils/result_formatter.ts
Adds static totalAirTemp() and static timestamp() formatting helpers; integrates total air temperature and message timestamp into DecodeResult items and stores corresponding fields. Minor parsing adjustments for temperature handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Better H1 Parsing #327: Modifies lib/utils/result_formatter.ts by adding formatter methods similar in pattern to the new totalAirTemp/timestamp helpers.

Suggested reviewers

  • kevinelliott
  • andermatt64

Poem

🐇 I nibble bytes and parse the sky’s small maps,
AUTPOS hops in, I stitch degrees to taps,
Winds and temps and fuel I tuck in neat arrays,
Tests clap paws as timestamps find their days,
Hooray — the little plugin bounds and maps the way.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding support for decoding label 16 AUTPOS messages, which is the primary objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@makrsmark
Copy link
Collaborator Author

@SoTi-AF - here you go

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
lib/plugins/Label_16_AUTPOS.test.ts (1)

41-60: Consider adding assertion for outside_air_temperature.

The test verifies total_air_temperature (TAT) but doesn't assert the outside_air_temperature (SAT) field. The message contains SAT -057 which should parse to -57.

💡 Suggested addition
     expect(decodeResult.raw.total_air_temperature).toBe(-27);
+    expect(decodeResult.raw.outside_air_temperature).toBe(-57);
     expect(decodeResult.raw.airspeed).toBe(476);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/plugins/Label_16_AUTPOS.test.ts` around lines 41 - 60, Add an assertion
checking that the SAT value is parsed into outside_air_temperature: after
calling plugin.decode(message) and before checking formatted.items length,
assert that decodeResult.raw.outside_air_temperature equals -57 (parsed from
"SAT -057"); update the test block in Label_16_AUTPOS.test.ts where decodeResult
is used (the test('matches all values') function) to include this new
expectation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/plugins/Label_16_AUTPOS.ts`:
- Around line 111-121: The comment above the DAT/TIM parsing is wrong: DAT is
actually in YYMMDD (e.g., 260228 -> 2026-02-28), but the code slices dat into yy
= dat.slice(0,2), mm = dat.slice(2,4), dd = dat.slice(4,6) and then builds
mmddyy for DateTimeUtils.convertDateTimeToEpoch; update the comment to state
"DAT is YYMMDD, TIM is HHMMSS" (or similar) so it matches the parsing logic in
this block that calls ResultFormatter.timestamp and
DateTimeUtils.convertDateTimeToEpoch(tim, mmddyy). Ensure the comment explicitly
notes convertDateTimeToEpoch expects MMDDYY.
- Around line 7-14: The plugin class Label_16_AUTPOS is not exported from the
central plugins export module, so MessageDecoder never registers it; fix this by
adding an export for the Label_16_AUTPOS plugin in the same central plugins
export file alongside the other Label_16 variants so it follows the same export
pattern and will be picked up by MessageDecoder.decode().

In `@lib/utils/result_formatter.ts`:
- Around line 309-318: The change renaming the formatted item type from
'outside_air_temperature' to 'temperature' breaks existing tests that expect
decodeResult.formatted.items[*].type === 'outside_air_temperature'; revert the
type value in the object pushed in result_formatter.ts so it remains
'outside_air_temperature', or if you intentionally want the new value, update
all test expectations (e.g., in Label_H1_POS.test.ts and Label_21_POS.test.ts)
and any other code that matches on decodeResult.formatted.items[].type to use
'temperature' instead; ensure you update every occurrence of the type string and
run the test suite to confirm no other consumers rely on the old value.

---

Nitpick comments:
In `@lib/plugins/Label_16_AUTPOS.test.ts`:
- Around line 41-60: Add an assertion checking that the SAT value is parsed into
outside_air_temperature: after calling plugin.decode(message) and before
checking formatted.items length, assert that
decodeResult.raw.outside_air_temperature equals -57 (parsed from "SAT -057");
update the test block in Label_16_AUTPOS.test.ts where decodeResult is used (the
test('matches all values') function) to include this new expectation.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86acd6f and 3b985d0.

📒 Files selected for processing (3)
  • lib/plugins/Label_16_AUTPOS.test.ts
  • lib/plugins/Label_16_AUTPOS.ts
  • lib/utils/result_formatter.ts

Comment on lines +7 to +14
export class Label_16_AUTPOS extends DecoderPlugin {
name = 'label-16-autpos';
qualifiers() {
return {
labels: ['16'],
preambles: [''],
};
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if Label_16_AUTPOS is registered in MessageDecoder
rg -n "Label_16_AUTPOS" lib/MessageDecoder.ts

# List all registered Label_16 plugins for comparison
rg -n "Label_16" lib/MessageDecoder.ts

Repository: airframesio/acars-decoder-typescript

Length of output: 331


🏁 Script executed:

#!/bin/bash
# Check if Label_16_AUTPOS.ts file exists
ls -la lib/plugins/Label_16_AUTPOS.ts

# Check if it's exported from the Plugins index/module
rg -n "Label_16_AUTPOS" lib/plugins/

Repository: airframesio/acars-decoder-typescript

Length of output: 487


🏁 Script executed:

#!/bin/bash
# Check how plugins are imported in MessageDecoder.ts
head -20 lib/MessageDecoder.ts

# Check if there's an index/barrel export in plugins directory
cat lib/plugins/index.ts 2>/dev/null || ls -la lib/plugins/*.ts | grep -i index

Repository: airframesio/acars-decoder-typescript

Length of output: 611


🏁 Script executed:

#!/bin/bash
# Check plugins/official.ts for Label_16_AUTPOS export
rg -n "Label_16_AUTPOS|export" lib/plugins/official.ts | head -50

Repository: airframesio/acars-decoder-typescript

Length of output: 1836


🏁 Script executed:

#!/bin/bash
# Get the full plugins/official.ts file to check for Label_16_AUTPOS
wc -l lib/plugins/official.ts
# Check if Label_16_AUTPOS appears anywhere in the file
rg "Label_16_AUTPOS" lib/plugins/official.ts

Repository: airframesio/acars-decoder-typescript

Length of output: 106


Plugin not exported from official plugins module.

The Label_16_AUTPOS plugin is not exported from lib/plugins/official.ts and therefore not registered in MessageDecoder.ts. The plugin class exists but won't be invoked when decoding messages through the main MessageDecoder.decode() API. Add the export line to lib/plugins/official.ts alongside the other Label_16 variants (lines 11-14):

export * from './Label_16_AUTPOS';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/plugins/Label_16_AUTPOS.ts` around lines 7 - 14, The plugin class
Label_16_AUTPOS is not exported from the central plugins export module, so
MessageDecoder never registers it; fix this by adding an export for the
Label_16_AUTPOS plugin in the same central plugins export file alongside the
other Label_16 variants so it follows the same export pattern and will be picked
up by MessageDecoder.decode().

Comment on lines 111 to 121
if (!dat.includes('*') && !tim.includes('*')) {
// DAT is DDMMYY, TIM is HHMMSS
// DateTimeUtils.convertDateTimeToEpoch expects MMDDYY
const yy = dat.slice(0, 2);
const mm = dat.slice(2, 4);
const dd = dat.slice(4, 6);
const mmddyy = `${mm}${dd}${yy}`;
ResultFormatter.timestamp(
decodeResult,
DateTimeUtils.convertDateTimeToEpoch(tim, mmddyy),
);
Copy link

@coderabbitai coderabbitai bot Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Date format comment is incorrect; actual format appears to be YYMMDD.

The comment states DAT is DDMMYY, but the code extracts yy = dat.slice(0, 2), mm = dat.slice(2, 4), dd = dat.slice(4, 6), which treats the format as YYMMDD. Based on the test case where 260228 produces a timestamp for Feb 28, 2026, the actual format is YYMMDD.

📝 Proposed fix
     if (!dat.includes('*') && !tim.includes('*')) {
-      // DAT is DDMMYY, TIM is HHMMSS
+      // DAT is YYMMDD, TIM is HHMMSS
       // DateTimeUtils.convertDateTimeToEpoch expects MMDDYY
       const yy = dat.slice(0, 2);
       const mm = dat.slice(2, 4);
       const dd = dat.slice(4, 6);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!dat.includes('*') && !tim.includes('*')) {
// DAT is DDMMYY, TIM is HHMMSS
// DateTimeUtils.convertDateTimeToEpoch expects MMDDYY
const yy = dat.slice(0, 2);
const mm = dat.slice(2, 4);
const dd = dat.slice(4, 6);
const mmddyy = `${mm}${dd}${yy}`;
ResultFormatter.timestamp(
decodeResult,
DateTimeUtils.convertDateTimeToEpoch(tim, mmddyy),
);
if (!dat.includes('*') && !tim.includes('*')) {
// DAT is YYMMDD, TIM is HHMMSS
// DateTimeUtils.convertDateTimeToEpoch expects MMDDYY
const yy = dat.slice(0, 2);
const mm = dat.slice(2, 4);
const dd = dat.slice(4, 6);
const mmddyy = `${mm}${dd}${yy}`;
ResultFormatter.timestamp(
decodeResult,
DateTimeUtils.convertDateTimeToEpoch(tim, mmddyy),
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/plugins/Label_16_AUTPOS.ts` around lines 111 - 121, The comment above the
DAT/TIM parsing is wrong: DAT is actually in YYMMDD (e.g., 260228 ->
2026-02-28), but the code slices dat into yy = dat.slice(0,2), mm =
dat.slice(2,4), dd = dat.slice(4,6) and then builds mmddyy for
DateTimeUtils.convertDateTimeToEpoch; update the comment to state "DAT is
YYMMDD, TIM is HHMMSS" (or similar) so it matches the parsing logic in this
block that calls ResultFormatter.timestamp and
DateTimeUtils.convertDateTimeToEpoch(tim, mmddyy). Ensure the comment explicitly
notes convertDateTimeToEpoch expects MMDDYY.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect. the code is corect

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makrsmark, I apologize for any confusion. To clarify, I was pointing out that the comment text on line 111 states // DAT is DDMMYY, but the code logic parses it as YYMMDD (year-month-day). The code itself is correct—I was suggesting updating only the comment to match what the code does.

However, if you feel the comment is fine as-is or prefer to keep it, that's perfectly okay. I'll defer to your judgment on this.


🧠 Learnings used
Learnt from: makrsmark
Repo: airframesio/acars-decoder-typescript PR: 332
File: lib/plugins/Label_H1.ts:39-40
Timestamp: 2026-02-21T01:32:05.328Z
Learning: In lib/plugins/Label_H1.ts, when parsing two-part H1 messages (split by '#'), the offset logic `parts[0] === '- ' || isNaN(parseInt(parts[1][1])) ? 3 : 4` is correct. The `parts[0] === '- '` condition ensures that messages like '- `#M1FPN/`...' use offset=3 to skip 3 characters after '#' ('M1' + next char), whereas messages like 'F37AKL0767#M1BFPN/...' use offset=4 to skip 4 characters ('M1B' + '/'). Removing the `parts[0] === '- '` check would break '- `#M1`...' messages where parts[1][1] is numeric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant