Giter VIP home page Giter VIP logo

jackport.js's Introduction

JackPort.js

JackPort.js is a JavaScript library for handling Serial Port in both Node.js and Chrome Apps.

Motivation

Chrome implementation and Node.js implementation (serialport library) differs. It is hard to write a module that will use Serial Port to work both on Node.js and in Chrome. This library is a first step in unifying these two experiences. It provides minimalistic set of functionality good for small project.

Installation

NPM:

npm install jackport.js --save

Yarn:

yarn add jackport.js

Usage

The library exposes single object for subscribing / sending data to Serial Port. Based on the platform it will be resolved to either Node or Chrome implementation.

Methods

constructor(path: string)

To create a new JackPort object, provide the path to the device (for example /dev/ttyACM0. If you are connecting with Arduino, you will find your device name at the bottom right corner of your Arduino IDE.)

onMessage(fn: (msg: string): void): void

Subscribes to messages sent on the Serial bus. The library waits for the separator \r\n and splits the messages accordingly.

offMessage(fn: (msg: string): void): void

Unsubscribes. The same instance of the function should be passed here as for the subscription.

sendMessage(msg: string): void

Sends the message over the bus.

Examples

You can find simple examples in Examples directory.

License

Library is released under MIT license.

References and attribution

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

jackport.js's People

Contributors

kulak-at avatar

Watchers

James Cloos 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.