Open
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the PDU node firmware (source/pdu/) into smaller, task-oriented modules (switch sensing/control, fault scanning, cooling policy, and telemetry publishing) and removes the legacy auto_switch and cooling implementations.
Changes:
- Introduces new PDU modules:
pdu_state,pdu_switches,pdu_faults,pdu_telemetry, andpdu_cooling(+ optional bang-bang backend). - Updates
source/pdu/main.cto orchestrate initialization and start the new periodic tasks. - Deletes legacy
source/pdu/auto_switch/andsource/pdu/cooling/modules and documents the new layout insource/pdu/README.md.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| source/pdu/pdu_telemetry.h | Declares periodic telemetry publishing entry points. |
| source/pdu/pdu_telemetry.c | Publishes rail/current/temp and flow telemetry over CAN. |
| source/pdu/pdu_switches.h | Defines switch IDs and switch control/sensing APIs. |
| source/pdu/pdu_switches.c | Implements mux sampling + ADC conversions + switch/LED control. |
| source/pdu/pdu_state.h | Defines shared g_pdu_state and cooling command/state structs. |
| source/pdu/pdu_state.c | Initializes shared PDU state defaults. |
| source/pdu/pdu_faults.h | Declares rail fault init/periodic APIs. |
| source/pdu/pdu_faults.c | Implements table-driven nFAULT scanning and fault/LED updates. |
| source/pdu/pdu_cooling_bangbang.h | Adds compile-time toggle and bang-bang cooling API. |
| source/pdu/pdu_cooling_bangbang.c | Implements optional bang-bang cooling updates from motor temps. |
| source/pdu/pdu_cooling.h | Declares cooling init/periodic APIs. |
| source/pdu/pdu_cooling.c | Computes/apply/sends cooling outputs (switches + PWM + CAN). |
| source/pdu/main.c | Wires new modules into init and periodic task schedule; updates heartbeat LED behavior. |
| source/pdu/cooling/cooling.h | Removes legacy cooling interface. |
| source/pdu/cooling/cooling.c | Removes legacy cooling implementation. |
| source/pdu/auto_switch/auto_switch.h | Removes legacy auto-switch interface. |
| source/pdu/auto_switch/auto_switch.c | Removes legacy auto-switch implementation. |
| source/pdu/README.md | Documents responsibilities, module layout, and task model. |
| source/pdu/CMakeLists.txt | No functional change (formatting only). |
Member
|
the files dont need to be named pdu_, they are already in the pdu folder |
irvingywang
reviewed
Apr 13, 2026
irvingywang
reviewed
Apr 14, 2026
| ) | ||
|
|
||
| static float cooling_hottest_motor_temp_c(void) { | ||
| float front_left = can_data.motor_temps.front_left; |
irvingywang
requested changes
Apr 14, 2026
irvingywang
reviewed
Apr 14, 2026
| @@ -0,0 +1,16 @@ | |||
| #ifndef PDU_COOLING_BANGBANG_H | |||
irvingywang
reviewed
Apr 14, 2026
| update_fault(fault->fault_id, is_faulted); | ||
| LED_control(fault->led_id, is_latched(fault->fault_id) ? LED_BLINK : LED_OFF); | ||
|
|
||
| g_pdu_state.next_rail_fault_index = (uint8_t)((index + 1U) % (sizeof(PDU_RAIL_FAULT_MAP) / sizeof(PDU_RAIL_FAULT_MAP[0]))); |
Member
There was a problem hiding this comment.
use if statement instead of modulo
Member
|
cooling should be managed by an FSM |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary