Metadata-Version: 2.4
Name: lotusrpc
Version: 1.0.0
Summary: A code generator for remote procedure calls on embedded systems
Author: T Zijnge
License: MIT License
        
        Copyright (c) 2022 tzijnge
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/tzijnge/LotusRpc
Project-URL: Bug Tracker, https://github.com/tzijnge/LotusRpc/issues
Project-URL: Documentation, https://tzijnge.github.io/LotusRpc/
Project-URL: Source Code, https://github.com/tzijnge/LotusRpc
Keywords: code generation,embedded systems,C++,RPC,remote procedure call
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: C++
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Embedded Systems
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyyaml==6.0.2
Requires-Dist: jsonschema==4.26.0
Requires-Dist: click==8.4.1
Requires-Dist: click-log==0.4.0
Requires-Dist: types-click-log==0.4.0.20250413
Requires-Dist: typing-extensions==4.15.0
Requires-Dist: colorama==0.4.6
Requires-Dist: pydantic==2.13.3
Provides-Extra: transport-serial
Requires-Dist: pyserial==3.5; extra == "transport-serial"
Dynamic: license-file

# LotusRPC 🌼

![Build & Test](https://github.com/tzijnge/LotusRpc/actions/workflows/cmake.yml/badge.svg?branch=main) [![Code style: clang-format](https://img.shields.io/badge/code%20style-clang--format-blue)](https://clang.llvm.org/docs/ClangFormat.html) [![Static analysis: clang-tidy](https://img.shields.io/badge/static%20analysis-clang--tidy-blue)](https://clang.llvm.org/extra/clang-tidy/) [![PyPI](https://img.shields.io/pypi/v/lotusrpc)](https://pypi.org/project/lotusrpc/) [![Python](https://img.shields.io/pypi/pyversions/lotusrpc)](https://pypi.org/project/lotusrpc/) [![License: MIT](https://img.shields.io/github/license/tzijnge/LotusRpc)](LICENSE) [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=tzijnge_LotusRpc&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=tzijnge_LotusRpc) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=tzijnge_LotusRpc&metric=coverage)](https://sonarcloud.io/summary/new_code?id=tzijnge_LotusRpc) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=tzijnge_LotusRpc&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=tzijnge_LotusRpc) [![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff) [![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint) [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)

[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=tzijnge_LotusRpc)](https://sonarcloud.io/summary/new_code?id=tzijnge_LotusRpc)

RPC framework for embedded systems based on [ETL](https://github.com/ETLCPP/etl). Define your interface once in YAML; LotusRPC generates all C++ server code and a Python client. No dynamic memory allocations, no exceptions, no RTTI.

```mermaid
graph LR
    C["Client\nPC · Python"] <-->|"function call / return"| T["Transport\nserial · BT · TCP · …"]
    T <-->|bytes| S["Server\nMCU · C++"]
```

## Features

- **No dynamic memory** — stack-only, no heap, no exceptions, no RTTI
- **Transport agnostic** — any byte-oriented channel (serial, Bluetooth, TCP, …)
- **YAML definitions** — schema-validated, editor-friendly, easy to parse or extend
- **Code generation** — `lrpcg` produces all C++ server code in one command
- **CLI client** — `lrpcc` lets any team member call remote functions without writing code
- **Streams** — client-to-server and server-to-client data streams, finite or infinite
- **C++11 compatible** — works on any platform with a modern C++ compiler

## Quick start

**Install:**

```bash
pip install lotusrpc
```

**Define your interface** (`math.lrpc.yaml`):

> [!NOTE]
> By convention, LotusRPC definition files use the `.lrpc.yaml` extension.

```yaml
name: math
settings:
  namespace: ex
services:
  - name: calc
    functions:
      - name: add
        params:
          - { name: a, type: int32_t }
          - { name: b, type: int32_t }
        returns:
          - { name: result, type: int32_t }
```

**Generate C++ server code:**

```bash
lrpcg cpp -d math.lrpc.yaml -o generated/
```

**Implement the server** — derive from the generated shim and implement the pure virtual function:

```cpp
#include "math/math.hpp"

class CalcService : public ex::calc_shim
{
protected:
    int32_t add(int32_t a, int32_t b) override
    {
        return a + b;
    }
};
```

Subclass the generated server to provide a transport, register your service, and feed incoming bytes:

```cpp
class MathServer : public ex::math
{
    void lrpcTransmit(lrpc::span<const uint8_t> bytes) override
    {
        uart_write(bytes.data(), bytes.size());  // your hardware here
    }
};

CalcService calc;
MathServer server;
server.registerService(calc);

// In your receive loop:
server.lrpcReceive(incoming_byte);
```

**Call from the command line:**

```bash
lrpcc calc add 3 7   # result = 10
```

## Documentation

Full documentation is at **[tzijnge.github.io/LotusRpc](https://tzijnge.github.io/LotusRpc/)**, including:

- [Getting started](https://tzijnge.github.io/LotusRpc/getting_started) — complete walkthrough
- [Interface definition reference](https://tzijnge.github.io/LotusRpc/reference/definition) — all YAML options
- [C++ API reference](https://tzijnge.github.io/LotusRpc/cpp_api) — generated server and shim classes
- [Python API](https://tzijnge.github.io/LotusRpc/python-api/client) — client library and definition model
- [Examples](https://tzijnge.github.io/LotusRpc/examples) — math service and STM32 example
