forked from MiczFlor/RPi-Jukebox-RFID
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Future3/documentation (MiczFlor#2127)
* fixed typo * restored "rpc-commands" * fixed broken links * switched placed for leading documentation * added docu for changing swap size * unified links to source
- Loading branch information
1 parent
924c7f3
commit 12f4f92
Showing
19 changed files
with
193 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# RPC Commands | ||
|
||
|
||
We use the RPC commands when triggering actions from different inputs like a card swipe, | ||
a GPIO button press, etc. Triggering an action is equal to sending an RPC function call. | ||
In many places the command to send when an input is triggered is configurable in a YAML-file. | ||
|
||
## Basics | ||
|
||
Consequently, you need to know how to specify the RPC command in the YAML file. | ||
Here is the essence of what you need to know: | ||
|
||
An RPC command consists of up to three parts | ||
|
||
#. the function to execute (e.g. play_folder, change_volume) | ||
#. the positional arguments (optional) | ||
#. the keyword arguments (optional) | ||
|
||
The function specification consists of two (e.g., ``host.shutdown``) or three terms (e.g., ``volume.ctrl.change_volume``). | ||
In configuration files, this will look like this: | ||
|
||
.. code-block:: yaml | ||
|
||
package: host | ||
plugin: shutdown | ||
|
||
Or like this for a three part function with the argument set to ``5``: | ||
|
||
.. code-block:: yaml | ||
|
||
package: volume | ||
plugin: ctrl | ||
method: change_volume | ||
args: [5] | ||
|
||
The keyword ``method`` is optional. If needs to be used depends on the function you want to call. | ||
|
||
## Aliases | ||
|
||
|
||
Not so complicated, right? It will get even easier. For common commands we have defined aliases. An alias simply maps | ||
to a pre-defined RPC command, e.g. ``play_card`` maps to ``player.ctrl.play_card``. | ||
|
||
Instead of | ||
|
||
.. code-block:: yaml | ||
|
||
package: player | ||
plugin: ctrl | ||
method: play_card | ||
args: [path/to/folder] | ||
|
||
you can simply specify instead : | ||
|
||
.. code-block:: yaml | ||
|
||
alias: play_card | ||
args: [path/to/folder] | ||
|
||
Using in alias is optional. But if the keyword is present in the configuration it takes precedence over an explicit | ||
specified RPC command. | ||
|
||
## Arguments | ||
|
||
Arguments can be specified in similar fashion to Python function arguments: as positional arguments and / or | ||
keyword arguments. Let's check out play_card, which is defined as: | ||
|
||
.. py:function:: play_card(...) -> player.ctrl.play_card(folder: str, recursive: bool = False) | ||
:noindex: | ||
|
||
:param folder: Folder path relative to music library path | ||
:param recursive: Add folder recursively | ||
|
||
This means it takes two arguments: | ||
|
||
* folder of type string | ||
* recursive of type bool | ||
|
||
In the following examples, we will always use the alias for smaller configuration text. All three examples | ||
do exactly the same, but use different ways of specifying the command. | ||
|
||
.. code-block:: yaml | ||
|
||
alias: play_card | ||
args: [path/to/folder, True] | ||
|
||
.. code-block:: yaml | ||
|
||
alias: play_card | ||
args: [path/to/folder] | ||
kwargs: | ||
recursive: True | ||
|
||
.. code-block:: yaml | ||
|
||
alias: play_card | ||
kwargs: | ||
folder: path/to/folder | ||
recursive: True | ||
|
||
|
||
.. important:: *args* must be a **list** of arguments to be passed! Even if only a single argument is passed. | ||
So, use *args: [value]*. We try catch mis-uses but that might not always work. | ||
|
||
|
||
You will find some more examples the configuration of the [Card Database](card-database.md) | ||
|
||
## For developers | ||
|
||
To send RPC commands for testing and debugging purpose you can use the CLI Tool [`run_rpc_tool.py`](../developers/coreapps.md#run_rpc_toolpy) | ||
Also here is a ready-to-use decoding functions which decodes an RPC command (with or without alias) | ||
from a YAML entry:func:`jukebox.utils.decode_rpc_command`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
|
||
For documentation see [src/jukebox/components/rfid/hardware/template_new_reader/README.md](../../../../src/jukebox/components/rfid/hardware/template_new_reader/README.md). | ||
# Template Reader | ||
|
||
*Template for creating and integrating a new RFID Reader* | ||
|
||
> [!NOTE] | ||
> For developers only | ||
This template provides the skeleton API for a new Reader. If you follow | ||
the conventions outlined below, your new reader will be picked up | ||
automatically There is no extra need to register the reader module with | ||
the Phoniebox. Just re-run `the reader config tool <developer/coreapps:run_register_rfid_reader.py>`. | ||
|
||
Follow the instructions in [template_new_reader.py] | ||
|
||
Also have a look at the other reader subpackages to see how stuff works | ||
with an example | ||
|
||
## File structure | ||
|
||
Your new reader is a python subpackage with these three mandatory files | ||
|
||
``` bash | ||
components/rfid/hardware/awesome_reader/ | ||
+- awesome_reader.py <-- The actual reader module | ||
+- description.py <-- A description module w/o dependencies. Do not change the filename! | ||
+- README.rst <-- The Readme | ||
``` | ||
|
||
The module documentation must go into a separate file, called README.ME. | ||
|
||
## Conventions | ||
|
||
- Single reader per directory / subpackage | ||
- reader module directory name and reader module file name must be | ||
identical | ||
- Obviously awesome_reader will be replaced with something more | ||
descriptive. The naming scheme for the subpackage is | ||
- \<type_of_reader\>\_\<io_bus\>\_\<other_specials_like_special_lib\> | ||
- e.g. generic_usb/generic_usb.py | ||
- e.g. pn532_spi/pn532_spi.py | ||
- ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
For documentation see [documentation/content/developers/rfid/mock_reader.md](../../../../../../documentation/content/developers/rfid/mock_reader.md). | ||
For documentation see [documentation/developers/rfid/mock_reader.md](../../../../../../documentation/developers/rfid/mock_reader.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
For documentation see [documentation/content/developers/rfid/genericusb.md](../../../../../../documentation/content/developers/rfid/genericusb.md). | ||
For documentation see [documentation/developers/rfid/genericusb.md](../../../../../../documentation/developers/rfid/genericusb.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
For documentation see [documentation/content/developers/rfid/pn532_i2c.md](../../../../../../documentation/content/developers/rfid/pn532_i2c.md). | ||
For documentation see [documentation/developers/rfid/pn532_i2c.md](../../../../../../documentation/developers/rfid/pn532_i2c.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
For documentation see [documentation/content/developers/rfid/mfrc522_spi.md](../../../../../../documentation/content/developers/rfid/mfrc522_spi.md). | ||
For documentation see [documentation/developers/rfid/mfrc522_spi.md](../../../../../../documentation/developers/rfid/mfrc522_spi.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
For documentation see [documentation/content/developers/rfid/rdm6300.md](../../../../../../documentation/content/developers/rfid/rdm6300.md). | ||
For documentation see [documentation/developers/rfid/rdm6300.md](../../../../../../documentation/developers/rfid/rdm6300.md). |
41 changes: 1 addition & 40 deletions
41
src/jukebox/components/rfid/hardware/template_new_reader/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,2 @@ | ||
# Template Reader | ||
|
||
*Template for creating and integrating a new RFID Reader* | ||
|
||
> [!NOTE] | ||
> For developers only | ||
This template provides the skeleton API for a new Reader. If you follow | ||
the conventions outlined below, your new reader will be picked up | ||
automatically There is no extra need to register the reader module with | ||
the Phoniebox. Just re-run `the reader config tool <developer/coreapps:run_register_rfid_reader.py>`. | ||
|
||
Follow the instructions in [template_new_reader.py] | ||
|
||
Also have a look at the other reader subpackages to see how stuff works | ||
with an example | ||
|
||
## File structure | ||
|
||
Your new reader is a python subpackage with these three mandatory files | ||
|
||
``` bash | ||
components/rfid/hardware/awesome_reader/ | ||
+- awesome_reader.py <-- The actual reader module | ||
+- description.py <-- A description module w/o dependencies. Do not change the filename! | ||
+- README.rst <-- The Readme | ||
``` | ||
|
||
The module documentation must go into a separate file, called README.ME. | ||
|
||
## Conventions | ||
|
||
- Single reader per directory / subpackage | ||
- reader module directory name and reader module file name must be | ||
identical | ||
- Obviously awesome_reader will be replaced with something more | ||
descriptive. The naming scheme for the subpackage is | ||
- \<type_of_reader\>\_\<io_bus\>\_\<other_specials_like_special_lib\> | ||
- e.g. generic_usb/generic_usb.py | ||
- e.g. pn532_spi/pn532_spi.py | ||
- ... | ||
For documentation see [documentation/developers/rfid/template_reader.md](../../../../../../documentation/developers/rfid/template_reader.md). |