KPAL is an extensible control system for physical computing.
KPAL is under development. The API will not be considered stable until 1.0 is released.
KPAL allows you to control and read data from peripherals attached to a computer such as your desktop or Raspberry Pi. It acts as an interface between users and individual peripherals through two application programming interfaces (APIs):
console
mkdir -p ~/.kpal/libraries
4. Move the file libbasic-plugin.so
from the archive into the ~/.kpal/libraries
folder. This is
an example plugin that is used for demonstrations and testing; it does not control any actual
hardware.
5. Run the binary file kpald
to start the daemon. If you want to see the logs, set the RUST_LOG
environment variable to info
, error
, or debug
, depending on the desired log level:
console
RUST_LOG=info ./kpald
You may now make HTTP requests to the daemon. The following examples use the UNIX curl
command
line utility to make the requests, but you may use the HTTP client of your choice.
```console
curl -s localhost:8000/api/v0/libraries
curl -s localhost:8000/api/v0/libraries/0
curl -s \ --request POST \ localhost:8000/api/v0/peripherals \ --header "Content-Type: application/json" \ --data '{"name":"foo","library_id":0}'
curl -s \ --request POST \ localhost:8000/api/v0/peripherals \ --header "Content-Type: application/json" \ --data '{ "name": "foo", "library_id": 0, "attributes": [ {"id":0, "variant":"double", "value": 999.99} ] }'
curl -s localhost:8000/api/v0/peripherals
curl -s localhost:8000/api/v0/peripherals/0
curl -s localhost:8000/api/v0/peripherals/0/attributes
curl -s localhost:8000/api/v0/peripherals/0/attributes/0
curl -s \ --request PATCH \ localhost:8000/api/v0/peripherals/0/attributes/0 \ --header "Content-Type: application/json" \ --data '{"variant":"double","value":42}' ```
The object model is the set of resources with which users interact. Currently, these resources include:
The KPAL daemon, or kpald
, is a web server that runs on the computer to which the peripherals are
connected. Users directly interact with the daemon through the user API. Each peripheral runs
inside its own thread which is spawned by a POST request to the user API. The daemon forwards other
user requests to each thread through the thread's dedicated channel. The threads interpret the
incoming requests and, in response, read and write data to individual plugins through the plugin
API using shared libraries.
Plugins are the means by which peripherals are integrated into KPAL. A plugin uses a shared library
(a .so
file on Linux) to communicate with the daemon. The common set of functions that the
library provides is the plugin API. Any programming language that can provide a C language
interface can be used to write a plugin library.
A plugin combines the data that represents a peripheral's state with the functionality for controlling the hardware device that is modeled by the peripheral.