Debian 10 (Buster) has gcc 8.2 which warns about:
cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’
The solution is to cast to '(PyCFunction)(void *)'
Debian 10 (Buster) has gcc 8.2 which warns about:
source/c_pwm.c:459:65: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
source/c_pwm.c:396:43: error: ‘%s’ directive output may be truncated writing up to 199 bytes into a region of size 100 [-Werror=format-truncation=]
Debian 10 (Buster) has gcc 8.2 which warns about:
cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’
The solution is to cast to '(PyCFunction)(void *)'
Debian 10 (Buster) has gcc 8.2 which warns about:
error: ‘%s’ directive output may be truncated writing up to 19 bytes into a region of size between 10 and 59 [-Werror=format-truncation=]
snprintf(path, sizeof(path), "%s/%s/state", ocp_dir, pinmux_dir);
Debian 10 (Buster) has gcc 8.2 which warns about:
cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’
The solution is to cast to '(PyCFunction)(void *)'
Rather than returning the error code for UART1 regardless of which
interface had problems, we should return the error code for the
interface that actually had an error.
Pretty sure this was a simple copy-paste mistake.
Use set_pin_mode() to set pinmux for UART
RX and TX pins. This is similar effect as
running the config-pin utility.
Signed-off-by: Drew Fustini <drew@pdp7.com>
PWM.set_frequency() and PWM.set_duty_cycle()
were resulting in a seg fault inside the
call to PyArg_ParseTupleAndKeywords().
Signed-off-by: Drew Fustini <drew@pdp7.com>
Issue #197: JesseMcL raised the issue that running
PWM.start() and PWM.start() in a loop will eventually
exhaust the number of open file descriptors and
PWM.start() will raise the error:
RuntimeError: problem with sysfs file.
The file descriptor for the enable file should
be closed in pwm_disable() to avoid the leak
Signed-off-by: Drew Fustini <drew@pdp7.com>
cache board type to avoid poor performance
in functions that are called frequently like
gpio_set_value() in source/event_gpio.c
Signed-off-by: Drew Fustini <drew@pdp7.com>
sleep 100 ms after export to avoid race condition as udev
needs the opportunity to set group ownership and permission
Test instructions:
==================
reboot, log back in, wait for udev to set group ownership and permission:
$ ls -la /sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip6/export
-rw-rw---- 1 root pwm 4096 Nov 2 04:02 /sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip6/export
run test program:
python ~/issue185.py
contents of test program:
import Adafruit_BBIO.PWM as PWM
PWM.start("P8_13", 50, 1000, 0)
PWM.stop("P8_13")
PWM.cleanup()
Example of pwm and ecap paths for pwm outputs in the 4.14 kernel:
/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0/pwm-0:0/duty_cycle
/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1/pwm-1:0/duty_cycle
/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1/pwm-1:1/duty_cycle
/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm-3:0/duty_cycle
/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm-3:1/duty_cycle
/sys/devices/platform/ocp/48304000.epwmss/48304100.ecap/pwm/pwmchip5/pwm-5:0/duty_cycle
Note that the ecap path is longer than pwm path by 1 character