Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/minihil_build_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: minihil Build Checker (SIL)
on:
push:
branches: [ master ]
paths:
- 'sw/minihil/**/*.cpp'
- 'sw/minihil/**/*.hpp'
- 'sw/minihil/CMakeLists.txt'
pull_request:
branches: [ master ]
paths:
- 'sw/minihil/**/*.cpp'
- 'sw/minihil/**/*.hpp'
- 'sw/minihil/CMakeLists.txt'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config nlohmann-json3-dev

- name: Configure CMake
run: |
cmake -B sw/minihil/build -S sw/minihil

- name: Build project
run: |
cmake --build sw/minihil/build --config Release
48 changes: 48 additions & 0 deletions .github/workflows/minihil_cc_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: minihil C++ Checker
on:
push:
branches: [ master ]
paths:
- 'sw/minihil/**/*.cpp'
- 'sw/minihil/**/*.hpp'
pull_request:
branches: [ master ]
paths:
- 'sw/minihil/**/*.cpp'
- 'sw/minihil/**/*.hpp'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Check length of line in modules
id: long_line_checker
run: |
echo "Checking the length of lines in modules"
modules_ok=0
files=($(find sw/minihil/ -type f \( -name '*.cpp' -o -name '*.hpp' \)))
for f in "${files[@]}"; do
line_length=$(wc -L < "${f}")
echo "${f} : $line_length"
if [[ $line_length -gt 500 ]]; then
modules_ok=1
fi
done
[[ $modules_ok -eq 0 ]] && echo "All modules are good" || exit 1

- name: Check number of lines in modules
id: num_line_checker
run: |
echo "Checking the number of lines in modules"
modules_ok=0
files=($(find sw/minihil/ -type f \( -name '*.cpp' -o -name '*.hpp' \)))
for f in "${files[@]}"; do
line_count=$(wc -l < "${f}")
echo "${f} : $line_count"
if [[ $line_count -gt 500 ]]; then
modules_ok=1
fi
done
[[ $modules_ok -eq 0 ]] && echo "All modules are good" && exit 0 || exit 1
Empty file modified .gitignore
100755 → 100644
Empty file.
13 changes: 10 additions & 3 deletions .readthedocs.yml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
version: 2
python:
version: '3.7'

build:
os: ubuntu-22.04
tools:
python: "3.10"

sphinx:
configuration: docs/source/conf.py
formats: all

formats:
- pdf
- htmlzip
Empty file modified LICENSE
100755 → 100644
Empty file.
84 changes: 71 additions & 13 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The README is used to introduce the tool and provide instructions on
how to install the tool, any machine dependencies it may have and any
other information that should be provided before the tool is installed.

[![minihil-desktop C++ CI](https://github.com/electux/minihil/actions/workflows/minihil_desktop_cc_checker.yml/badge.svg)](https://github.com/electux/minihil/actions/workflows/minihil_desktop_cc_checker.yml) [![GitHub issues open](https://img.shields.io/github/issues/electux/minihil.svg)](https://github.com/electux/minihil/issues) [![GitHub contributors](https://img.shields.io/github/contributors/electux/minihil.svg)](https://github.com/electux/minihil/graphs/contributors)
[![minihil C++ Checker](https://github.com/electux/minihil/actions/workflows/minihil_cc_checker.yml/badge.svg)](https://github.com/electux/minihil/actions/workflows/minihil_cc_checker.yml) [![minihil Build Checker (SIL)](https://github.com/electux/minihil/actions/workflows/minihil_build_checker.yml/badge.svg)](https://github.com/electux/minihil/actions/workflows/minihil_build_checker.yml) [![GitHub issues open](https://img.shields.io/github/issues/electux/minihil.svg)](https://github.com/electux/minihil/issues) [![GitHub contributors](https://img.shields.io/github/contributors/electux/minihil.svg)](https://github.com/electux/minihil/graphs/contributors)

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
Expand All @@ -19,20 +19,82 @@ other information that should be provided before the tool is installed.

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

### Installation
### About minihild

![Debian Linux OS](https://raw.githubusercontent.com/electux/minihil/master/docs/debtux.png)
The core of the software is `minihild` — a POSIX C++ daemon running as a server on the Raspberry Pi target. It listens for incoming connections on TCP port `9000` and parses **JSON-RPC 2.0** commands. It controls the **Waveshare Relay Board (B)** (an 8-channel relay board) via standard Linux character device GPIO controls (`libgpiod` v2).

Navigate to release **[page](https://github.com/electux/minihil/releases)** download and extract release archive.
It is designed with a decoupled architecture to allow easy expansion (e.g. adding WebSockets) and supports **Software-in-the-Loop (SIL) simulation** so that you can compile and test the server and its API directly on your local developer PC without Raspberry Pi hardware.

To install **minihil** type the following
---

### SIL (Software-in-the-Loop) Host Build

To compile and run the daemon locally on your developer PC in SIL mock mode:

#### Prerequisites
Install the required JSON header libraries:
```bash
sudo apt-get install nlohmann-json3-dev
```

#### Compile and Run
```bash
# Configure and compile using CMake
cmake -B sw/minihil/build -S sw/minihil
cmake --build sw/minihil/build

# Start the mock daemon
./sw/minihil/build/minihild
```
The daemon will boot in SIL mode and print:
`[SilRelayController] Software-in-the-Loop simulation initialized.`

---

### Dependencies
### Yocto Image Build (Raspberry Pi Target)

**minihil** requires next modules and libraries
MiniHIL packages `minihild` into a custom Yocto Linux image (`minihil-image`) using `meta-raspberrypi` and Poky.

#### Prerequisites
Ensure your build host has all required packages for Yocto Scarthgap (refer to [rpi-base-platform/README.md](file:///data/dev/raspberry/minihil/github/minihil/sw/rpi-base-platform/README.md) for the list of packages).

#### Compile target image
```bash
# 1. Initialize environment (sources Poky and sets up configs/layers)
source sw/setup-env.sh

# 2. Trigger the bitbake build
bitbake minihil-image
```
This compiles the C++ application, bundles the systemd daemon config (`minihil.service`) to start automatically on boot, and outputs a flashable image.

---

### JSON-RPC 2.0 API Specification

You can send JSON-RPC text frames (terminated by `\n`) to port `9000`.

#### `set_relay`
Energize or de-energize a relay channel (1 to 8):
- **Request**:
```json
{"jsonrpc": "2.0", "method": "set_relay", "params": {"relay_id": 3, "state": true}, "id": 1}
```
- **Response**:
```json
{"jsonrpc": "2.0", "result": {"relay_id": 3, "state": true, "success": true}, "id": 1}
```

#### `get_relays`
Query states of all 8 relay channels:
- **Request**:
```json
{"jsonrpc": "2.0", "method": "get_relays", "id": 2}
```
- **Response**:
```json
{"jsonrpc": "2.0", "result": {"1": false, "2": false, "3": true, "4": false, "5": false, "6": false, "7": false, "8": false}, "id": 2}
```

### Docs

Expand All @@ -46,14 +108,10 @@ More documentation and info at

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Copyright (C) 2020 by [electux.github.io/minihil](https://electux.github.io/minihil)
Copyright (C) 2020 - 2026 by [electux.github.io/minihil](https://electux.github.io/minihil)

**minihil** is free software; you can redistribute it and/or modify it.

Lets help and support Raspberry PI && GNOME.

<a href="https://www.raspberrypi.org/donate/">
<img src="https://raw.githubusercontent.com/electux/minihil/master/docs/RPi.png" alt="RPi" width="350" height="98">
</a> <a href="https://www.gnome.org/support-gnome/donate/">
<img src="https://raw.githubusercontent.com/electux/minihil/master/docs/GNOME.png" alt="GNOME" width="327" height="115">
</a>
<img src="https://raw.githubusercontent.com/electux/minihil/master/docs/foundations.png" alt="Raspberry Pi & GNOME Foundations" width="681" height="100">
Binary file removed docs/GNOME.png
Binary file not shown.
Binary file removed docs/RPi.png
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: f8da516a4c01458efcaab50cf2a597cf
config: a9222a8de56e8140ddb3be6ef6c463bd
tags: 645f666f9bcd5a90fca523b33c5a78b7
103 changes: 85 additions & 18 deletions docs/build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ minihil

**minihil** is development device which can be used for HWIL.

The README is used to introduce the tool and provide instructions on
how to install the tool, any machine dependencies it may have and any
other information that should be provided before the tool is installed.
The docs introduce the tool and provide instructions on how to install, build, and use the MiniHIL software.

.. toctree::
:hidden:
Expand All @@ -23,33 +21,97 @@ other information that should be provided before the tool is installed.
.. |Documentation Status| image:: https://readthedocs.org/projects/minihil/badge/?version=latest
:target: https://minihil.readthedocs.io/projects/minihil/en/latest/?badge=latest

Installation
-------------
About minihild
--------------

Navigate to release `page`_ download and extract release archive.
The core of the software is ``minihild`` — a POSIX C++ daemon running as a server on the Raspberry Pi target. It listens for incoming connections on TCP port ``9000`` and parses **JSON-RPC 2.0** commands. It controls the **Waveshare Relay Board (B)** (an 8-channel relay board) via standard Linux character device GPIO controls (``libgpiod`` v2).

.. _page: https://github.com/electux/minihil/releases
It is designed with a decoupled architecture to allow easy expansion (e.g. adding WebSockets) and supports **Software-in-the-Loop (SIL) simulation** so that you can compile and test the server and its API directly on your local developer PC without Raspberry Pi hardware.

To install **minihil** type the following
SIL (Software-in-the-Loop) Host Build
-------------------------------------

To compile and run the daemon locally on your developer PC in SIL mock mode:

Prerequisites
~~~~~~~~~~~~~
Install the required JSON header libraries:

.. code-block:: bash

in progress
sudo apt-get install nlohmann-json3-dev

Compile and Run
~~~~~~~~~~~~~~~
.. code-block:: bash

Dependencies
-------------
# Configure and compile using CMake
cmake -B sw/minihil/build -S sw/minihil
cmake --build sw/minihil/build

**minihil** requires next modules and libraries
in progress
# Start the mock daemon
./sw/minihil/build/minihild

Project structure
------------------
The daemon will boot in SIL mode and print:
``[SilRelayController] Software-in-the-Loop simulation initialized.``

**minihil** is based on POP.
Yocto Image Build (Raspberry Pi Target)
---------------------------------------

MiniHIL packages ``minihild`` into a custom Yocto Linux image (``minihil-image``) using ``meta-raspberrypi`` and Poky.

Prerequisites
~~~~~~~~~~~~~
Ensure your build host has all required packages for Yocto Scarthgap (refer to ``sw/rpi-base-platform/README.md`` for the list of packages).

Compile target image
~~~~~~~~~~~~~~~~~~~~
.. code-block:: bash

in progress
# 1. Initialize environment (sources Poky and sets up configs/layers)
source sw/setup-env.sh

# 2. Trigger the bitbake build
bitbake minihil-image

This compiles the C++ application, bundles the systemd daemon config (``minihil.service``) to start automatically on boot, and outputs a flashable image.

JSON-RPC 2.0 API Specification
------------------------------

You can send JSON-RPC text frames (terminated by ``\n``) to port ``9000``.

set_relay
~~~~~~~~~
Energize or de-energize a relay channel (1 to 8):

* **Request**:

.. code-block:: json

{"jsonrpc": "2.0", "method": "set_relay", "params": {"relay_id": 3, "state": true}, "id": 1}

* **Response**:

.. code-block:: json

{"jsonrpc": "2.0", "result": {"relay_id": 3, "state": true, "success": true}, "id": 1}

get_relays
~~~~~~~~~~
Query states of all 8 relay channels:

* **Request**:

.. code-block:: json

{"jsonrpc": "2.0", "method": "get_relays", "id": 2}

* **Response**:

.. code-block:: json

{"jsonrpc": "2.0", "result": {"1": false, "2": false, "3": true, "4": false, "5": false, "6": false, "7": false, "8": false}, "id": 2}

Copyright and licence
----------------------
Expand All @@ -62,5 +124,10 @@ Copyright and licence
.. |License: Apache 2.0| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
:target: https://opensource.org/licenses/Apache-2.0

Copyright (C) 2020 by `electux.github.io/minihil <https://electux.github.io/minihil>`_
Copyright (C) 2020 - 2026 by `electux.github.io/minihil <https://electux.github.io/minihil>`_

.. image:: https://raw.githubusercontent.com/electux/minihil/master/docs/foundations.png
:alt: Raspberry Pi & GNOME Foundations
:width: 681px
:height: 100px

Loading
Loading