diff --git a/.travis.yml b/.travis.yml index df3bb3e..f515d75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: python +python: + - "3.6" install: - pip install tox script: diff --git a/source/c_adc.c b/source/c_adc.c index 21ad284..d496366 100644 --- a/source/c_adc.c +++ b/source/c_adc.c @@ -41,9 +41,9 @@ int adc_initialized = 0; BBIO_err initialize_adc(void) { #ifdef BBBVERSION41 - char test_path[49]; + char test_path[149]; #else - char test_path[40]; + char test_path[140]; #endif FILE *fh; BBIO_err err; @@ -94,10 +94,10 @@ BBIO_err read_value(unsigned int ain, float *value) { FILE * fh; #ifdef BBBVERSION41 - char ain_path[49]; + char ain_path[149]; snprintf(ain_path, sizeof(ain_path), "%s%d_raw", adc_prefix_dir, ain); #else - char ain_path[40]; + char ain_path[140]; snprintf(ain_path, sizeof(ain_path), "%s%d", adc_prefix_dir, ain); #endif diff --git a/source/c_pinmux.c b/source/c_pinmux.c index a315b83..23f1030 100644 --- a/source/c_pinmux.c +++ b/source/c_pinmux.c @@ -9,7 +9,7 @@ BBIO_err set_pin_mode(const char *key, const char *mode) { // char ocp_dir[] defined in common.h - char path[60]; // "/sys/devices/platform/ocp/ocp:P#_##_pinmux/state" + char path[100]; // "/sys/devices/platform/ocp/ocp:P#_##_pinmux/state" char pinmux_dir[20]; // "ocp:P#_##_pinmux" char pin[6]; //"P#_##" FILE *f = NULL; diff --git a/source/c_pwm.c b/source/c_pwm.c index e1f917e..f03e1bd 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -119,7 +119,7 @@ BBIO_err initialize_pwm(void) BBIO_err pwm_set_frequency(const char *key, float freq) { int len; - char buffer[20]; + char buffer[100]; unsigned long period_ns; struct pwm_exp *pwm; @@ -195,7 +195,7 @@ BBIO_err pwm_set_frequency(const char *key, float freq) { // Only works before chip is enabled BBIO_err pwm_set_polarity(const char *key, int polarity) { int len; - char buffer[9]; /* allow room for trailing NUL byte */ + char buffer[100]; /* allow room for trailing NUL byte */ struct pwm_exp *pwm; #ifdef BBBVERSION41 int enabled; /* Maintain original state */ @@ -275,7 +275,7 @@ BBIO_err pwm_set_polarity(const char *key, int polarity) { BBIO_err pwm_set_duty_cycle(const char *key, float duty) { int len; - char buffer[20]; + char buffer[100]; struct pwm_exp *pwm; if (duty < 0.0 || duty > 100.0) @@ -309,17 +309,17 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri struct pwm_exp *new_pwm; #ifdef BBBVERSION41 - char pwm_dev_path[45]; // "/sys/devices/platform/ocp/48300000.epwmss" - char pwm_addr_path[60]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm" - char pwm_chip_path[75]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0" - char pwm_export_path[80]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/export" - char pwm_path[85]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/pwm1" - char pwm_path_udev[85]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/pwm-0:1" - char ecap_path_udev[85];// "/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0/pwm-0:0/" - char duty_path[95]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/pwm1/duty_cycle" - char period_path[95]; - char polarity_path[95]; - char enable_path[90]; + char pwm_dev_path[100]; // "/sys/devices/platform/ocp/48300000.epwmss" + char pwm_addr_path[150]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm" + char pwm_chip_path[200]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0" + char pwm_export_path[250]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/export" + char pwm_path[250]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/pwm2" + char pwm_path_udev[250]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/pwm-0:2" + char ecap_path_udev[300]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ecap/pwm/pwmchip0/pwm-0:0/" + char duty_path[300]; // "/sys/devices/platform/ocp/48300000.epwmss/48300200.ehrpwm/pwm/pwmchip0/pwm2/duty_cycle" + char period_path[300]; + char polarity_path[300]; + char enable_path[300]; char pin_mode[PIN_MODE_LEN]; // "pwm" or "pwm2" int e; @@ -400,7 +400,7 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri snprintf(pwm_path_udev, sizeof(pwm_path_udev), "%s/pwm-%c:%d", pwm_chip_path, pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, pwm_path_udev: %s", key, pwm_path_udev); //ecap output with udev patch - snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, pwm_path[67], p->index); + snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, ecap_path_udev: %s", key, ecap_path_udev); // Export PWM if hasn't already been @@ -456,11 +456,11 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri return BBIO_GEN; } } else { - strncpy(pwm_path, ecap_path_udev, sizeof(ecap_path_udev)); + strncpy(pwm_path, ecap_path_udev, sizeof(pwm_path)); } } } else { - strncpy(pwm_path, pwm_path_udev, sizeof(pwm_path_udev)); + strncpy(pwm_path, pwm_path_udev, sizeof(pwm_path)); usleep(100*1000); } } @@ -470,12 +470,12 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri snprintf(duty_path, sizeof(duty_path), "%s/duty_cycle", pwm_path); snprintf(enable_path, sizeof(enable_path), "%s/enable", pwm_path); #else - char fragment[18]; - char pwm_fragment[20]; - char pwm_path[45]; - char duty_path[56]; - char period_path[50]; - char polarity_path[55]; + char fragment[100]; + char pwm_fragment[100]; + char pwm_path[100]; + char duty_path[200]; + char period_path[100]; + char polarity_path[100]; int period_fd, duty_fd, polarity_fd; if (!pwm_initialized) { @@ -590,7 +590,7 @@ BBIO_err pwm_start(const char *key, float duty, float freq, int polarity) //fprintf(stderr, "Adafruit_BBIO: pwm_start: %s, %f, %f, %i\n", key, duty, freq, polarity); BBIO_err err; - char buffer[20]; + char buffer[100]; ssize_t len; struct pwm_exp *pwm = lookup_exported_pwm(key); @@ -694,7 +694,7 @@ BBIO_err pwm_disable(const char *key) #ifndef BBBVERSION41 BBIO_err err; - char fragment[18]; + char fragment[100]; snprintf(fragment, sizeof(fragment), "bone_pwm_%s", key); err = unload_device_tree(fragment); if (err != BBIO_OK) @@ -709,7 +709,7 @@ BBIO_err pwm_disable(const char *key) { #ifdef BBBVERSION41 - char buffer[2]; + char buffer[100]; size_t len; // Disable the PWM diff --git a/source/common.c b/source/common.c index a22cfe2..cd03bd9 100644 --- a/source/common.c +++ b/source/common.c @@ -636,12 +636,10 @@ BBIO_err load_device_tree(const char *name) { char line[256]; FILE *file = NULL; - + char slots[100]; #ifdef BBBVERSION41 - char slots[41]; snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr"); #else - char slots[40]; build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir)); #endif @@ -698,11 +696,10 @@ BBIO_err load_device_tree(const char *name) int device_tree_loaded(const char *name) { FILE *file = NULL; + char slots[100]; #ifdef BBBVERSION41 - char slots[41]; snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr"); #else - char slots[40]; build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir)); #endif char line[256]; @@ -755,11 +752,10 @@ int device_tree_loaded(const char *name) BBIO_err unload_device_tree(const char *name) { FILE *file = NULL; + char slots[100]; #ifdef BBBVERSION41 - char slots[41]; snprintf(ctrl_dir, sizeof(ctrl_dir), "/sys/devices/platform/bone_capemgr"); #else - char slots[40]; build_path("/sys/devices", "bone_capemgr", ctrl_dir, sizeof(ctrl_dir)); #endif char line[256]; diff --git a/source/py_gpio.c b/source/py_gpio.c index 1f37dda..2721cca 100644 --- a/source/py_gpio.c +++ b/source/py_gpio.c @@ -555,14 +555,14 @@ static PyObject *py_setwarnings(__attribute__ ((unused)) PyObject *self, __attri static const char moduledocstring[] = "GPIO functionality of a BeagleBone using Python"; PyMethodDef gpio_methods[] = { - {"setup", (PyCFunction)py_setup_channel, METH_VARARGS | METH_KEYWORDS, "Set up the GPIO channel, direction and (optional) pull/up down control\nchannel - Either: RPi board pin number (not BCM GPIO 00..nn number). Pins start from 1\n or : BCM GPIO number\ndirection - INPUT or OUTPUT\n[pull_up_down] - PUD_OFF (default), PUD_UP or PUD_DOWN\n[initial] - Initial value for an output channel\n[delay] - Time in milliseconds to wait after exporting gpio pin"}, + {"setup", (PyCFunction)(void *)py_setup_channel, METH_VARARGS | METH_KEYWORDS, "Set up the GPIO channel, direction and (optional) pull/up down control\nchannel - Either: RPi board pin number (not BCM GPIO 00..nn number). Pins start from 1\n or : BCM GPIO number\ndirection - INPUT or OUTPUT\n[pull_up_down] - PUD_OFF (default), PUD_UP or PUD_DOWN\n[initial] - Initial value for an output channel\n[delay] - Time in milliseconds to wait after exporting gpio pin"}, {"cleanup", py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"}, {"output", py_output_gpio, METH_VARARGS, "Output to a GPIO channel\ngpio - gpio channel\nvalue - 0/1 or False/True or LOW/HIGH"}, {"input", py_input_gpio, METH_VARARGS, "Input from a GPIO channel. Returns HIGH=1=True or LOW=0=False\ngpio - gpio channel"}, - {"add_event_detect", (PyCFunction)py_add_event_detect, METH_VARARGS | METH_KEYWORDS, "Enable edge detection events for a particular GPIO channel.\nchannel - either board pin number or BCM number depending on which mode is set.\nedge - RISING, FALLING or BOTH\n[callback] - A callback function for the event (optional)\n[bouncetime] - Switch bounce timeout in ms for callback"}, + {"add_event_detect", (PyCFunction)(void *)py_add_event_detect, METH_VARARGS | METH_KEYWORDS, "Enable edge detection events for a particular GPIO channel.\nchannel - either board pin number or BCM number depending on which mode is set.\nedge - RISING, FALLING or BOTH\n[callback] - A callback function for the event (optional)\n[bouncetime] - Switch bounce timeout in ms for callback"}, {"remove_event_detect", py_remove_event_detect, METH_VARARGS, "Remove edge detection for a particular GPIO channel\ngpio - gpio channel"}, {"event_detected", py_event_detected, METH_VARARGS, "Returns True if an edge has occured on a given GPIO. You need to enable edge detection using add_event_detect() first.\ngpio - gpio channel"}, - {"add_event_callback", (PyCFunction)py_add_event_callback, METH_VARARGS | METH_KEYWORDS, "Add a callback for an event already defined using add_event_detect()\ngpio - gpio channel\ncallback - a callback function\n[bouncetime] - Switch bounce timeout in ms"}, + {"add_event_callback", (PyCFunction)(void *)py_add_event_callback, METH_VARARGS | METH_KEYWORDS, "Add a callback for an event already defined using add_event_detect()\ngpio - gpio channel\ncallback - a callback function\n[bouncetime] - Switch bounce timeout in ms"}, {"wait_for_edge", py_wait_for_edge, METH_VARARGS, "Wait for an edge.\ngpio - gpio channel\nedge - RISING, FALLING or BOTH\ntimeout (optional) - time to wait in miliseconds. -1 will wait forever (default)"}, {"gpio_function", py_gpio_function, METH_VARARGS, "Return the current GPIO function (IN, OUT, ALT0)\ngpio - gpio channel"}, {"setwarnings", py_setwarnings, METH_VARARGS, "Enable or disable warning messages"}, diff --git a/source/py_pwm.c b/source/py_pwm.c index 55f50f9..e5f10f8 100644 --- a/source/py_pwm.c +++ b/source/py_pwm.c @@ -215,10 +215,10 @@ static PyObject *py_set_frequency(__attribute__ ((unused)) PyObject *self, PyObj static const char moduledocstring[] = "PWM functionality of a BeagleBone using Python"; PyMethodDef pwm_methods[] = { - {"start", (PyCFunction)py_start_channel, METH_VARARGS | METH_KEYWORDS, "Set up and start the PWM channel. channel can be in the form of 'P8_10', or 'EHRPWM2A'"}, - {"stop", (PyCFunction)py_stop_channel, METH_VARARGS | METH_KEYWORDS, "Stop the PWM channel. channel can be in the form of 'P8_10', or 'EHRPWM2A'"}, - { "set_duty_cycle", (PyCFunction)py_set_duty_cycle, METH_VARARGS | METH_KEYWORDS, "Change the duty cycle\ndutycycle - between 0.0 and 100.0" }, - { "set_frequency", (PyCFunction)py_set_frequency, METH_VARARGS | METH_KEYWORDS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" }, + {"start", (PyCFunction)(void *)py_start_channel, METH_VARARGS | METH_KEYWORDS, "Set up and start the PWM channel. channel can be in the form of 'P8_10', or 'EHRPWM2A'"}, + {"stop", (PyCFunction)(void *)py_stop_channel, METH_VARARGS | METH_KEYWORDS, "Stop the PWM channel. channel can be in the form of 'P8_10', or 'EHRPWM2A'"}, + { "set_duty_cycle", (PyCFunction)(void *)py_set_duty_cycle, METH_VARARGS | METH_KEYWORDS, "Change the duty cycle\ndutycycle - between 0.0 and 100.0" }, + { "set_frequency", (PyCFunction)(void *)py_set_frequency, METH_VARARGS | METH_KEYWORDS, "Change the frequency\nfrequency - frequency in Hz (freq > 0.0)" }, {"cleanup", py_cleanup, METH_VARARGS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"}, //{"setwarnings", py_setwarnings, METH_VARARGS, "Enable or disable warning messages"}, {NULL, NULL, 0, NULL} diff --git a/source/spimodule.c b/source/spimodule.c index 3b94109..7e438bd 100644 --- a/source/spimodule.c +++ b/source/spimodule.c @@ -777,17 +777,17 @@ PyDoc_STRVAR(SPI_type_doc, "specified SPI device interface.\n"); static PyMethodDef SPI_methods[] = { - {"open", (PyCFunction)SPI_open, METH_VARARGS | METH_KEYWORDS, + {"open", (PyCFunction)(void *)SPI_open, METH_VARARGS | METH_KEYWORDS, SPI_open_doc}, - {"close", (PyCFunction)SPI_close, METH_NOARGS, + {"close", (PyCFunction)(void *)SPI_close, METH_NOARGS, SPI_close_doc}, - {"readbytes", (PyCFunction)SPI_readbytes, METH_VARARGS, + {"readbytes", (PyCFunction)(void *)SPI_readbytes, METH_VARARGS, SPI_read_doc}, - {"writebytes", (PyCFunction)SPI_writebytes, METH_VARARGS, + {"writebytes", (PyCFunction)(void *)SPI_writebytes, METH_VARARGS, SPI_write_doc}, - {"xfer", (PyCFunction)SPI_xfer, METH_VARARGS, + {"xfer", (PyCFunction)(void *)SPI_xfer, METH_VARARGS, SPI_xfer_doc}, - {"xfer2", (PyCFunction)SPI_xfer2, METH_VARARGS, + {"xfer2", (PyCFunction)(void *)SPI_xfer2, METH_VARARGS, SPI_xfer2_doc}, {NULL}, }; diff --git a/tox.ini b/tox.ini index abaae1f..084648a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py27, py34 +envlist = py27, py36 [testenv] commands = echo "run pytest on beaglebone"
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: