Skip to content

Commit b5fe24f

Browse files
committed
Documentation.
1 parent b6ce7fe commit b5fe24f

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

docs/library.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ The constructor takes the following parameters.
3737
* - ``autoconnect``
3838
- yes
3939
- Automatically connect.
40+
* - ``load``
41+
- yes
42+
- Load interface definition from file.
4043

4144
Please see the list of handlers_ for a full description of the supported
4245
interface types.
@@ -99,6 +102,8 @@ The ``Interface`` class provides the following methods.
99102
- Query device state.
100103
* - ``call_method()``
101104
- Execute a method.
105+
* - ``save()``
106+
- Save the interface definition to a file.
102107

103108
The ``open()`` function is used to connect to a device, this is needed when
104109
``autoconnect=False`` is passed to the constructor.
@@ -109,6 +114,14 @@ The ``open()`` function is used to connect to a device, this is needed when
109114
>>> # Do something.
110115
>>> interface.open()
111116
117+
The ``open()`` function accepts the optional parameter ``handle``, which can be
118+
used to load an interface definition from a file. This can be useful when
119+
working with low throughput networks.
120+
121+
.. code:: python
122+
123+
>>> interface.open(open('interface.yml'))
124+
112125
The connection state can be queried using the ``is_open()`` function and it can
113126
be closed using the ``close()`` function.
114127

@@ -160,6 +173,14 @@ instance. These methods can be used like any normal class methods.
160173
Alternatively, the exported methods can be called by name using the
161174
``call_method()`` function.
162175

176+
The ``save()`` function is used to save the interface definition to a file.
177+
This can later be used by the constructor or the ``open()`` function to
178+
initialise the interface without having to query the device.
179+
180+
.. code:: python
181+
182+
>>> interface.save(open('interface.yml', 'w'))
183+
163184
164185
Basic usage
165186
-----------
@@ -227,6 +248,5 @@ other Object. A similar Object is returned.
227248
(b'b', (11, b'c'))
228249
229250
230-
231251
.. _example: https://simplerpc.readthedocs.io/en/latest/usage_device.html#example
232252
.. _handlers: https://pyserial.readthedocs.io/en/latest/url_handlers.html

docs/usage.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,31 @@ makes use of the demo_ sketch in the device examples.
108108
["b", [11, "c"]]
109109

110110

111+
Low throughput networks
112+
-----------------------
113+
114+
When working with low throughput networks (e.g., LoRa_), device initialisation
115+
can take a long time. To counteract this problem, it is possible to save the
116+
interface definition to a file, which can subsequently be used to initialise
117+
the interface without having to query the device.
118+
119+
An interface definition can be saved to a file using the ``-s`` option of the
120+
``list`` subcommand.
121+
122+
::
123+
124+
$ simple_rpc list -s interface.yml /dev/ttyACM0
125+
126+
A saved interface definition can be loaded to skip the initialisation procedure
127+
by using the ``-l`` option of the ``call`` subcommand.
128+
129+
::
130+
131+
$ simple_rpc call -l interface.yml /dev/ttyACM0 inc 1
132+
2
133+
134+
135+
.. _LoRa: https://en.wikipedia.org/wiki/LoRa
111136
.. _arduino-cli: https://arduino.github.io/arduino-cli/latest/
112137
.. _demo: https://github.com/jfjlaros/simpleRPC/blob/master/examples/demo/demo.ino
113138
.. _example: https://simplerpc.readthedocs.io/en/latest/usage.html#example

0 commit comments

Comments
 (0)