PyEval_ThreadsInitialized() and PyEval_InitThreads() are deprecated and break the build, adding a version check to ignore if we are compiling with a newer Python version.
PWM outputs on P9_28 and P9_42 are part of the ECAP hardware block. This causes 'ecap' to be in the path instead of 'pwm'. For example:
`/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0/pwm0`
is one character longer than:
`/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip4/pwm0`
Thus the index in pwm_path must be adjusted for the ecap_path_udev path. This fixes issue #342
Building with GCC 10.2.1 fails due linking errors caused by having multiple
definitions of the variables defined in the source/constants.h header file.
Fix this by moving the variables definition to the source/constants.c file,
to avoid the variables to be defined each time that the header is included.
While being there, use a single variable instead of having one for each
object that is added to the module.
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()