Skip to content

Commit

Permalink
Added protocol example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Feb 6, 2019
1 parent a578bfe commit 6a0d7b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions docs/protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ a struct formatted return type (if any), followed by a ``:`` and a space
delimited list of struct formatted parameter types. The format of the
documentation string is described in the :doc:`usage_device` section.

For our example, the response for the method discovery request will look as
follows.

::

<h: <h;inc: Increment a value. @a: Value. @return: a + 1.
: B;set_led: Set LED brightness. @brightness: Brightness.


Remote procedure call
---------------------
Expand All @@ -37,8 +46,8 @@ A remote procedure call is initiated by the host by writing one byte to the
serial device of which the value maps to one of the exported methods (i.e., 0
maps to the first method, 1 to the second, etc.). If this method takes any
parameters, their values are written to the serial device. After the parameter
values have been received, the device executes the method and writes the return
value of the method (if any) back to the serial device.
values have been received, the device executes the method and writes its return
value (if any) back to the serial device.

All native C types (``int``, ``float``, ``double``, etc.) are currently
supported. All values are little-endian. The host is responsible for packing
Expand Down
2 changes: 1 addition & 1 deletion docs/usage_device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Example
^^^^^^^

Suppose we want to export a method that sets the brightness of an LED and a
method that takes two parameters and returns one value.
method that takes one parameter and returns a value.

.. code:: cpp
Expand Down

0 comments on commit 6a0d7b2

Please sign in to comment.