-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for 12.0 PJON version, changes for docs
- Loading branch information
Oleh L. Halytskyi
committed
Jan 9, 2020
1 parent
e6e93a3
commit 16b7f6f
Showing
18 changed files
with
273 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
# PJON-gRPC | ||
PJON-gRPC is a server-client interface for linux-based machines (scripts can be written on [different languages](https://grpc.io/docs/)) and devices Arduino, ATtiny, ATmega, ESP8266, etc. | ||
|
||
### Components | ||
PJON-gRPC is a server-client interface for linux-based machines (applications can be written on [different languages](https://grpc.io/docs/)) and devices Arduino, ATtiny, ATmega, ESP8266, etc. | ||
|
||
## Components | ||
|
||
**PJON™** (Padded Jittering Operative Network) is an Arduino compatible, multi-master, multi-media communications bus system created and mantained by Giovanni Blu Mitolo gioscarab@gmail.com https://github.com/gioblu/PJON | ||
|
||
**gRPC** is a modern open source high performance RPC framework that can run in any environment https://github.com/grpc/grpc | ||
|
||
### Server features | ||
## Server features | ||
|
||
- Receive requests from application located on RPi/PC (via gRPC, for example [pjon_grpc_client.py](examples/clients/python/pjon_grpc_client.py)) and send back responses from devices (like Arduino) connected with RPi through PJON [ThroughSerialAsync](https://github.com/gioblu/PJON/tree/master/src/strategies/ThroughSerialAsync) strategy. | ||
- Receive and forward messages to application located on RPi/PC from devices through PJON [ThroughSerialAsync](https://github.com/gioblu/PJON/tree/master/src/strategies/ThroughSerialAsync) strategy (via gRPC, for example [pjon_grpc_clientserver.py](examples/clients/python/pjon_grpc_clientserver.py)) | ||
- Communication between RPi/PC and devices (like Arduino) through any [PJON strategies](https://github.com/gioblu/PJON/blob/master/documentation/configuration.md) via [router](examples/devices/router_extender) | ||
- Can be configured for working with 2 modules at the same time (see [pjon-grpc.cfg](server/conf/pjon-grpc.cfg)). Logic isolated in separate threads for maximum performance. Very useful if need to distribute the load, for example, `1st module` can be configured for accept and response on requests, `2nd module` can be configured for accept only incoming messages. | ||
|
||
**Required** PJON version >[11.1](https://github.com/gioblu/PJON/tree/11.1) | ||
## Tested with | ||
|
||
**PJON version:** [12.0](https://github.com/gioblu/PJON/tree/12.0)<br> | ||
**Device:** [Raspberry Pi 3](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)<br> | ||
**OS:** [Raspbian buster](https://www.raspberrypi.org/downloads/raspbian/) | ||
|
||
**Tested** and fully compatible with [master branch](https://github.com/gioblu/PJON/tree/master) | ||
## Video example (for old version, will be changed) | ||
|
||
#### Video example | ||
https://www.youtube.com/watch?v=J8FVPZW4y4I |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
**clients** - examples of applications which running on RPi/PC side | ||
# Examples | ||
|
||
**devices** - examples of Arduino sketches | ||
[clients](clients) - examples of applications which running on RPi/PC side | ||
|
||
[devices](devices) - examples of Arduino sketches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,48 @@ | ||
### Install gRPC and gRPC tools: | ||
``` | ||
$ virtualenv .venv | ||
$ source .venv/bin/activate | ||
$ python -m pip install --upgrade pip | ||
$ python -m pip install grpcio | ||
$ python -m pip install grpcio-tools | ||
``` | ||
# Client python tools | ||
|
||
## Install gRPC and gRPC tools | ||
|
||
### Generate gRPC code: | ||
```bash | ||
apt-get install python3 python3-dev python3-venv -y | ||
python3 -m venv .venv | ||
source .venv/bin/activate | ||
python -m pip install --upgrade pip | ||
python -m pip install grpcio | ||
python -m pip install grpcio-tools | ||
``` | ||
$ ./run_codegen.py | ||
|
||
### Generate gRPC code | ||
|
||
```bash | ||
./run_codegen.py | ||
``` | ||
|
||
OR | ||
``` | ||
$ python -m grpc_tools.protoc -Iprotos --python_out=. --grpc_python_out=. protos/pjongrpc.proto | ||
``` | ||
|
||
### Examples of run | ||
**pjon_grpc_client.py** - client for sending requests to devices and getting responses | ||
```bash | ||
python -m grpc_tools.protoc -Iprotos --python_out=. --grpc_python_out=. protos/pjongrpc.proto | ||
``` | ||
|
||
## Examples of run | ||
|
||
[pjon_grpc_client.py](pjon_grpc_client.py) - client for sending requests to devices and getting responses | ||
|
||
```bash | ||
$ ./pjon_grpc_client.py 1 11 n | ||
Client received: n>1 | ||
``` | ||
|
||
where: | ||
``` | ||
|
||
```bash | ||
1 - master ID | ||
11 - device ID | ||
n - command | ||
``` | ||
**pjon_grpc_clientserver.py** - client-server script for receiving messages from devices (works in daemon mode) | ||
``` | ||
|
||
[pjon_grpc_clientserver.py](pjon_grpc_clientserver.py) - client-server script for receiving messages from devices (works in daemon mode) | ||
|
||
```bash | ||
$ ./pjon_grpc_clientserver.py | ||
Client-Server received: node_id=11, data=29 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
### Arduino examples | ||
# Arduino devices | ||
|
||
#### Makefile | ||
## Makefile | ||
|
||
If you want compiling code and flashing it to Arduino directly from RPi need install/configure [Arduino-Makefile](https://github.com/sudar/Arduino-Makefile). | ||
|
||
Install necessary packages | ||
``` | ||
$ sudo apt-get install python-serial git | ||
``` | ||
|
||
Download [Arduino IDE 1.6.13](https://www.arduino.cc/en/Main/OldSoftwareReleases#previous) to `/opt` and: | ||
```bash | ||
apt-get install python-serial git -y | ||
``` | ||
$ cd /opt | ||
$ tar xf arduino-1.6.13-linuxarm.tar.xz && rm -rf arduino-1.6.13-linuxarm.tar.xz | ||
$ ln -s arduino-1.6.13 arduino | ||
$ cd arduino | ||
$ git clone https://github.com/sudar/Arduino-Makefile.git | ||
$ cd Arduino-Makefile && git checkout 1.6.0 | ||
|
||
Download [Arduino IDE 1.8.10](https://www.arduino.cc/en/Main/OldSoftwareReleases#previous) to `/opt` and run commands | ||
|
||
```bash | ||
cd /opt | ||
tar xf arduino-1.8.10-linuxarm.tar.xz | ||
rm -rf arduino-1.8.10-linuxarm.tar.xz | ||
ln -s arduino-1.8.10 arduino | ||
cd /opt | ||
git clone https://github.com/sudar/Arduino-Makefile.git | ||
cd Arduino-Makefile && git checkout 1.6.0 | ||
``` | ||
|
||
Add PJON library to Arduino IDE (assume that you downloaded it to `/opt/libraries/PJON`): | ||
``` | ||
$ cd /opt/arduino/libraries | ||
$ ln -s /opt/libraries/PJON | ||
|
||
```bash | ||
cd /opt/arduino/libraries | ||
ln -s /opt/libraries/PJON | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
# Router extenders | ||
|
||
**router_extender** - communication between RPi and devices with different strategies | ||
```cpp | ||
|
||
```bash | ||
RPi <—--ThroughSerialAsync---> Arduino (router) <—--SoftwareBitBang--—> Arduino (device1) | ||
| | ||
<---ThroughSerialAsync (HC-12)---> Arduino (device2) | ||
| | ||
<--- Other PJON strategy---> Arduino (deviceN) | ||
``` | ||
**router_1_bus** - sketch for Arduino router which allow RPi communicate with devices connected to one PJON bus, see device example: [device1](device1) | ||
|
||
**router_2_bus** - sketch for Arduino router which allow RPi communicate with devices connected to two different PJON bus, see device examples: [device1](device1) and [device2](device2) | ||
[router_1_bus](router_1_bus) - sketch for Arduino router which allow RPi communicate with devices connected to one PJON bus, see device example: [device1](device1) | ||
|
||
[router_2_bus](router_2_bus) - sketch for Arduino router which allow RPi communicate with devices connected to two different PJON buses, see device examples: [device1](device1) and [device2](device2) | ||
|
||
**device1** - sketch for Arduino device which connected to Arduino router via [SoftwareBitBang](https://github.com/gioblu/PJON/tree/master/src/strategies/SoftwareBitBang) strategy | ||
[device1](device1) - sketch for Arduino device which connected to Arduino router via [SoftwareBitBang](https://github.com/gioblu/PJON/tree/master/src/strategies/SoftwareBitBang) strategy | ||
|
||
**device2** - sketch for Arduino device which connected to Arduino router via [ThroughSerialAsync](https://github.com/gioblu/PJON/tree/master/src/strategies/ThroughSerialAsync) strategy ([HC-12 module](http://statics3.seeedstudio.com/assets/file/bazaar/product/HC-12_english_datasheets.pdf)) | ||
[device2](device2) - sketch for Arduino device which connected to Arduino router via [ThroughSerialAsync](https://github.com/gioblu/PJON/tree/master/src/strategies/ThroughSerialAsync) strategy ([HC-12 module](http://statics3.seeedstudio.com/assets/file/bazaar/product/HC-12_english_datasheets.pdf)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.