.. pyaler documentation master file, created by
   sphinx-quickstart on Sat May 22 10:51:04 2010.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to pyaler's documentation!
==================================

.. include:: ../README.txt

Deploy
------

With mod_wsgi
*************

  from pyaler import pyaler

  application = pyaler.make_app({}, config='conf.yaml')

With PasteDeploy
****************

Create a config file:

.. literalinclude:: ../config.ini
   :language: ini

Then run::

  $ paster serve config.ini

Or create a mod_wsgi file::

  from paste.deploy import loadapp
  application = loadapp('config:%s' % '/path/to/config.ini')

Extending pyaler
----------------

pyaler is based on `bottle <http://bottle.paws.de/>`_. You can use the bottle
api to extend your pyaler service. Here is a simple example:

.. literalinclude:: ../pyaler/test_app.py

Then create your WSGI application like this::


  from pyaler import pyaler

  application = pyaler.make_app({}, config='conf.yaml', app='yourappmodule')



Example usage
-------------

Led on / led off example.
First, C source:

.. sourcecode:: c

    int incomingByte = 0;
    int ledPin = 13;

    void setup() {
        Serial.begin(9600);
        pinMode(ledPin, OUTPUT);
    }

    void loop() {
        if (Serial.available() > 0) {
            incomingByte = Serial.read();
            if (incomingByte > 49) {
                digitalWrite(ledPin, HIGH);
                Serial.println('LED turned ON');
            } else {
                digitalWrite(ledPin, LOW);
                Serial.println('LED turned OFF');
            }
        }
    }

Then you can run with this matching yaml configuration ::

    arduinos:
        arduino1: /dev/tty.usbserial-A800eIR3
        arduino2: /dev/tty.usbserial-A800eIho

    read_actions:

    write_actions:
        ledon: 42
        ledoff: 0


Contents:

.. toctree::
   :maxdepth: 2

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

