https://github.com/araffin/arduino-robust-serial
A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.
https://github.com/araffin/arduino-robust-serial
arduino bluetooth c communication cpp protocol python raspberry-pi rust serial sockets
Last synced: about 1 month ago
JSON representation
A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.
- Host: GitHub
- URL: https://github.com/araffin/arduino-robust-serial
- Owner: araffin
- License: mit
- Created: 2018-04-05T14:37:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-10T17:24:04.000Z (about 2 years ago)
- Last Synced: 2024-04-26T19:21:56.890Z (about 1 year ago)
- Topics: arduino, bluetooth, c, communication, cpp, protocol, python, raspberry-pi, rust, serial, sockets
- Language: C++
- Homepage: https://medium.com/@araffin/simple-and-robust-computer-arduino-serial-communication-f91b95596788
- Size: 14.6 KB
- Stars: 130
- Watchers: 7
- Forks: 28
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Robust Arduino Serial Protocol
**Robust Arduino Serial** is a simple and robust serial communication protocol. It was designed to make two Arduinos communicate, but can also be useful when you want a computer (e.g. a Raspberry Pi) to communicate with an Arduino.
**Please read the [Medium Article](https://medium.com/@araffin/simple-and-robust-computer-arduino-serial-communication-f91b95596788) to have an overview of this protocol.**
Implementations are available in various programming languages:
- Arduino (`arduino-serial/` folder)
- [Python](https://github.com/araffin/python-arduino-serial)
- [C++](https://github.com/araffin/cpp-arduino-serial)
- [Rust](https://github.com/araffin/rust-arduino-serial)**Examples** are provided in each repository.
To clone all the repositories at once, tou need to use the `--recursive` command:
```
git clone https://github.com/araffin/arduino-robust-serial.git --recursive
```Table of Contents
=================* [Provided Functions](#provided-functions)
* [Arduino Implementation](#arduino-implementation)
* [1. Using Arduino IDE](#1-using-arduino-ide)
* [2. Using Arduino Makefile (Recommended)](#2-using-arduino-makefile-recommended)
* [Python Implementation](#python-implementation)
* [C Implementation](#c-implementation)
* [Rust Implementation](#rust-implementation)
* [Real Life Example](#real-life-example)
* [Acknowledgments](#acknowledgments)### Provided Functions
Please check examples in the different repos to have the parameters details for each programming language.
- `read_order()`: Read one byte from a file/serial port and convert it to an order (equivalent to read_i8)
- `read_i8()`: Read one byte from a file/serial port and convert it to a 8 bits int
- `read_i16()`: Read one byte from a file/serial port and convert it to a 16 bits int
- `read_i32()`: Read one byte from a file/serial port and convert it to a 32 bits int
- `write_order()`: Write an order to a file/serial port. (equivalent to write_i8)
- `write_i8()`: Write one byte int to a file/serial port.
- `write_i16()`: Write two bytes (16-bits) int to a file/serial port.
- `write_i32()`: Write four bytes (32-bits) int to a file/serial port.### Arduino Implementation
#### 1. Using Arduino IDE
Open `arduino-board/slave/slave.ino` in your Arduino IDE.
#### 2. Using Arduino Makefile (Recommended)
This method only works with Linux/Mac Os systems: [https://github.com/sudar/Arduino-Makefile](https://github.com/sudar/Arduino-Makefile)
Install Arduino Makefile.
```
sudo apt-get install arduino-mk
```Compile and upload the code to the Arduino (please check the board name in the Makefile):
```
cd arduino-board/
make
make upload
```### Python Implementation
[](https://travis-ci.org/araffin/python-arduino-serial)
Python repository: [https://github.com/araffin/python-arduino-serial](https://github.com/araffin/python-arduino-serial)
### C++ Implementation
[](https://travis-ci.org/araffin/cpp-arduino-serial)
C++ repository: [https://github.com/araffin/cpp-arduino-serial](https://github.com/araffin/cpp-arduino-serial)
### Rust Implementation
[](https://travis-ci.org/araffin/rust-arduino-serial) [](https://ci.appveyor.com/project/araffin/rust-arduino-serial/branch/master)
Rust repository: [https://github.com/araffin/rust-arduino-serial](https://github.com/araffin/rust-arduino-serial)
### Real Life Example
This protocol was used on the Racing Robot: [https://github.com/sergionr2/RacingRobot](https://github.com/sergionr2/RacingRobot)
[](https://www.youtube.com/watch?v=xhI71ZdSh6k)
### Acknowledgments
I would like to thanks Dara Ly for the original idea of communicating with the Arduino via a command parser, and Xuan Zhang for fixing Arduino limited buffer issue.