Code Monkey home page Code Monkey logo

ushet's Introduction

uSHET: A Malloc-Free SHET Client Library for Microcontrollers

A simple microcontroller-friendly C library for interfacing with SHET targeted at microcontrollers forked from SHETC and extended to support the complete SHET client protocol. uSHET intends to replace SHETSource as the de-facto microcontroller SHET interface.

uSHET supports the following key features:

  • Transport-independent: The library simply expects to be fed strings received from a network device and will call a user-defined callback with strings to transmit. This means the library is suitable for use with any network interface/library.
  • Malloc-free: The library does not use dynamic memory allocation and thus can have deterministic memory requirements and use only statically-allocated storage. This has the obvious side-effect that the library cannot handle arbitrarily large commands but this should not impact most applications.
  • Small-ish: Though uSHET has not received any serious space optimisation passes, it is based on the compact jsmn JSON parser and avoids needlessly duplicating JSON strings.
  • Complete SHET client protocol support: uSHET supports the full SHET client protocol and exposes a fairly sane high-level interface, unlike SHETSource. This comes with the trade-off that uSHET is heavier-weight than SHETSource in terms of network requirements, memory requirements and execution overhead since it deals with full JSON strings rather than a compact byte-stream.
  • (Optional) High-Level Wrapper Macros: Includes EZSHET, a library of macros which hide much of the boilerplate required in handling dynamically typed input from SHET.

Documentation

Beginner's tutorials for the EZSHET and uSHET libraries are included in doc and these are the recommended starting point for new users to uSHET.

The uSHET and EZSHET libraries contain fairly extensive API documentation within their header files, shet.h and ezshet.h.

Teaser

The following snippet (which uses EZSHET) should give you a feel for the ease-of-use of the library.

void set_led(shet_state_t *shet, bool state) {
	digitalWrite(led_pin, state);
}
bool get_led(shet_state_t *shet) {
	return digitalRead(led_pin);
}
EZSHET_PROP("/arduino/led", led, SHET_BOOL);

This code creates a new boolean property in SHET at the path "/arduino/led" that controls the state of an LED in an Arduino project.

Test Suite

A test suite is included. It can be compiled and run as follows:

gcc -Wall -Wextra -Werror test.c -o test && ./test

Note that the testbench actually #includes the library sources in order to test a number of internal functions.

ushet's People

Contributors

mossblaser avatar tomjnixon avatar rafagago avatar

Stargazers

 avatar  avatar Alexander Gornak avatar Jeffry avatar Petr Holčák avatar steve hu avatar Cuda Chen avatar unlsycn avatar Berkay Köksal avatar Quang-Ninh Nguyen avatar Scott Lai avatar  avatar Lobsang Sanchez avatar Li avatar MuGdxy avatar Yatharth Bhasin avatar Rodrigo Peixoto avatar Jim Cromie avatar Attie Grande avatar Guido Dipietro avatar Yu Lei avatar  avatar  avatar Fergus Bray avatar Ryder Rishel avatar Mohamed Saher avatar X Caminhante avatar Valentin Berlier avatar Tai-Yuan Kuo avatar 张zq avatar mykola-ambar avatar Philipp Trommler avatar Timothy Grijalva avatar  avatar  avatar abdul dakkak avatar Joey Lawrance avatar Ata Deniz Aydın avatar  avatar Jonny Rhea avatar  avatar  avatar  avatar  avatar Peter Borenstein avatar kai avatar  avatar Max avatar

Watchers

 avatar  avatar James Sandford avatar Matthew Leach avatar Karl Sutt avatar Amanieu d'Antras avatar James Cloos avatar zhouzhenghui avatar

ushet's Issues

addition of _FN for HAS_ARGS() in cpp_magic.h causes problems

Hey,
I tried the cpp_magic.h macros and found out, that the _FN suffix to the HAS_ARGS() functionality causes problems for me. Based on the version history, this seems to be the newest addition. Here is the error:

Pasting formed ')_FN', an invalid preprocessing token

When reverting to the old version, everything works. I believe the change fixes only the problem described by @RafaGago that caused the motivation for the change, but breaks everything else? Anyway, this change should be revised!

cpp_magic.h might be a cause for com.apple.dt.SourceKitService "runaway"

Hey, since I've been toying around with cpp_magic.h a bit, I noticed that using the macros in my source code make Xcode, specifically com.apple.dt.SourceKitService go crazy on me, taking up to 300% CPU. Now, this might just be a side effect of the recursion happening in the pre-processor code and Xcode trying to understand the code itself to show me the correct error messages (as it continually resolves pre-processor code already internally), but perhaps this is also linked to something that can be fixed?

I am not sure how to proceed on this issue, but I wanted to put this here, just for the record.

Question about avoiding compiler's notes re expansion macros for cpp_magic.

Hi,

First of all many thanks for your efforts!

I'm using cpp_magic to implement yet another (surely, super fast:-)) logger in C (not C++ where variadic templates help a lot) and the only issue I have is that any error in the use of my macro generates thousands of note: in expansion of macro ‘EVAL...' messages.

I can reduce the number of those notes by adding own MAP-like macros based on EVAL64 -- that's the minimal in my case. But still it gives 400+ notes. So I'm wondering if you have a solution or advice for this issue?

NB I tried to find a gcc diagnostic option (either tweakable from pragmas or acceptable for the whole project) but I failed. Currently I'm thinking about adding some basic macro arithmetic (DEC_/INC_) to count macro arguments and use a limited 0-9 args version for 99% of cases while leave the full-up-to-64 for the reset.

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.