Compost
Compost is a Remote Procedure Call (RPC) protocol generator with a simple wire format.
It abstracts communication between a PC and an MCU. Basically it allows you to call functions on your MCU from a PC.
Compost is meant to be used over any medium, but it's simplicity is best suited for UART/RS232 or UDP/IP.
Install
pip install compost_rpc
Documentation
Documentation is available in the Wiki
Introduction
With Compost you can write a function for your MCU in C, but call it from Python or C# on a PC.
The call on the PC looks like a normal function call, but Compost takes the arguments, creates a message and sends it over a transport like serial port. Then, Compost on the MCU parses the message and calls your function with the arguments you provided on the PC. Your function returns a value. Compost on the MCU creates a response message with the return value. The response is sent to PC. Compost on the PC parses the message and the function you called on the PC returns the value you provided in the MCU.
Simplified functionality diagram:
Features
Languge support
- C
- C11 standard
- Implemented roles
- RPC server (callee)
- Notification sender
- Notification receiver
- Python
- Needs version >= 3.10
- Implemented roles
- RPC client (caller)
- Notification receiver
- C#
- Implemented roles
- RPC client (caller)
- Notification receiver
- Implemented roles
Transports
- UDP transport
- Serial transport
- Raw ethernet transport (Linux only)
- TCP transport
- Stdio transport
- CAN FD using SocketCAN (Linux only)
- Custom
Data types
- 8, 16, 32 and 64-bit signed and unsigned integers
- 32 and 64-bit floating-point numbers (IEEE 754)
- Bit-precise integers
- C like Struct
- C like Enum with selectable underlying type
- Dynamically sized array (list) for each supported primitive type
Try it!
You just need Python and a C compiler like GCC to run our single PC example.
Clone the repository and enter the directory with the example:
git clone https://github.com/STMicroelectronics/compost-rpc.git
cd compost-rpc/examples/pc_to_pc
Generate C code from the protocol definition:
python protocol_def.py
Compile the server:
On Linux or macOS:
gcc -o server main.c compost.c
On Windows:
gcc -o server main.c compost.c -lws2_32
In one terminal run the C server:
./server
In another terminal run the Python client:
python main.py
Client sends two integers and the server adds them together and sends the result back to the client. It's probably the simplest Compost example you can have.
If you want to try Compost-RPC properly with an MCU, check out the Tutorial.
Metadata
Release files for compost-rpc 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| compost_rpc-0.8.1.tar.gz | 27.7 kB | Without provenance | Details for compost_rpc-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| compost_rpc-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for compost_rpc-0.8.1-py3-none-any.whl |
Total release size: 57.5 kB
Release files / compost_rpc-0.8.1.tar.gz
| Download URL | compost_rpc-0.8.1.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b8ac5958311316d4a7a64321d470ffa240f3699152e9a1fa86811d131bd94c5
|
|
BLAKE2b-256 checksum How to use checksums |
80b43a6ef0b1874347df1b428431dc00031aa23590c4e61a306a884c1c6cb362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"KDE neon","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / compost_rpc-0.8.1-py3-none-any.whl
| Download URL | compost_rpc-0.8.1-py3-none-any.whl |
|---|---|
| Size | 29.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a225a1a9e4cc8a15e8da2c0e9cef4a61c3c5af08679bca565ef1f07310d5526f
|
|
BLAKE2b-256 checksum How to use checksums |
0f9509cffff23b090a6ac301f8ebd204f6848c89c4ecb5bdb802dd9e299f3f16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"KDE neon","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for compost-rpc 0.8.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.