Skip to content

Commit

Permalink
Add initial docs
Browse files Browse the repository at this point in the history
  • Loading branch information
NValsted committed Apr 2, 2024
1 parent fb9dab2 commit 1ec7653
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: csp_proc
description: Lightweight, programmable procedures with a libcsp- and libparam-native runtime.
theme: jekyll-theme-minimal
5 changes: 5 additions & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# csp_proc

Lightweight, programmable procedures with a libcsp- and libparam-native runtime. This provides remote control of libparam-based coordination between nodes in a CSP network, essentially exposing the network as single programmable unit.

The library has a relatively small footprint suitable for microcontrollers, requiring no external libraries other than libcsp and libparam themselves for the core of the library. However, currently, the only runtime implementation relies on FreeRTOS.
66 changes: 66 additions & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Setup `csp_proc`

The easiest way to integrate `csp_proc` is with [meson](https://mesonbuild.com/). As of writing, no other build systems are supported out-of-the-box, so you'll have to get creative if using meson is not an option. See below for an overview of the constituent parts of `csp_proc`.

The following demonstrates the outline of a `meson.build` file in a parent project where `libcsp`, `libparam`, and `csp_proc` are present in the `lib` subdirectory:
```meson
project(..., subproject_dir: 'lib', default_options: [
'csp_proc:slash=false',
'csp_proc:freertos=false',
'csp_proc:RESERVED_PROC_SLOTS=...',
...
])
deps = []
deps += dependency('csp', fallback: ['libcsp', 'csp_dep'])
deps += dependency('param', fallback: ['libparam', 'param_dep'])
deps += dependency('csp_proc', fallback: ['csp_proc', 'csp_proc_dep'])
app = executable(...
dependencies : deps,
...
)
```

Note that `csp_proc` is not a standalone library. The core part of the library depends on `libparam` and `libcsp`, while optional parts depend on `slash` and the FreeRTOS kernel. A reference setup can be found in the following [Dockerfile](https://github.com/discosat/csp_proc/blob/main/Dockerfile), which is the environment that's used to run the automated tests in the CI pipeline.

## Composition of the library
The library has the following components:
### Core
The core part of the library consists of the following files:
- `proc_analyze.(h|c)`: Functions for analyzing procedures.
- `proc_client.(h|c)`: Client-side functions, e.g. request to push procedure over CSP network.
- `proc_pack.(h|c)`: Functions for packing and unpacking procedures into CSP packets.
- `proc_runtime.(h|c)`: Runtime interface as expected by the core library.
- `proc_server.(h|c)`: Server-side functions, e.g. handling incoming procedure requests.
- `proc_store.(h|c)`: Functions for storing and retrieving procedures in a local procedure table.
- `proc_types.(h|c)`: Procedure data type, including the procedure structure and the instruction structure.

### Runtime
- _Optional_ `proc_runtime_FreeRTOS.c`: A FreeRTOS-based runtime for `csp_proc`.
- _Optional_ `proc_runtime_instructions.c`: Instruction handlers for the FreeRTOS-based runtime.

### Slash
- _Optional_ `slash/slash_csp_proc.c`: A series of slash commands for interacting with `csp_proc`.


## Configuration options at compile-time

The following options can be configured at compile-time:

- `RESERVED_PROC_SLOTS`: This option defines the number of reserved procedure slots.
- `MAX_PROC_BLOCK_TIMEOUT_MS`: This option sets the maximum time (in milliseconds) that block instructions will wait before timing out.
- `MIN_PROC_BLOCK_PERIOD_MS`: This option sets the minimum time (in milliseconds) between evaluations of a block instruction's condition.
- `MAX_PROC_RECURSION_DEPTH`: This option sets the maximum recursion depth of a procedure.
- `MAX_PROC_CONCURRENT`: This option sets the maximum number of procedure runtimes that can run concurrently.

In addition to the above, the default FreeRTOS-based runtime has its own set of configuration options:

- `PROC_RUNTIME_TASK_SIZE`: This option sets the stack size of a runtime task.
- `PROC_RUNTIME_TASK_PRIORITY`: This option sets the FreeRTOS task priority of a runtime task.
- `PARAM_REMOTE_TIMEOUT_MS`: This option sets the timeout (in milliseconds) for a remote call via libparam.
- `PARAM_ACK_ON_PUSH`: This option toggles whether to expect an acknowledgment from the remote node when pushing a parameter.
- `PROC_FLOAT_EPSILON`: This option sets the epsilon value for floating-point comparisons.
- `TASK_STORAGE_RECURSION_DEPTH_INDEX`: This option sets the index of the thread-local storage pointer for recursion depth tracking.

Please note that the FreeRTOS-based runtime requires a `FreeRTOSConfig.h` file in the parent project. This configuration file should define `configNUM_THREAD_LOCAL_STORAGE_POINTER` to a value greater than 0, as the tracking of recursion depth is done using thread-local storage.
2 changes: 2 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Overview](docs/overview.md)
[Setup](docs/setup.md)

0 comments on commit 1ec7653

Please sign in to comment.