Fix 'A PWM object already exists for this GPIO channel' exception #504
Reference in New Issue
Block a user
Delete Branch "fix-pwm_exception"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously, the
configure_gpiomethod removed PWM entries from thepwm_instanceslist without first stopping the actual PWM signal on the corresponding GPIO pin. As a result, reconfiguring a pin that already had an active PWM object triggered the exception:A PWM object already exists for this GPIO channel.This exception caused the plugin to crash, leading to broken GPIO functionality such as unresponsive buttons or failure to turn off the heater when the target temperature was reached.
This patch addresses the issue by explicitly stopping all active PWM instances associated with a given pin before removing them from the pwm_instances list.
It's important to note that we collect all matching instances first and remove them only after they’ve been stopped. This ensures proper handling of scenarios where multiple PWM instances are associated with the same GPIO pin.
Fix #335, fix #236.