From a62a26dae0f7bb1e3e4484ccd59b384bc2763b3f Mon Sep 17 00:00:00 2001 From: Robert Wolterman Date: Fri, 22 Jul 2016 23:27:46 -0500 Subject: [PATCH 1/4] Adding Manifest file for pypi to enable pip installation --- MANIFEST.in | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..50b245a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include distribute_setup.py +include README.rst +include CHANGELOG.rst +recursive-include source *.h +recursive-include overlays *.dts *.py From b180fe1d6f07d9ff524dbc9befe65d1565be2d89 Mon Sep 17 00:00:00 2001 From: Robert Wolterman Date: Sun, 24 Jul 2016 21:37:11 -0500 Subject: [PATCH 2/4] Adding my test code for Issue #14 --- test/spwmtest.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 test/spwmtest.py diff --git a/test/spwmtest.py b/test/spwmtest.py new file mode 100755 index 0000000..7e89595 --- /dev/null +++ b/test/spwmtest.py @@ -0,0 +1,57 @@ +import CHIP_IO.SOFTPWM as SPWM +import CHIP_IO.GPIO as GPIO +import time +import datetime +import threading + +class SPWMReceiver(threading.Thread): + def __init__(self,gpio,key,maxcount=20,sleeptime=0.5): + self.gpio = gpio + self.key = key + self.counter = 0 + self.maxcount = maxcount + self.sleeptime = sleeptime + threading.Thread.__init__(self) + + def run(self): + print("SETTING UP RECEIVER GPIO") + self.gpio.cleanup() + self.gpio.setup(self.key, self.gpio.IN) + print("STARTING RECEIVE LOOP") + try: + while self.counter < self.maxcount: + pwmval = self.gpio.input(self.key) + print("SPWM VALUE: {0} @ {1}".format(pwmval, datetime.datetime.now())) + time.sleep(self.sleeptime) + self.counter += 1 + except KeyboardInterrupt: + self.gpio.cleanup(self.key) + +if __name__ == "__main__": + # SETUP VARIABLES + SPWMGPIO = "XIO-P7" + RECEIVERGPIO = "CSID0" + COUNT = 200 + SLEEPTIME = 0.01 + + # CLEANUP THE GPIO + GPIO.cleanup() + SPWM.cleanup() + + # SETUP SOFTPWM + SPWM.start(SPWMGPIO, 50, 1) + #SPWM.set_frequency(SPWMGPIO, 2) + + # SETUP SOFTPWM RECEIVER + rcvr = SPWMReceiver(GPIO, RECEIVERGPIO, COUNT, SLEEPTIME) + rcvr.start() + + time.sleep(COUNT*SLEEPTIME + 1) + + # CLEANUP + print("CLEANUP") + SPWM.stop(SPWMGPIO) + SPWM.cleanup() + GPIO.cleanup() + + From c3448ec6618d1e6b357c5341c0b4820c2d2c7675 Mon Sep 17 00:00:00 2001 From: "Brady L. Hurlburt" Date: Mon, 25 Jul 2016 14:27:31 +0000 Subject: [PATCH 3/4] Fixes softpwm mutex stallout and assert --- source/c_softpwm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/c_softpwm.c b/source/c_softpwm.c index c794770..08fb10e 100644 --- a/source/c_softpwm.c +++ b/source/c_softpwm.c @@ -101,7 +101,7 @@ int softpwm_set_frequency(const char *key, float freq) { pwm->params.freq = freq; pthread_mutex_unlock(pwm->params_lock); - return 1; + return 0; } int softpwm_set_polarity(const char *key, int polarity) { @@ -274,11 +274,13 @@ int softpwm_start(const char *key, float duty, float freq, int polarity) pwm = pwm->next; pwm->next = new_pwm; } + pthread_mutex_unlock(new_params_lock); ASSRT(softpwm_set_duty_cycle(new_pwm->key, duty) == 0); ASSRT(softpwm_set_frequency(new_pwm->key, freq) == 0); ASSRT(softpwm_set_polarity(new_pwm->key, polarity) == 0); + pthread_mutex_lock(new_params_lock); // create thread for pwm ret = pthread_create(&new_thread, NULL, softpwm_thread_toggle, (void *)new_pwm); ASSRT(ret == 0); From 7e83fa84352415ae1d0d2eb4c543414d6e0d3592 Mon Sep 17 00:00:00 2001 From: Robert Wolterman Date: Mon, 25 Jul 2016 19:38:27 -0500 Subject: [PATCH 4/4] Updating version to 0.1.2, fixing the SoftPWM verification test case --- CHANGELOG.rst | 5 +++++ setup.py | 2 +- source/constants.c | 2 +- test/spwmtest.py | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 32a294f..ea892dd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +0.1.2 +---- +* SoftPWM Fix by aninternetof +* Added a verification test for SoftPWM + 0.1.1 ---- * Some refactoring of the edge detection code, made it function better diff --git a/setup.py b/setup.py index ec17c6b..0e9e334 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ classifiers = ['Development Status :: 3 - Alpha', 'Topic :: System :: Hardware'] setup(name = 'CHIP_IO', - version = '0.1.1', + version = '0.1.2', author = 'Robert Wolterman', author_email = 'robert.wolterman@gmail.com', description = 'A module to control CHIP IO channels', diff --git a/source/constants.c b/source/constants.c index 108713b..7a86c53 100644 --- a/source/constants.c +++ b/source/constants.c @@ -76,6 +76,6 @@ void define_constants(PyObject *module) both_edge = Py_BuildValue("i", BOTH_EDGE); PyModule_AddObject(module, "BOTH", both_edge); - version = Py_BuildValue("s", "0.1.1"); + version = Py_BuildValue("s", "0.1.2"); PyModule_AddObject(module, "VERSION", version); } diff --git a/test/spwmtest.py b/test/spwmtest.py index 7e89595..3c2af43 100755 --- a/test/spwmtest.py +++ b/test/spwmtest.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import CHIP_IO.SOFTPWM as SPWM import CHIP_IO.GPIO as GPIO import time @@ -40,7 +42,7 @@ if __name__ == "__main__": # SETUP SOFTPWM SPWM.start(SPWMGPIO, 50, 1) - #SPWM.set_frequency(SPWMGPIO, 2) + SPWM.set_frequency(SPWMGPIO, 2) # SETUP SOFTPWM RECEIVER rcvr = SPWMReceiver(GPIO, RECEIVERGPIO, COUNT, SLEEPTIME)