From 79a7aaaa96c62566ca21b2928025f0141519caeb Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Thu, 14 Mar 2013 15:45:33 +0100 Subject: [PATCH] RPIO v0.10.0 * Auto-cleanup on exit (also shuts down ``wait_for_interrupts(threaded=True)``) * Bugfix in cpuinfo.c: correctly trim over-voltage header * rpio-curses: help shows raspberry sysinfo * switched argument ordering of wait_for_interrupts to (``wait_for_interrupts(threaded=False, epoll_timeout=1)``) * Added ``RPIO.Exceptions`` --- README.rst | 1 + VERSION | 1 + debian/changelog | 27 +++++---------- documentation/source/conf.py | 2 +- documentation/source/index.rst | 12 +++++-- documentation/source/rpio_py.rst | 56 ++++++++++++++++++++----------- examples/example1_interrupts.py | 19 +++++------ examples/example2_gpio.py | 4 +++ examples/example3_pwm_servo.py | 11 +++--- examples/example4_pwm_lowlevel.py | 6 +++- fabfile.py | 14 ++++---- setup.py | 4 +-- source/RPIO/Exceptions.py | 34 +++++++++++++++++++ source/RPIO/_RPIO.py | 25 +++++++++----- source/RPIO/__init__.py | 41 +++++++++++----------- source/c_gpio/cpuinfo.c | 2 +- source/c_gpio/py_gpio.c | 18 +++++----- source/c_pwm/pwm_py.c | 2 +- source/scripts/man/rpio.1 | 2 +- source/scripts/rpio | 1 - source/scripts/rpio-curses | 2 ++ version_update.sh | 49 ++++++++++++++------------- 22 files changed, 199 insertions(+), 134 deletions(-) create mode 100644 VERSION create mode 100644 source/RPIO/Exceptions.py diff --git a/README.rst b/README.rst index 52efdb9..2020494 100644 --- a/README.rst +++ b/README.rst @@ -67,3 +67,4 @@ Links * http://pypi.python.org/pypi/RPi.GPIO * http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf * http://www.kernel.org/doc/Documentation/gpio.txt +* `semver versioning standard `_ \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..78bc1ab --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.10.0 diff --git a/debian/changelog b/debian/changelog index 037206e..1699a24 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,25 +1,16 @@ -rpio (0.9.6) unstable; urgency=low - - * RC 0.9.5 had critical bugs. Fixed now. - - -- Chris Hager Wed, 13 Mar 2013 21:30:14 +0100 - -rpio (0.9.5) unstable; urgency=low +rpio (0.10.0) unstable; urgency=low - * Cleanup + * Auto-cleanup on exit (also shuts down ``wait_for_interrupts(threaded=True)``) + * Bugfix in cpuinfo.c: correctly trim over-voltage header + * rpio-curses: help shows raspberry sysinfo + * switched argument ordering of wait_for_interrupts to (``wait_for_interrupts(threaded=False, epoll_timeout=1)``) - -- Chris Hager Wed, 13 Mar 2013 02:24:08 +0100 + -- Chris Hager Thu, 14 Mar 2013 15:42:59 +0100 -rpio (0.9.4) unstable; urgency=low +rpio (0.9.6) unstable; urgency=low - * Debounce timeout for interrupts (Closes: #XXXXXX) + * Debounce timeout for interrupts * Threaded argument for wait_for_interrupts() * Refactoring - -- Chris Hager Tue, 12 Mar 2013 22:34:04 +0100 - -rpio (0.9.2) unstable; urgency=low - - * Initial PWM release. (Closes: #XXXXXX) - - -- Chris Hager Tue, 12 Mar 2013 17:59:56 +0100 + -- Chris Hager Wed, 13 Mar 2013 21:30:14 +0100 diff --git a/documentation/source/conf.py b/documentation/source/conf.py index 31afbe1..e29ede1 100644 --- a/documentation/source/conf.py +++ b/documentation/source/conf.py @@ -48,7 +48,7 @@ # built documents. # # The short X.Y version. -version = '0.9.6' +version = '0.10.0' # The full version, including alpha/beta/rc tags. release = version diff --git a/documentation/source/index.rst b/documentation/source/index.rst index 81e5c25..afa4a81 100644 --- a/documentation/source/index.rst +++ b/documentation/source/index.rst @@ -58,7 +58,7 @@ Or from Github but without Git:: $ cd RPIO-master $ sudo python setup.py install -Debian packages are available at `metachris.github.com/rpio/download `_. +Debian packages are available at `metachris.github.com/rpio/download `_. After the installation you can use ``import RPIO`` as well as the command-line tool ``rpio``. @@ -84,6 +84,7 @@ Links * http://pypi.python.org/pypi/RPi.GPIO * http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf * http://www.kernel.org/doc/Documentation/gpio.txt +* `semver versioning standard `_ License & Copyright @@ -112,6 +113,13 @@ License & Copyright Changes ------- +* v0.10.0 + + * Auto-cleanup on exit (also shuts down ``wait_for_interrupts(threaded=True)``) + * Bugfix in cpuinfo.c: correctly trim over-voltage header + * rpio-curses: help shows raspberry sysinfo + * switched argument ordering of wait_for_interrupts to (``wait_for_interrupts(threaded=False, epoll_timeout=1)``) + * v0.9.6 * Added ``debounce_timeout_ms`` argument to ``RPIO.add_interrupt_callback(..)`` @@ -121,7 +129,7 @@ Changes * Added ``RPIO.close_tcp_client(fileno)`` * Debian .deb package builds * License changed to GNU Lesser General Public License v3 or later (LGPLv3+) - * ``RPIO.sysinfo()`` returns is_overclocked (improved detection in cpuinfo.c) + * Improved detection in cpuinfo.c * v0.9.1 diff --git a/documentation/source/rpio_py.rst b/documentation/source/rpio_py.rst index 6b3cf72..06f82ef 100644 --- a/documentation/source/rpio_py.rst +++ b/documentation/source/rpio_py.rst @@ -17,8 +17,21 @@ GPIO & TCP Interrupts --------------------- ``RPIO`` can listen for two kinds of interrupts: ``GPIO`` and ``TCP``. GPIO interrupts happen -when the state on a specific GPIO input changes. TCP interrupts happen when a TCP client -connects to the built-in TCP server and sends a message. +when the state on a specific GPIO input changes. TCP interrupts happen when a TCP socket client +sends a message. + + +.. method:: RPIO.wait_for_interrupts(threaded=False, epoll_timeout=1) + + This is the main blocking loop which, while active, will listen for interrupts and start + your custom callbacks. At some point in your script you need to start this to receive interrupt + callbacks. This blocking method is perfectly suited as "the endless loop that keeps your script + running". + + With the argument ``threaded=True``, this method starts in the background while your script + continues in the main thread (RPIO will automatically shut down the thread when your script exits):: + + RPIO.wait_for_interrupts(threaded=True) .. _ref-rpio-py-interrupts: @@ -33,12 +46,16 @@ or pull-down resistor. .. method:: RPIO.add_interrupt_callback(gpio_id, callback, edge='both', pull_up_down=RPIO.PUD_OFF, threaded_callback=False, debounce_timeout_ms=None) - Adds a callback to receive notifications when a GPIO changes it's value. Possible ``pull_up_down`` values are - ``RPIO.PUD_UP``, ``RPIO.PUD_DOWN`` and ``RPIO.PUD_OFF`` (default). Possible edges are ``rising``, - ``falling`` and ``both`` (default). The values passed to the callback are of type integer, and either ``0`` or ``1``. - A callback might look like this: ``def gpio_callback(gpio_id, value):``. + Adds a callback to receive notifications when a GPIO changes it's state from 0 to 1 or vice versa. - If ``debounce_timeout_ms`` is set, interrupt callbacks will not be started until the specified milliseconds have passed since the last interrupt. Adjust this to your needs (typically between 10ms and 100ms). + * Possible edges are ``rising``, ``falling`` and ``both`` (default). + * Possible ``pull_up_down`` values are ``RPIO.PUD_UP``, ``RPIO.PUD_DOWN`` and ``RPIO.PUD_OFF`` (default). + * If ``threaded_callback`` is ``True``, the callback will be started inside a thread. Else the callback will block RPIO from waiting for interrupts until it has finished (in the meantime no further callbacks are dispatched). + * If ``debounce_timeout_ms`` is set, interrupt callbacks will not be started until the specified milliseconds have passed since the last interrupt. Adjust this to your needs (typically between 10ms and 100ms). + + The callback receives two arguments: the gpio number and the value (an integer, either ``0`` (Low) or ``1`` (High)). A callback typically looks like this:: + + def gpio_callback(gpio_id, value): .. method:: RPIO.del_interrupt_callback(gpio_id) @@ -93,14 +110,11 @@ The following example shows how to listen for some GPIO and TCP interrupts:: # TCP socket server callback on port 8080 RPIO.add_tcp_callback(8080, socket_callback) - # Start the blocking epoll loop, and cleanup interfaces on exit - try: - RPIO.wait_for_interrupts() - finally: - RPIO.cleanup_interrupts() + # Blocking main epoll loop + RPIO.wait_for_interrupts() -If you want to receive a callback inside a Thread (to not block RPIO from returning to wait +To receive a callback inside a Thread (and not block RPIO from returning to wait for interrupts), set ``threaded_callback`` to ``True`` when adding it:: # for GPIO interrupts @@ -116,15 +130,17 @@ to ``add_interrupt_callback(..)`` like this:: RPIO.add_interrupt_callback(7, do_something, debounce_timeout_ms=100) -``wait_for_interrupts()`` is a blocking method which, while running, will listen for -interrupts and start the callbacks. You can add the argument ``threaded=True`` to put -``wait_for_interrupts()`` in a thread to run in the background:: +``wait_for_interrupts()`` listens for interrupts and dispatches the callbacks. +You can add the argument ``threaded=True`` to have it run in a thread and your +script continue. Since v0.10.0, RPIO automatically shuts down everything nicely +when your script quits. + +:: RPIO.wait_for_interrupts(threaded=True) -To stop ``wait_for_interrupts(..)``, call ``RPIO.stop_waiting_for_interrupts()``. After using -``RPIO.wait_for_interrupts()`` you should call ``RPIO.cleanup_interrupts()`` before your -program quits, to shut everything down cleanly. + +To stop ``wait_for_interrupts(..)``, call ``RPIO.stop_waiting_for_interrupts()``. .. _ref-rpio-py-rpigpio: @@ -221,6 +237,6 @@ Interrupt Handling * ``RPIO.add_tcp_callback(port, callback, threaded_callback=False)`` * ``RPIO.del_interrupt_callback(gpio_id)`` * ``RPIO.close_tcp_client(fileno)`` -* ``RPIO.wait_for_interrupts(epoll_timeout=1, threaded=False)`` +* ``RPIO.wait_for_interrupts(threaded=False, epoll_timeout=1)`` * ``RPIO.stop_waiting_for_interrupts()`` * implemented with ``epoll`` diff --git a/examples/example1_interrupts.py b/examples/example1_interrupts.py index 82d38b2..8b90351 100644 --- a/examples/example1_interrupts.py +++ b/examples/example1_interrupts.py @@ -1,7 +1,7 @@ -#import logging -#log_format = '%(levelname)s | %(asctime)-15s | %(message)s' -#logging.basicConfig(format=log_format, level=logging.DEBUG) - +""" +Example of how to use GPIO and TCP interrupts with RPIO. +RPIO Documentation: http://pythonhosted.org/RPIO +""" import RPIO @@ -15,16 +15,13 @@ def socket_callback(socket, val): RPIO.close_tcp_client(socket.fileno()) -# Add two GPIO interrupt callbacks (second one with a debouce timeout of 100ms) +# Two GPIO interrupt callbacks (second one with a debouce timeout of 100ms) RPIO.add_interrupt_callback(17, gpio_callback) RPIO.add_interrupt_callback(14, gpio_callback, edge='rising', \ debounce_timeout_ms=100) -# Add one TCP interrupt callback (opens socket server at port 8080) +# One TCP interrupt callback (opens socket server at port 8080) RPIO.add_tcp_callback(8080, socket_callback) -# Wait for interrupts indefinitely, and clean up before quitting -try: - RPIO.wait_for_interrupts() -finally: - RPIO.cleanup() +# Starts waiting for interrupts (exit with Ctrl+C) +RPIO.wait_for_interrupts() diff --git a/examples/example2_gpio.py b/examples/example2_gpio.py index 93a8f1a..2dcf9ee 100644 --- a/examples/example2_gpio.py +++ b/examples/example2_gpio.py @@ -1,3 +1,7 @@ +""" +Examples of how to use RPIO as a drop-in replacement for RPi.GPIO +RPIO Documentation: http://pythonhosted.org/RPIO +""" import RPIO # set up input channel without pull-up diff --git a/examples/example3_pwm_servo.py b/examples/example3_pwm_servo.py index 24e5dd4..29e4ed0 100644 --- a/examples/example3_pwm_servo.py +++ b/examples/example3_pwm_servo.py @@ -1,19 +1,16 @@ """ -This example demonstrates how to easily control servos. +Demonstration of how to control servo pulses with RPIO.PWM +RPIO Documentation: http://pythonhosted.org/RPIO """ from RPIO import PWM servo = PWM.Servo() -# Set servo on GPIO17 to 1200µs (1.2ms) +# Add servo pulse for GPIO 17 with 1200µs (1.2ms) servo.set_servo(17, 1200) -... - -# Set servo on GPIO17 to 2000µs (2.0ms) +# Add servo pulse for GPIO 17 with 2000µs (2.0ms) servo.set_servo(17, 2000) -... - # Clear servo on GPIO17 servo.stop_servo(17) diff --git a/examples/example4_pwm_lowlevel.py b/examples/example4_pwm_lowlevel.py index c91fe4e..771991d 100644 --- a/examples/example4_pwm_lowlevel.py +++ b/examples/example4_pwm_lowlevel.py @@ -1,5 +1,9 @@ """ -This example uses lower-level PWM control methods. +This example uses lower-level PWM control methods of RPIO.PWM. The default +settings include a subcycle time of 20ms and a pulse-width increment +granularity of 10us. + +RPIO Documentation: http://pythonhosted.org/RPIO """ import RPIO.PWM as PWM diff --git a/fabfile.py b/fabfile.py index 032edea..aca33bc 100644 --- a/fabfile.py +++ b/fabfile.py @@ -1,7 +1,7 @@ """ You can see all commands with `$ fab -l`. Typical usages: - $ fab upload build_gpio test_gpio + $ fab upload build $ fab upload build_pwm $ fab upload test $ fab build_deb @@ -22,7 +22,7 @@ def _get_cur_version(): def clean(): - run("rm -rf /tmp/source/") + run("sudo rm -rf /tmp/source/") def upload(): @@ -96,6 +96,7 @@ def upload_deb(): print " $ ./gen_version_index.sh %s" % v print " $ ./gen_index.sh" print " $ git status" + print " $ git add ." print " $ git commit -am 'Debian packages for RPIO %s" % v print " $ git push" @@ -181,7 +182,7 @@ def upload_to_pypi(): """ Upload sdist and bdist_eggs to pypi """ # DO_UPLOAD provides a safety mechanism to avoid accidental pushes to pypi. # Set it to "upload" to actually push to pypi; else it only does a dry-run. - DO_UPLOAD = "" # "upload" + DO_UPLOAD = "upload" # One more safety input and then we are ready to go :) x = prompt("Are you sure to upload the current version to pypi?") @@ -190,9 +191,9 @@ def upload_to_pypi(): return local("rm -rf dist") - local("python setup.py sdist %s" % DO_UPLOAD) - fn = local("ls dist/", capture=True) - version = fn[5:-7] + local("python setup.py sdist") + version = _get_cur_version() + fn = "RPIO-%s.tar.gz" % version put("dist/%s" % fn, "/tmp/") with cd("/tmp"): run("tar -xf /tmp/%s" % fn) @@ -200,3 +201,4 @@ def upload_to_pypi(): run("python2.6 setup.py bdist_egg %s" % DO_UPLOAD) run("python2.7 setup.py bdist_egg %s" % DO_UPLOAD) run("python3.2 setup.py bdist_egg %s" % DO_UPLOAD) + local("python setup.py sdist %s" % DO_UPLOAD) diff --git a/setup.py b/setup.py index fba11df..0e4f825 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): setup( name="RPIO", - version="0.9.6", + version="0.10.0", package_dir={"": "source"}, packages=['RPIO', 'RPIO.PWM'], ext_modules=[ @@ -27,7 +27,7 @@ def read(fname): author="Chris Hager", author_email="chris@linuxuser.at", - license="MIT", + license="LGPLv3+", keywords=["raspberry", "raspberry pi", "interrupts", "gpio", "rpio"], classifiers=[ "Development Status :: 4 - Beta", diff --git a/source/RPIO/Exceptions.py b/source/RPIO/Exceptions.py new file mode 100644 index 0000000..d787334 --- /dev/null +++ b/source/RPIO/Exceptions.py @@ -0,0 +1,34 @@ +# This file is part of RPIO. +# +# Copyright +# +# Copyright (C) 2013 Chris Hager +# +# License +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details at +# +# +# Documentation +# +# http://pythonhosted.org/RPIO +# +""" +This module contains all the exceptions used by the C GPIO wrapper. +""" +import RPIO._GPIO as _GPIO + +WrongDirectionException = _GPIO.WrongDirectionException +InvalidModeException = _GPIO.InvalidModeException +InvalidDirectionException = _GPIO.InvalidDirectionException +InvalidChannelException = _GPIO.InvalidChannelException +InvalidPullException = _GPIO.InvalidPullException +ModeNotSetException = _GPIO.ModeNotSetException diff --git a/source/RPIO/_RPIO.py b/source/RPIO/_RPIO.py index d1381d6..cef492d 100644 --- a/source/RPIO/_RPIO.py +++ b/source/RPIO/_RPIO.py @@ -27,6 +27,7 @@ import select import os.path import time +import atexit from logging import debug, info, warn, error from threading import Thread @@ -43,8 +44,21 @@ def _threaded_callback(callback, *args): - """ Internal wrapper to start a callback in threaded mode """ - Thread(target=callback, args=args).start() + """ + Internal wrapper to start a callback in threaded mode. Using the + daemon mode to not block the main thread from exiting. + """ + t = Thread(target=callback, args=args) + t.daemon = True + t.start() + + +def exit_handler(): + """ Auto-cleanup on exit """ + RPIO.stop_waiting_for_interrupts() + RPIO.cleanup_interrupts() + +atexit.register(exit_handler) class Interruptor: @@ -267,7 +281,6 @@ def wait_for_interrupts(self, epoll_timeout=1): callbacks again before using `wait_for_interrupts(..)` again. """ self._is_waiting_for_interrupts = True - #try: while self._is_waiting_for_interrupts: events = self._epoll.poll(epoll_timeout) for fileno, event in events: @@ -306,12 +319,6 @@ def wait_for_interrupts(self, epoll_timeout=1): f.seek(0) self._handle_interrupt(fileno, val) - #except: - # debug("RPIO: auto-cleaning interfaces after an exception") - # cleanup_interfaces() - # cleanup_tcpsockets() - # raise - def stop_waiting_for_interrupts(self): """ Ends the blocking `wait_for_interrupts()` loop the next time it can, diff --git a/source/RPIO/__init__.py b/source/RPIO/__init__.py index 465a357..02262c1 100644 --- a/source/RPIO/__init__.py +++ b/source/RPIO/__init__.py @@ -26,12 +26,7 @@ """ RPIO extends RPi.GPIO with GPIO interrupts, TCP socket interrupts and more. -You can use RPIO the same way as RPi.GPIO (eg. RPIO.setmode(...), -RPIO.input(...)), as well as access the new interrupt handling methods. The -following example shows how to react on events on 3 pins, and one socket -server on port 8080. The interrupts can have optional `edge` and -`pull_up_down` parameters (default edge is `both` and default pull_up_down is -`RPIO.PUD_OFF`.): +Example of how to listen for interrupts with RPIO: import RPIO @@ -40,7 +35,7 @@ def gpio_callback(gpio_id, val): def socket_callback(socket, val): print("socket %s: '%s'" % (socket.fileno(), val)) - socket.send("echo: %s\n" % val) + socket.send("echo: %s" % val) # Three GPIO interrupt callbacks RPIO.add_interrupt_callback(7, gpio_callback) @@ -49,14 +44,15 @@ def socket_callback(socket, val): # One TCP socket server callback on port 8080 RPIO.add_tcp_callback(8080, socket_callback) - # Start the blocking epoll loop, and catch Ctrl+C KeyboardInterrupt - try: - RPIO.wait_for_interrupts() - except KeyboardInterrupt: - RPIO.cleanup_interrupts() + # Start the blocking epoll loop (exit with Ctrl+C) + RPIO.wait_for_interrupts() -Now you can connect to the socket server with `$ telnet localhost 8080` and -send input to your callback. +You can add the argument `threaded=True` to `wait_for_interrupts(..)` in order +to run it in a thread. RPIO will automatically shutdown everything nicely when +your script exits. + +GPIO interrupts can have optional `edge` and `pull_up_down` parameters (default +edge is `both` and default pull_up_down is `RPIO.PUD_OFF`). If you want to receive a callback inside a Thread (which won't block anything else on the system), set `threaded_callback` to True when adding an interrupt- @@ -120,7 +116,7 @@ def socket_callback(socket, val): from RPIO._RPIO import Interruptor -VERSION = "0.9.6" +VERSION = "0.10.0" # Exposing constants from RPi.GPIO VERSION_GPIO = _GPIO.VERSION_GPIO @@ -231,7 +227,7 @@ def close_tcp_client(fileno): _rpio.close_tcp_client(fileno) -def wait_for_interrupts(epoll_timeout=1, threaded=False): +def wait_for_interrupts(threaded=False, epoll_timeout=1): """ Blocking loop to listen for GPIO interrupts and distribute them to associated callbacks. epoll_timeout is an easy way to shutdown the @@ -244,10 +240,13 @@ def wait_for_interrupts(epoll_timeout=1, threaded=False): callbacks again before using `wait_for_interrupts(..)` again. If the argument `threaded` is True, wait_for_interrupts will be - started in a Thread. To quit it, call `RPIO.stop_waiting_for_interrupts()`. + started in a daemon Thread. To quit it, call + `RPIO.stop_waiting_for_interrupts()`. """ if threaded: - Thread(target=_rpio.wait_for_interrupts, args=(epoll_timeout,)).start() + t = Thread(target=_rpio.wait_for_interrupts, args=(epoll_timeout,)) + t.daemon = True + t.start() else: _rpio.wait_for_interrupts(epoll_timeout) @@ -262,9 +261,9 @@ def stop_waiting_for_interrupts(): def cleanup_interrupts(): """ - Clean up all interrupt-related sockets and interfaces. Recommended to - use before exiting your program! After this you'll need to re-add the - interrupt callbacks before waiting for interrupts again. + Removes all callbacks and closes used GPIO interfaces and sockets. After + this you'll need to re-add the interrupt callbacks before waiting for + interrupts again. Since RPIO v0.10.0 this is done automatically on exit. """ _rpio.cleanup_interrupts() diff --git a/source/c_gpio/cpuinfo.c b/source/c_gpio/cpuinfo.c index e37ca7a..f61005c 100644 --- a/source/c_gpio/cpuinfo.c +++ b/source/c_gpio/cpuinfo.c @@ -63,7 +63,7 @@ get_cpuinfo_revision(char *revision_hex) // If over-voltage is present, remove it char* pos = strstr(revision_hex, "1000"); if (pos && pos - revision_hex == 0 && strlen(revision_hex) > 5) { - strcpy(revision_hex, revision_hex+4); + strcpy(revision_hex, revision_hex+(strlen(revision_hex) - 4)); } // Returns revision diff --git a/source/c_gpio/py_gpio.c b/source/c_gpio/py_gpio.c index db98f0b..accc775 100644 --- a/source/c_gpio/py_gpio.c +++ b/source/c_gpio/py_gpio.c @@ -162,7 +162,7 @@ channel_to_gpio(int channel) int gpio; if (gpio_mode != BOARD && gpio_mode != BCM) { - PyErr_SetString(ModeNotSetException, "Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)"); + PyErr_SetString(ModeNotSetException, "Please set pin numbering mode using RPIO.setmode(RPIO.BOARD) or RPIO.setmode(RPIO.BCM)"); return -1; } @@ -238,7 +238,7 @@ py_setup_channel(PyObject *self, PyObject *args, PyObject *kwargs) ((func != 0 && func != 1) || // (already one of the alt functions or (gpio_direction[gpio] == -1 && func == 1))) // already an output not set from this program) { - PyErr_WarnEx(NULL, "This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.", 1); + PyErr_WarnEx(NULL, "This channel is already in use, continuing anyway. Use RPIO.setwarnings(False) to disable warnings.", 1); } // printf("Setup GPIO %d direction %d pud %d\n", gpio, direction, pud); @@ -467,22 +467,22 @@ PyMODINIT_FUNC init_GPIO(void) goto exit; #endif - WrongDirectionException = PyErr_NewException("GPIO.WrongDirectionException", NULL, NULL); + WrongDirectionException = PyErr_NewException("RPIO.Exceptions.WrongDirectionException", NULL, NULL); PyModule_AddObject(module, "WrongDirectionException", WrongDirectionException); - InvalidModeException = PyErr_NewException("GPIO.InvalidModeException", NULL, NULL); + InvalidModeException = PyErr_NewException("RPIO.Exceptions.InvalidModeException", NULL, NULL); PyModule_AddObject(module, "InvalidModeException", InvalidModeException); - InvalidDirectionException = PyErr_NewException("GPIO.InvalidDirectionException", NULL, NULL); + InvalidDirectionException = PyErr_NewException("RPIO.Exceptions.InvalidDirectionException", NULL, NULL); PyModule_AddObject(module, "InvalidDirectionException", InvalidDirectionException); - InvalidChannelException = PyErr_NewException("GPIO.InvalidChannelException", NULL, NULL); + InvalidChannelException = PyErr_NewException("RPIO.Exceptions.InvalidChannelException", NULL, NULL); PyModule_AddObject(module, "InvalidChannelException", InvalidChannelException); - InvalidPullException = PyErr_NewException("GPIO.InvalidPullException", NULL, NULL); + InvalidPullException = PyErr_NewException("RPIO.Exceptions.InvalidPullException", NULL, NULL); PyModule_AddObject(module, "InvalidPullException", InvalidPullException); - ModeNotSetException = PyErr_NewException("GPIO.ModeNotSetException", NULL, NULL); + ModeNotSetException = PyErr_NewException("RPIO.Exceptions.ModeNotSetException", NULL, NULL); PyModule_AddObject(module, "ModeNotSetException", ModeNotSetException); high = Py_BuildValue("i", HIGH); @@ -540,7 +540,7 @@ PyMODINIT_FUNC init_GPIO(void) rpi_revision_hex = Py_BuildValue("s", revision_hex); PyModule_AddObject(module, "RPI_REVISION_HEX", rpi_revision_hex); - version = Py_BuildValue("s", "0.9.6/0.4.2a"); + version = Py_BuildValue("s", "0.10.0/0.4.2a"); PyModule_AddObject(module, "VERSION_GPIO", version); // set up mmaped areas diff --git a/source/c_pwm/pwm_py.c b/source/c_pwm/pwm_py.c index 133fd99..d57a0af 100644 --- a/source/c_pwm/pwm_py.c +++ b/source/c_pwm/pwm_py.c @@ -245,7 +245,7 @@ PyMODINIT_FUNC init_PWM(void) return; #endif - PyModule_AddObject(module, "VERSION", Py_BuildValue("s", "0.9.6")); + PyModule_AddObject(module, "VERSION", Py_BuildValue("s", "0.10.0")); PyModule_AddObject(module, "DELAY_VIA_PWM", Py_BuildValue("i", DELAY_VIA_PWM)); PyModule_AddObject(module, "DELAY_VIA_PCM", Py_BuildValue("i", DELAY_VIA_PCM)); PyModule_AddObject(module, "LOG_LEVEL_DEBUG", Py_BuildValue("i", LOG_LEVEL_DEBUG)); diff --git a/source/scripts/man/rpio.1 b/source/scripts/man/rpio.1 index 58b0778..603e34f 100644 --- a/source/scripts/man/rpio.1 +++ b/source/scripts/man/rpio.1 @@ -1,4 +1,4 @@ -.TH "RPIO" "1" "March 13, 2013" "0.9.6" "RPIO" +.TH "RPIO" "1" "March 14, 2013" "0.10.0" "RPIO" .SH NAME rpio \- RPIO Documentation . diff --git a/source/scripts/rpio b/source/scripts/rpio index d681884..b61d00d 100644 --- a/source/scripts/rpio +++ b/source/scripts/rpio @@ -245,7 +245,6 @@ def main(): RPIO._RPIO.GPIO_FUNCTIONS[f], gpio_id)) - if options.interrupt: show_help = False # gpio-ids can either be a single value, comma separated or a range diff --git a/source/scripts/rpio-curses b/source/scripts/rpio-curses index 1753111..3ad23ad 100644 --- a/source/scripts/rpio-curses +++ b/source/scripts/rpio-curses @@ -89,6 +89,8 @@ if "no_rpio" not in CMD_OPTIONS: return gpios GPIO_LIST = get_gpiolist() + HELP += ("\nRaspberry System Info:\n[%s] Model %s, Revision %s, RAM: %s MB, " + "Maker: %s") % RPIO.sysinfo() # # GPIO methods diff --git a/version_update.sh b/version_update.sh index f6d5f4c..3be4528 100644 --- a/version_update.sh +++ b/version_update.sh @@ -1,51 +1,54 @@ #! /bin/bash # -# This script updates the version number in all necessary places -# throughout the project, and adds a new entry to debian/changelog. +# This script updates the version number in all necessary places throughout +# the project, and can add a new entry to debian/changelog. # DATE_STR=`date +"%a, %d %b %Y %H:%M:%S +0100"` VERSION_FILES=('setup.py' 'source/RPIO/__init__.py' 'source/c_gpio/py_gpio.c' 'source/c_pwm/pwm_py.c' 'documentation/source/conf.py'); -VERSION_LAST=`head -n1 debian/changelog | awk '{print $2}' | sed "s/[()]//g"` +VERSION_LAST=`cat VERSION` if [ "$1" == "--show" ]; then echo $VERSION_LAST exit 0 fi -echo "The last version is $VERSION_LAST." -echo -n "New version number: " +echo "Current Version: $VERSION_LAST" +echo -n " New version: " read version - if [ -e $version ]; then exit 1 fi -echo -n "Are you sure you want to update the project to v$version? [y/n] " +echo -n "Are you sure you want to update the project? [y/n] " read confirm - -if [ -e $confirm ]; then +if [ "$confirm" != "y" ]; then exit 1 fi echo "Updating project to v$version..." for fn in ${VERSION_FILES[@]}; do echo "- $fn"; - #echo $cmd - sed -i '' "s/$VERSION_LAST/$version/g" $fn + sed -i '' "s/$VERSION_LAST/$version/" $fn done -# Update Changelog -echo "rpio ($version) unstable; urgency=low" > CHANGELOG.new -echo "" >> CHANGELOG.new -echo " * " >> CHANGELOG.new -echo " * " >> CHANGELOG.new -echo " * " >> CHANGELOG.new -echo "" >> CHANGELOG.new -echo " -- Chris Hager $DATE_STR" >> CHANGELOG.new -echo "" >> CHANGELOG.new -cat debian/changelog >> CHANGELOG.new -mv CHANGELOG.new debian/changelog -nano -w debian/changelog +echo $version > VERSION + +echo -n "Do you want to update debian/changelog? [y/n] " +read confirm +if [ "$confirm" == "y" ]; then + # Update Changelog + echo "rpio ($version) unstable; urgency=low" > CHANGELOG.new + echo "" >> CHANGELOG.new + echo " * " >> CHANGELOG.new + echo " * " >> CHANGELOG.new + echo " * " >> CHANGELOG.new + echo "" >> CHANGELOG.new + echo " -- Chris Hager $DATE_STR" >> CHANGELOG.new + echo "" >> CHANGELOG.new + cat debian/changelog >> CHANGELOG.new + mv CHANGELOG.new debian/changelog + nano -w debian/changelog +fi # Now rebuild doc for latest version echo "Run 'make doc' now, to build documentation with the new version number" \ No newline at end of file