Giter Site home page Giter Site logo

stevemarple / arduino-commandhandler Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 2.0 25 KB

An Arduino library to parse commands from a serial stream.

License: GNU Lesser General Public License v2.1

C++ 86.68% Makefile 13.32%
arduino arduino-library command-parsing command-handler

arduino-commandhandler's Introduction

ComandHandler

CommandHandler is a library for Arduino and other Wiring-type environments to implement command parsing from serial data streams where characters arrive separately. Multiple serial data streams can be processed simultaneously by assigning a separate CommandHandler object for each serial stream. To minimise memory usage the command handlers can be shared between serial data streams.

The library does not use any dynamic memory allocation. The caller is required to pass in the buffer required, thereby allowing full control of the memory used.

License

The SoftWire library is licensed with the GNU Lesser General Public License. See LICENSE.txt for details.

Version 2.0 changes

Partial command matching now possible

CommandOption now takes an optional additional parameter, partialMatch. Previously all commands tested by CommandHandler were partial matches. This meant short commands such as AT were required to be placed after longer commands in the CommandOptions array, otherwise it would match the longer commands. By setting partialMatch to false CommandHandler can now be instructed to call the handler only on a full match for a given command.

Incompatible handler changes

Version 2.0 changes the function parameters and return type of the command handlers. The change was introduced so that callback handlers can be used with multiple serial Stream objects simultaneously.

The handler callback is now given the command string (after any full or partial match has been eliminated), a reference to the serial Stream object from which the command was read (enabling output and errors to be printed to the approriate destination), and also a reference to the CommandOption object being processed. The handler is now expected to return a boolean value, with true interpreted as meaning the command was successfully identified, and false meaning the command was not identified. In the case of commands which were marked as a partial match the false return value from the handler signifies that the handler(s) for other commands with matching command strings should also be called.

arduino-commandhandler's People

Contributors

stevemarple avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.