Giter Site home page Giter Site logo

serializer's Introduction

Serializer

arduino serialization library for transfering variables between arduinos

this library implements two classes:

_Serializer (default instance is Serializer)

which has the methods pack and unpack these can be used directly (look at the advanced examples) however the suggested way is to use the second class.

SerialServerClass

this takes a serial class in its constructor:

SerialServerClass server(Serial);

So it can be used on any serial port. default instances will be created to match the serial objects available:

SerialServer
SerialServer1
SerialServer2
SerialServer3

Also works with AltSoftSerial (see the simple AltSoftSerial_Server example)
It may also work with SoftwareSerial, NeoSWSerial but these are not tested.

Methods:

add_response method:

this has two overloads, one that will send a reply and one that calls a function when that sequence is recieved.

void add_response(char request[], void* response, uint16_t size);

where the first argument is the string that should be recieved (terminated by carraige return, this is added by library)
the second is a pointer to the object you want to send. and the third is it's size (the size of a pointer will always be the same, so we need the size of the actual object)

to use is as simple as:

char id[20] = "I'm a demo"; // note that this must be a global variable and cannot itself be a pointer
SerialServer.add_response("ID?", id, sizeof(id));

to send more complex data or several variables at once:

struct {
uint8_t var1;
int32_t var2;
char array[50];
} data;
SerialServer.add_response("Data?", data, sizeof(data));

so this automatically takes into account the size of the object to be sent.

and to recieve simply declare the variable in exactly the same way and call make_request:

struct {
uint8_t var1;
int32_t var2;
char array[50];
} data;
bool succeeded = SerialServer.make_request("Data?", data, sizeof(data));

there is also an optional timeout argumentat the end set to a default of 1000ms

serializer's People

Contributors

jamesgkent avatar

Watchers

 avatar  avatar

serializer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.