Skip to content

Commit

Permalink
Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Nov 29, 2020
1 parent 740ca34 commit 0470169
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ library.
- Function and parameter names are defined on the Arduino.
- API documentation is defined on the Arduino.
- Support for disconnecting and reconnecting.
- Support for serial and ethernet devices.

Please see ReadTheDocs_ for the latest documentation.

Expand Down
2 changes: 2 additions & 0 deletions docs/credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Contributors
============

- Jeroen F.J. Laros <jlaros@fixedpoint.nl> (Original author, maintainer)
- Chris Flesher <chris.flesher@stoneaerospace.com> (Ethernet support)


Find out who contributed:

Expand Down
23 changes: 16 additions & 7 deletions docs/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ Library
=======

The API library provides the ``Interface`` class. A class instance is made by
passing the path to a serial device to the constructor.
passing the path to a device to the constructor.

.. code:: python
>>> from simple_rpc import Interface
>>>
If the device is a serial device, the path may look like this.

.. code:: python
>>> interface = Interface('/dev/ttyACM0')
>>> ethernet_interface = Interface('socket://192.168.1.50:10000')
If the device is an ethernet device, the path may look like this.

.. code:: python
>>> interface = Interface('socket://192.168.1.50:10000')
Every exported method will show up as a class method of the ``interface`` class
instance. These methods can be used like any normal class methods.
Expand All @@ -26,7 +35,7 @@ The constructor takes the following parameters.
- description
* - ``device``
- no
- Serial device name.
- Device name.
* - ``baudrate``
- yes
- Baud rate.
Expand All @@ -45,11 +54,11 @@ The following standard methods are available.
* - name
- description
* - ``open()``
- Connect to serial device.
- Connect to device.
* - ``close()``
- Disconnect from serial device.
- Disconnect from device.
* - ``is_open()``
- Query serial device state.
- Query device state.
* - ``call_method()``
- Execute a method.

Expand Down
6 changes: 3 additions & 3 deletions simple_rpc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def rpc_list(handle, device, baudrate, wait):
"""List the device methods.
:arg stream handle: Output handle.
:arg str device: Serial device.
:arg str device: Device.
:arg int baudrate: Baud rate.
:arg int wait: Time in seconds before communication starts.
"""
Expand All @@ -65,7 +65,7 @@ def rpc_call(handle, device, baudrate, wait, name, args):
"""Execute a method.
:arg stream handle: Output handle.
:arg str device: Serial device.
:arg str device: Device.
:arg int baudrate: Baud rate.
:arg int wait: Time in seconds before communication starts.
:arg str name: Method name.
Expand All @@ -85,7 +85,7 @@ def main():
common_parser = ArgumentParser(add_help=False)
common_parser.add_argument(
'-d', dest='device', type=str, default='/dev/ttyACM0',
help='serial device (%(type)s default="%(default)s")')
help='device (%(type)s default="%(default)s")')
common_parser.add_argument(
'-b', dest='baudrate', type=int, default=9600,
help='baud rate (%(type)s default=%(default)s)')
Expand Down
8 changes: 4 additions & 4 deletions simple_rpc/simple_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Interface(object):
def __init__(self, device, baudrate=9600, wait=1, autoconnect=True):
"""Initialise the class.
:arg str device: Serial device name.
:arg str device: Device name.
:arg int baudrate: Baud rate.
:arg int wait: Time in seconds before communication starts.
:arg bool autoconnect: Automatically connect.
Expand Down Expand Up @@ -105,7 +105,7 @@ def _get_methods(self):
return methods

def open(self):
"""Connect to serial device."""
"""Connect to device."""
if self.is_open():
return

Expand All @@ -122,7 +122,7 @@ def open(self):
self, method['name'], MethodType(make_function(method), self))

def close(self):
"""Disconnect from serial device."""
"""Disconnect from device."""
if not self.is_open():
return

Expand All @@ -135,7 +135,7 @@ def close(self):
self._connection.close()

def is_open(self):
"""Query serial device state."""
"""Query device state."""
return self._connection.isOpen()


Expand Down

0 comments on commit 0470169

Please sign in to comment.