Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firmata-io

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firmata-io

Firmata protocol implementation

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
decreased by-16.58%
Maintainers
1
Weekly downloads
 
Created
Source

Firmata-io

This is Firmata.js without a default Transport.

Install

Install Firmata-io:

npm install firmata-io --save

Install a Transport:

npm install serialport --save

Transports

  • Serialport
  • Etherport

Basic Usage

With A Transport Class

Here's an example using the Serialport class:

// Require your Transport!
const Serialport = require("serialport"); 
// Pass the Transport class to the transport binding 
// function exported by firmata-io. The transport binding
// function will return the Firmata class object with
// the Transport class bound in its scope. 
const Firmata = require("firmata-io")(Serialport);

Firmata.requestPort((error, port) => {
  if (error) {
    console.log(error);
    return;
  }

  const board = new Firmata(port.comName);

  board.on("close", () => {
    // Unplug the board to see this event!
    console.log("Closed!");
  });
});

With A Transport Instance

Here's an example using a Serialport instance:

// Require your Transport!
const Serialport = require("serialport");
// Get the Firmata class without a bound transport. 
const Firmata = require("firmata-io").Firmata;

Serialport.list().then(ports => {
  // Figure which port to use...
  const port = ports.find(port => port.manufacturer.startsWith("Arduino"));
  
  // Instantiate an instance of your Transport class
  const transport = new Serialport(port.comName);

  // Pass the new instance directly to the Firmata class
  const board = new Firmata(transport);

  board.on("close", () => {
    // Unplug the board to see this event!
    console.log("Closed!");
  });
});

License

(The MIT License)

Copyright (c) 2011-2015 Julian Gautier julian.gautier@alumni.neumont.edu
Copyright (c) 2015-2019 The Firmata.js Authors (see AUTHORS.md)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 15 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc