Skip to content

Commit 300a3ce

Browse files
committed
Updated documentation.
1 parent 7c1cbb7 commit 300a3ce

File tree

5 files changed

+50
-43
lines changed

5 files changed

+50
-43
lines changed

README.rst

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Arduino simpleRPC Python client
2-
===============================
1+
Arduino simpleRPC API client library and CLI
2+
============================================
33

44
.. image:: https://img.shields.io/github/last-commit/jfjlaros/arduino-simple-rpc.svg
55
:target: https://github.com/jfjlaros/arduino-simple-rpc/graphs/commit-activity
@@ -29,53 +29,35 @@ with the simpleRPC_ protocol. The exported method definitions are communicated
2929
to the host, which is then able to generate an API interface using this
3030
library.
3131

32-
Only one function call is needed to perform a remote procedure call.
32+
Features:
33+
34+
- User friendly API library.
35+
- Command line interface (CLI) for method discovery and testing.
36+
- Function and parameter names are defined on the Arduino.
37+
- API documentation is defined on the Arduino.
38+
- Support for disconnecting and reconnecting.
3339

3440
Please see ReadTheDocs_ for the latest documentation.
3541

3642

3743
Quick start
3844
-----------
3945

40-
Export any function e.g., ``digitalRead()`` and ``digitalWrite()`` using the
41-
``interface()`` function.
42-
43-
.. code:: cpp
44-
45-
#include <simpleRPC.h>
46-
47-
void setup(void) {
48-
Serial.begin(9600);
49-
}
46+
Export any function e.g., ``digitalRead()`` and ``digitalWrite()`` on the
47+
Arduino, these functions will show up as member functions of the ``Interface``
48+
class instance.
5049

51-
void loop(void) {
52-
interface(digitalRead, "", digitalWrite, "");
53-
}
54-
55-
These functions are now available on the host under name ``method2()`` and
56-
``method3()``.
50+
First, we make an ``Interface`` class instance and tell it to connect to the
51+
serial device ``/dev/ttyACM0``.
5752

5853
.. code:: python
5954
6055
>>> from simple_rpc import Interface
6156
>>>
6257
>>> interface = Interface('/dev/ttyACM0')
63-
>>>
64-
>>> interface.method2(8)
65-
0
66-
>>> interface.method3(13, True)
6758
68-
The documentation string can be used to name and describe the method.
69-
70-
.. code:: cpp
71-
72-
interface(
73-
digitalRead,
74-
"digital_read: Read digital pin. @pin: Pin number. @return: Pin value.",
75-
digitalWrite,
76-
"digital_write: Write to a digital pin. @pin: Pin number. @value: Pin value.");
77-
78-
This is reflected on the host.
59+
We can use the built-in ``help()`` function to see the API documentation of any
60+
exported method.
7961

8062
.. code:: python
8163
@@ -89,12 +71,16 @@ This is reflected on the host.
8971
9072
:returns int: Pin value.
9173
92-
>>> interface.digital_read(8)
74+
All exposed methods can be called like any other class method.
75+
76+
.. code:: python
77+
78+
>>> interface.digital_read(8) # Read from pin 8.
9379
0
94-
>>> interface.digital_write(13, True)
80+
>>> interface.digital_write(13, True) # Turn LED on.
9581
9682
For more information about the host library and other interfaces, please see
97-
the :doc:`usage` section.
83+
the :doc:`usage` and :doc:`library` sections.
9884

9985

10086
.. _Arduino: https://www.arduino.cc

docs/introduction.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
Introduction
22
============
33

4+
This Python library provides a simple way to interface to Arduino_ functions
5+
exported with the simpleRPC_ protocol.
6+
7+
For more background information and the reasons that led to this project, see
8+
the motivation_ section of the device library documentation.
9+
10+
This project serves as a reference implementation for clients using the
11+
simpleRPC protocol.
12+
13+
14+
.. _Arduino: https://www.arduino.cc
15+
.. _motivation: https://simplerpc.readthedocs.io/en/latest/introduction.html#motivation
16+
.. _simpleRPC: https://simpleRPC.readthedocs.io

docs/library.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ contains the definitions of the exported methods.
106106
Example
107107
-------
108108

109-
In our example we have exported the ``inc`` method, which is now present as a
110-
class method of the ``interface`` class instance.
109+
In the example_ given in the device library documentation, the ``inc`` method
110+
is exported, which is now present as a class method of the ``Interface`` class
111+
instance.
111112

112113
.. code:: python
113114
@@ -136,3 +137,6 @@ function can be used.
136137
:arg int a: Value.
137138
138139
:returns int: a + 1.
140+
141+
142+
.. _example: https://simplerpc.readthedocs.io/en/latest/usage_device.html#example

docs/usage.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ the ``-h`` option.
1414
Example
1515
-------
1616

17-
In our example, the ``list`` subcommand will show a description of the ``inc``
18-
method and the ``set_led`` method.
17+
If the Arduino has exposed the functions ``inc`` and ``set_led`` like in the
18+
example_ given in the device library documentation, the ``list`` subcommand
19+
will show the following.
1920

2021
.. code::
2122
@@ -37,9 +38,12 @@ method and the ``set_led`` method.
3738
int brightness: Brightness.
3839
3940
40-
A method can be called by using the ``call`` subcommand.
41+
Any of these methods can be called by using the ``call`` subcommand.
4142

4243
.. code::
4344
4445
$ simple_rpc call inc 1
4546
2
47+
48+
49+
.. _example: https://simplerpc.readthedocs.io/en/latest/usage_device.html#example

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[metadata]
22
name = arduino-simple-rpc
33
version = 1.0.3
4-
description = Arduino SimpleRPC Python client.
4+
description = Arduino simpleRPC API client library and CLI.
55
long_description = file: README.rst
66
author = Jeroen F.J. Laros
77
author_email = jlaros@fixedpoint.nl

0 commit comments

Comments
 (0)