EdgePi-Cloud / edgepi-python-sdk

Python SDK to control EdgePi, an industrial PC/PLC/IoT device powered by Raspberry Pi CM4
MIT License
5 stars 3 forks source link

Resolve ambiguity in PWM module #406

Open josiah-tesfu opened 9 months ago

josiah-tesfu commented 9 months ago

In the PWM module, a few functions must be executed in a specific order before continuing. Specifically, init_pwm must be called and followed by set_config, which itself requires that all configurations are set. After this, functions can be called normally (and set_config can be called with any number of parameters).

This is logical to someone familiar with PWM. However, since failling to do so causes ambiguous error messages that don't point to the cause, more documentation should be provided. In addition to better documentation, we might consider enhancing error messages to be clearer, especially for set_config. For example, when functions (like enable) were called after set_config was not configurated with all parameters, an exception triggered with the message "PWM closed unexpectedly." This is ambiguous and doesn't give any hint as to the source of the error.