Skip to content

Conversation

@avion23
Copy link

@avion23 avion23 commented Jun 29, 2025

Input Validation for Safety

Adds validation to prevent out-of-range values from being written to hardware DACs.

Changes

  • protocol_handler.c: Validate parsed command values before processing
  • pwrctl.c: Add bounds checking (65V max input, 60V max output, 20A max current)
  • opendps.c: Validate calibration coefficients (current ADC gain: 0.1-100.0f)

Behavior

  • Invalid commands return error response
  • Hardware limits prevent unsafe DAC writes
  • Device maintains last valid state on invalid input

Prevents potential hardware damage from malformed commands or invalid calibration data.

@avion23 avion23 force-pushed the safety-input-validation branch 2 times, most recently from ccbbe65 to 99c65f1 Compare June 29, 2025 18:08
Incoming setpoint commands for voltage and current from the host were not validated before being used by the power control module. This created a safety risk where a malformed or out-of-range value could be written directly to the hardware DACs. This could result in an output voltage/current that exceeds the device's safe operating area, potentially damaging the OpenDPS unit or the connected load. This commit introduces range checks in the following places: - protocol_handler.c: Validates parsed values from serial commands are within maximum theoretical device limits - pwrctl.c: Clamps final values before writing to hardware registers as final safety guarantee - opendps.c: Adds calibration coefficient validation to prevent malicious or accidental dangerous calibration values If an invalid value is received, an error response is sent to the host and the setpoint is rejected, maintaining the last known-good state.
@avion23 avion23 force-pushed the safety-input-validation branch from 99c65f1 to ee5c343 Compare July 14, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant