Skip to main content

Compost RPC protocol generator

Project description

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:

Functional overview

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compost_rpc-0.8.0.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compost_rpc-0.8.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file compost_rpc-0.8.0.tar.gz.

File metadata

  • Download URL: compost_rpc-0.8.0.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for compost_rpc-0.8.0.tar.gz
Algorithm Hash digest
SHA256 9739f5033d9f037e90ad6d20e735b9ea3176b2858a78dd4f9af3ec36e051ad9f
MD5 c0588e82577745e7d34ee93ee4d4417f
BLAKE2b-256 9de6c8d8a0f769882352208be23b9b1b932b0c9e4e12d54a78479a14b783969b

See more details on using hashes here.

File details

Details for the file compost_rpc-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for compost_rpc-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60c8052e62d478efa3447bb2be63b6320d379e20c13244bc7d614debc3897296
MD5 01183aea4de8c31060966f9453e2c57d
BLAKE2b-256 ecb0ee8252d8a4dca8a0d6591181db57cd7aad6ec47075c000993f3e5ac74ebd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page