Skip to content

Simple RPC implementation for Arduino.

License

Notifications You must be signed in to change notification settings

drbeefsupreme/simpleRPC

 
 

Repository files navigation

Simple RPC implementation for Arduino.

https://travis-ci.org/jfjlaros/simpleRPC.svg?branch=master https://readthedocs.org/projects/simplerpc/badge/?version=latest

This library provides a simple way to export Arduino functions as remote procedure calls. The exported method definitions are communicated to the host, which is then able to generate an API interface.

Features:

  • For each method, only one line of code is needed for exporting.
  • Automatic parameter- and return type inference.
  • Support for all native C types and strings.
  • Support for arbitrary functions and class methods.
  • Optional function and parameter naming and documentation.
  • Support for PROGMEM's F() macro to reduce memory footprint.
  • Support for compound data structures like Tuples, Objects (Tuples with internal structure), Vectors and arbitrary combinations of these.
  • Support for different types of I/O interfaces via plugins, e.g.,
    • Hardware serial.
    • Software serial (untested).
    • Wire (untested).
    • Ethernet (untested).
  • Support for using multiple interfaces at the same time.

The Arduino library is independent of any host implementation, a Python API client library is provided as a reference implementation.

Please see ReadTheDocs for the latest documentation.

Quick start

Export any function e.g., digitalRead() and digitalWrite() using the interface() function.

#include <simpleRPC.h>

HardwareSerialIO io;

void setup(void) {
  Serial.begin(9600);
  io.begin(Serial);
}

void loop(void) {
  interface(io, digitalRead, "", digitalWrite, "");
}

These functions are now available on the host under names method0() and method1().

The documentation string can be used to name and describe the method.

interface(
  io,
  digitalRead,
    "digital_read: Read digital pin. @pin: Pin number. @return: Pin value.",
  digitalWrite,
    "digital_write: Write to a digital pin. @pin: Pin number. @value: Pin value.");

This is reflected on the host, where the methods are now named digital_read() and digital_write() and where the provided API documentation is also available. In the client reference implementation documentation, contains an example on how this works.

Further reading

Please read :doc:`usage` for more information about exporting normal functions, class member functions and documentation conventions.

If you want to create your own host library implementation for other programming languages, the section :doc:`protocol` should help you on your way.

About

Simple RPC implementation for Arduino.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 97.7%
  • Makefile 1.2%
  • C 1.1%