Skip to content

Upgrade fw, clear error after timeout#35

Merged
bollenn merged 5 commits intomainfrom
upgrade-fw
Feb 24, 2026
Merged

Upgrade fw, clear error after timeout#35
bollenn merged 5 commits intomainfrom
upgrade-fw

Conversation

@bollenn
Copy link
Collaborator

@bollenn bollenn commented Feb 24, 2026

Upgrade 813x9 fw to v0.29.0, clear error after timeout

Summary by CodeRabbit

  • Bug Fixes

    • PWM controller now throttles repeated error notifications during setup and updates, automatically clears error messages as status polling recovers, and improves status message placement for clearer visibility.
  • Chores

    • Updated latest firmware revisions for select device models to newer supported releases.
  • New Features

    • Bootloader now supports an additional memory type for firmware operations, broadening supported boot memory options.

@bollenn bollenn self-assigned this Feb 24, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Warning

Rate limit exceeded

@bollenn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 0 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 2b1fdac and c744470.

📒 Files selected for processing (1)
  • src/js/usbMcmLin.js
📝 Walkthrough

Walkthrough

Adds transient error-throttling and StatusMessage relocation in the PWM controller; bumps two firmware latest revisions in SystemUpgrade.vue; consolidates bootloader memory type constants into a BTL_MEMORY mapping and uses it in usbMcmLin.js.

Changes

Cohort / File(s) Summary
PWM error-throttling & UI placement
src/views/pwm/PwmController.vue
Adds errorCount state and ERROR_DISPLAY_POLLS; sets throttled error display on setup, duty, and frequency errors; updateStatus decrements errorCount per poll and clears isErrorMsg/errorMsg when it reaches 0; moves StatusMessage placement after the status grid.
Firmware revision bumps
src/views/system/SystemUpgrade.vue
Updates firmwareLatestRev mapping: mcm-81339 and mcm-81349 from v0.28.0v0.29.0 (no other logic changes).
Bootloader memory mapping
src/js/usbMcmLin.js
Replaces separate MEMORY_FLASH/MEMORY_NVRAM constants with BTL_MEMORY = { nvram: 0, flash: 1, flash_cs: 2 }; derives bootload memory type from BTL_MEMORY[memory.toLowerCase()] and updates related comment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I chewed on code and counted sighs,

Ten quiet ticks where error lies,
Firmware hopped to v0.29,
Memory map now neat in line,
I twitch my nose — the build complies!

🚥 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 captures the two main changes: firmware upgrade (in SystemUpgrade.vue bumping fw versions) and error clearing after timeout (in PwmController.vue with errorCount throttling mechanism).
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
  • Commit unit tests in branch upgrade-fw

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.

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/views/pwm/PwmController.vue (1)

34-39: ⚠️ Potential issue | 🟠 Major

errorCount countdown never runs when onMounted setup fails — error message persists forever.

pollTimer = setInterval(updateStatus, 250) is inside the try block (Line 34) and is only reached when the entire setup succeeds. If enableSlavePower() or setup() throws, execution jumps to the catch at Line 35, which sets errorCount = 10 and shows the error message — but pollTimer remains null, so updateStatus is never scheduled. The decrement/clear logic at Lines 90–95 never executes, and the error banner stays on screen until the component is unmounted.

Move pollTimer initialization out of the try block so the countdown runs regardless of whether setup succeeded:

🐛 Proposed fix
 onMounted(async () => {
   try {
     await mcm.enableSlavePower();
     await mcm.setup();

     await updateDutyCycle();
     await updateFrequency();
     await updateStatus();
-
-    pollTimer = setInterval(updateStatus, 250);
   } catch (error) {
     isErrorMsg.value = true;
     errorMsg.value = error.message;
     errorCount = 10;
   }
+
+  pollTimer = setInterval(updateStatus, 250);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/views/pwm/PwmController.vue` around lines 34 - 39, The pollTimer
assignment is inside the try so if enableSlavePower() or setup() throws the
interval never starts and the error banner never auto-clears; move the pollTimer
= setInterval(updateStatus, 250) call out of the try/catch (e.g., start it
before calling enableSlavePower()/setup() or immediately in onMounted regardless
of success) so updateStatus runs even on setup failure and the errorCount
decrement/clear logic (which uses updateStatus) can run; ensure pollTimer is
declared in the same scope as updateStatus and cleared appropriately when
errorCount hits zero or on unmount.
🧹 Nitpick comments (1)
src/views/pwm/PwmController.vue (1)

90-95: else clears error state on every poll tick even when no error is active.

When errorCount === 0 (i.e., normal operation), the else branch unconditionally writes isErrorMsg.value = false and errorMsg.value = '' every 250 ms. Vue 3 short-circuits on same-value primitive writes so this is a no-op for rendering, but the intent is cleaner as a one-time transition when the counter reaches zero:

♻️ Proposed refactor
-  if (errorCount > 0) {
-    errorCount -= 1;
-  } else {
-    isErrorMsg.value = false;
-    errorMsg.value = '';
-  }
+  if (errorCount > 0) {
+    errorCount -= 1;
+    if (errorCount === 0) {
+      isErrorMsg.value = false;
+      errorMsg.value = '';
+    }
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/views/pwm/PwmController.vue` around lines 90 - 95, The else branch is
clearing isErrorMsg.value and errorMsg.value on every poll tick even when
nothing changed; update the logic around errorCount in the polling handler so
you only clear the error state once when the counter transitions to zero (e.g.,
decrement errorCount when > 0, and if that decrement results in 0 then set
isErrorMsg.value = false and errorMsg.value = ''), referencing the existing
errorCount, isErrorMsg.value and errorMsg.value symbols to locate and modify the
code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/views/pwm/PwmController.vue`:
- Around line 34-39: The pollTimer assignment is inside the try so if
enableSlavePower() or setup() throws the interval never starts and the error
banner never auto-clears; move the pollTimer = setInterval(updateStatus, 250)
call out of the try/catch (e.g., start it before calling
enableSlavePower()/setup() or immediately in onMounted regardless of success) so
updateStatus runs even on setup failure and the errorCount decrement/clear logic
(which uses updateStatus) can run; ensure pollTimer is declared in the same
scope as updateStatus and cleared appropriately when errorCount hits zero or on
unmount.

---

Nitpick comments:
In `@src/views/pwm/PwmController.vue`:
- Around line 90-95: The else branch is clearing isErrorMsg.value and
errorMsg.value on every poll tick even when nothing changed; update the logic
around errorCount in the polling handler so you only clear the error state once
when the counter transitions to zero (e.g., decrement errorCount when > 0, and
if that decrement results in 0 then set isErrorMsg.value = false and
errorMsg.value = ''), referencing the existing errorCount, isErrorMsg.value and
errorMsg.value symbols to locate and modify the code.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 606d8ab and a8b8799.

⛔ Files ignored due to path filters (4)
  • public/mcm-81339-v0-28-0.bin is excluded by !**/*.bin
  • public/mcm-81339-v0-29-0.bin is excluded by !**/*.bin
  • public/mcm-81349-v0-28-0.bin is excluded by !**/*.bin
  • public/mcm-81349-v0-29-0.bin is excluded by !**/*.bin
📒 Files selected for processing (2)
  • src/views/pwm/PwmController.vue
  • src/views/system/SystemUpgrade.vue

Coderabitai suggestion to write once
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/views/pwm/PwmController.vue (1)

25-39: ⚠️ Potential issue | 🟠 Major

Error message never clears when onMounted setup fails

When mcm.enableSlavePower() or mcm.setup() throws, the catch block sets errorCount = 10, but pollTimer = setInterval(updateStatus, 250) at line 34 is inside the try block and is never reached. updateStatus — which houses the countdown logic — is therefore never scheduled, so errorCount stays at 10 and the error message is displayed indefinitely. This directly contradicts the PR's stated goal of clearing errors after a timeout.

The simplest consistent fix is to move the setInterval call outside the try/catch so it always starts; updateStatus's polling errors are already silently swallowed, and the countdown will then work identically for all three error sources:

🐛 Proposed fix
 onMounted(async () => {
   try {
     await mcm.enableSlavePower();
     await mcm.setup();

     await updateDutyCycle();
     await updateFrequency();
     await updateStatus();
-
-    pollTimer = setInterval(updateStatus, 250);
   } catch (error) {
     isErrorMsg.value = true;
     errorMsg.value = error.message;
     errorCount = 10;
   }
+
+  pollTimer = setInterval(updateStatus, 250);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/views/pwm/PwmController.vue` around lines 25 - 39, The onMounted
try/catch currently prevents scheduling the status poll when
mcm.enableSlavePower() or mcm.setup() throws, so move the pollTimer =
setInterval(updateStatus, 250) call outside (after) the try/catch block so
updateStatus always runs and can decrement errorCount and clear
isErrorMsg/errorMsg; keep the try/catch to set isErrorMsg.value, errorMsg.value
and errorCount = 10 on failure, and ensure pollTimer, updateStatus, and
setInterval are the same symbols used so the countdown logic runs regardless of
setup success.
🧹 Nitpick comments (1)
src/views/pwm/PwmController.vue (1)

14-14: Extract the magic number 10 into a named constant

errorCount = 10 appears three times (lines 38, 56, 66). Extracting it to a named constant makes the intended timeout duration self-documenting and the only place to update if the poll interval changes.

♻️ Proposed refactor
+const ERROR_DISPLAY_POLLS = 10; // 10 × 250 ms = 2.5 s
 let errorCount = 0;
-    errorCount = 10;
+    errorCount = ERROR_DISPLAY_POLLS;

(apply the same substitution in updateDutyCycle and updateFrequency catch blocks)

Also applies to: 38-38, 56-56, 66-66

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/views/pwm/PwmController.vue` at line 14, Extract the magic number 10 used
to reset errorCount into a named constant (e.g., MAX_POLL_ERRORS or
POLL_ERROR_THRESHOLD) at the top of the module and replace all occurrences where
errorCount is set to 10; update the references in the catch blocks of fetch/poll
logic and in the functions updateDutyCycle and updateFrequency to use that
constant instead of the literal 10 so the threshold is self-documenting and
centralized for future changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/views/pwm/PwmController.vue`:
- Around line 25-39: The onMounted try/catch currently prevents scheduling the
status poll when mcm.enableSlavePower() or mcm.setup() throws, so move the
pollTimer = setInterval(updateStatus, 250) call outside (after) the try/catch
block so updateStatus always runs and can decrement errorCount and clear
isErrorMsg/errorMsg; keep the try/catch to set isErrorMsg.value, errorMsg.value
and errorCount = 10 on failure, and ensure pollTimer, updateStatus, and
setInterval are the same symbols used so the countdown logic runs regardless of
setup success.

---

Nitpick comments:
In `@src/views/pwm/PwmController.vue`:
- Line 14: Extract the magic number 10 used to reset errorCount into a named
constant (e.g., MAX_POLL_ERRORS or POLL_ERROR_THRESHOLD) at the top of the
module and replace all occurrences where errorCount is set to 10; update the
references in the catch blocks of fetch/poll logic and in the functions
updateDutyCycle and updateFrequency to use that constant instead of the literal
10 so the threshold is self-documenting and centralized for future changes.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8b8799 and a8dcec1.

📒 Files selected for processing (1)
  • src/views/pwm/PwmController.vue

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/js/usbMcmLin.js`:
- Around line 4-8: BTL_MEMORY currently maps strings to numeric codes but
invalid or mis-cased `memory` values (e.g., 'Flash_CS') will produce undefined
which coerces to 0 when written into a Uint8Array, silently selecting nvram; fix
by normalizing and validating the lookup: when you compute the mapped value (use
a local like `const memCode = BTL_MEMORY[memory.toLowerCase()]`), check that
memCode is a valid number (e.g., typeof memCode === 'number' and not NaN) before
assembling the payload or writing into the Uint8Array, and if invalid throw or
return an explicit error; update all usages (including the payload assembly site
that writes the memory code into the buffer) to use this guarded `memCode`
variable.

In `@src/views/pwm/PwmController.vue`:
- Around line 36-40: The catch block in the onMounted setup sets
isErrorMsg.value/errorMsg.value and errorCount = ERROR_DISPLAY_POLLS but never
schedules updateStatus because pollTimer is only assigned at the end of the try;
fix by ensuring the countdown runs on error: either (A) in the catch, start a
one-shot timer (e.g., setTimeout) that calls updateStatus (or decrements
errorCount) after the same interval used by pollTimer so the error banner will
clear, or (B) assign pollTimer inside the catch to the same recurring timer used
in the try so updateStatus continues running; update the catch to reference
pollTimer, updateStatus, isErrorMsg, errorMsg, and ERROR_DISPLAY_POLLS
accordingly.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8dcec1 and 2b1fdac.

📒 Files selected for processing (2)
  • src/js/usbMcmLin.js
  • src/views/pwm/PwmController.vue

@bollenn bollenn merged commit 702914d into main Feb 24, 2026
4 of 7 checks passed
@bollenn bollenn deleted the upgrade-fw branch February 24, 2026 19:20
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